deliverable/binutils-gdb.git
9 years agoclean up some target delegation cases
Tom Tromey [Fri, 11 Jul 2014 14:02:03 +0000 (08:02 -0600)] 
clean up some target delegation cases

This patch cleans up some minor inconsistencies in target delegation.
It's primary purpose is to avoid confusion in the code.  A few spots
were checking the "beneath" target; however this can only be NULL for
the dummy target, so such tests are not needed.  Some other spots were
iterating over the beneath targets, looking for a method
implementation.  This is not needed for methods handled by
make-target-delegates, as there is always an implementation.

2014-07-18  Tom Tromey  <tromey@redhat.com>

PR gdb/17130:
* spu-multiarch.c (spu_region_ok_for_hw_watchpoint)
(spu_fetch_registers, spu_store_registers, spu_xfer_partial)
(spu_search_memory, spu_mourn_inferior): Simplify delegation.
* linux-thread-db.c (thread_db_pid_to_str): Always delegate.
* windows-nat.c (windows_xfer_partial): Always delegate.
* record-btrace.c (record_btrace_xfer_partial): Simplify
delegation.
(record_btrace_fetch_registers, record_btrace_store_registers)
(record_btrace_prepare_to_store, record_btrace_resume)
(record_btrace_wait, record_btrace_find_new_threads)
(record_btrace_thread_alive): Likewise.
* procfs.c (procfs_xfer_partial): Always delegate.
* corelow.c (core_xfer_partial): Always delegate.
* sol-thread.c (sol_find_new_threads): Simplify delegation.

9 years agomove exec_make_note_section earlier
Tom Tromey [Fri, 18 Jul 2014 15:35:04 +0000 (09:35 -0600)] 
move exec_make_note_section earlier

This patch moves exec_make_note_section a bit earlier in exec.c.  This
lets us remove an otherwise unnecessary forward declaration and it
also makes the file a bit more in line with other code, as now
_initialize_exec is the final function in the file.

Tested by rebuilding.
I'm committing this as obvious.

2014-07-18  Tom Tromey  <tromey@redhat.com>

* exec.c (exec_make_note_section): Move earlier.

9 years agodaily update
Alan Modra [Fri, 18 Jul 2014 00:00:39 +0000 (09:30 +0930)] 
daily update

9 years agoProperly handle EVEX register aliases
Ilya Tocar [Thu, 17 Jul 2014 09:59:32 +0000 (13:59 +0400)] 
Properly handle EVEX register aliases

gas/

* config/tc-i386.c (parse_register): Set need_vrex.

gas/testsuite/

* gas/i386/x86-64-equ.d: New.
* gas/i386/x86-64-equ.s: New.
* gas/i386/i386.exp: Run x86-64-equ.

9 years agoPR 17170 - testcase for GDB global --statistics regression - fix up.
Jan Kratochvil [Thu, 17 Jul 2014 11:59:03 +0000 (13:59 +0200)] 
PR 17170 - testcase for GDB global --statistics regression - fix up.

Add missing file to previous entry.

9 years agoPR 17170 - testcase for GDB global --statistics regression.
Jan Kratochvil [Thu, 17 Jul 2014 11:56:24 +0000 (13:56 +0200)] 
PR 17170 - testcase for GDB global --statistics regression.

gdb/testsuite/
2014-07-17  Jan Kratochvil  <jan.kratochvil@redhat.com>

PR gdb/17170
* gdb.base/statistics.exp: New file.

Message-ID: <20140712174217.GA1478@host2.jankratochvil.net>

9 years agoAdd reference to PR 17170 to previous entry.
Doug Evans [Thu, 17 Jul 2014 09:42:55 +0000 (02:42 -0700)] 
Add reference to PR 17170 to previous entry.

9 years agoFix 17170.
Doug Evans [Thu, 17 Jul 2014 09:38:32 +0000 (02:38 -0700)] 
Fix 17170.

* maint.c (count_symtabs_and_blocks): Handle NULL
current_program_space.
(report_command_stats): Check global enabled flag in addition to
recorded enabled flag.
(make_command_stats_cleanup): Handle msg_type == 0, startup.

testsuite/
* gdb.base/maint.exp: Update testing of per-command stats.

9 years agodaily update
Alan Modra [Thu, 17 Jul 2014 00:00:48 +0000 (09:30 +0930)] 
daily update

9 years agoor1k: increase linux TEXT_START_ADDR to 0x2000
Stefan Kristiansson [Wed, 16 Jul 2014 21:25:20 +0000 (00:25 +0300)] 
or1k: increase linux TEXT_START_ADDR to 0x2000

Override the default value of 0x0000 defined in
TEXT_START_ADDR to avoid linux executables to be mapped
at zero page.

ld/
* emulparams/elf32or1k_linux.sh (TEXT_START_ADDR): Increase from
0x0 to first page boundary at 0x2000.

9 years agoLinux: Use kill_lwp/tkill instead of kill when killing a process
Pedro Alves [Wed, 16 Jul 2014 19:06:55 +0000 (20:06 +0100)] 
Linux: Use kill_lwp/tkill instead of kill when killing a process

Since we use tkill everywhere, using kill to try to kill each lwp
individually looks suspiciously odd.  We should really be using tgkill
everywhere, but at least while we don't get there this makes us
consistent.

gdb/gdbserver/
2014-07-16  Pedro Alves  <palves@redhat.com>

* linux-low.c (linux_kill_one_lwp): Use kill_lwp, not kill.

gdb/
2014-07-16  Pedro Alves  <palves@redhat.com>

* linux-nat.c (kill_callback): Use kill_lwp, not kill.

9 years agogdb.trace/tfile.c: Remove Thumb bit in one more more, general cleanup
Pedro Alves [Wed, 16 Jul 2014 18:25:41 +0000 (19:25 +0100)] 
gdb.trace/tfile.c: Remove Thumb bit in one more more, general cleanup

I noticed that the existing code casts a function's address to 'long',
but that doesn't work correctly on some ABIs, like Win64, where long
is 32-bit and while pointers are 64-bit:

  func_addr = (long) &write_basic_trace_file;

Fixing that showed there's actually another place in the file that
writes a function address to file, and therefore should clear the
Thumb bit.  This commit adds a macro+function pair to centralize the
Thumb bit handling, and uses it in both places.

The rest is just enough changes to make the file build without
warnings with "-Wall -Wextra" with x86_64-w64-mingw32-gcc and
i686-w64-mingw32-gcc cross compilers, and with -m32/-m64 on x86_64
GNU/Linux.  Currently with x86_64-w64-mingw32-gcc we get:

  $ x86_64-w64-mingw32-gcc tfile.c  -Wall -DTFILE_DIR=\"\"
  tfile.c: In function 'start_trace_file':
  tfile.c:51:23: error: 'S_IRGRP' undeclared (first use in this function)
 S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
 ^
  tfile.c:51:23: note: each undeclared identifier is reported only once for each function it appears in
  tfile.c:51:31: error: 'S_IROTH' undeclared (first use in this function)
 S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
 ^
  tfile.c: In function 'add_memory_block':
  tfile.c:79:10: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
     ll_x = (unsigned long) addr;
    ^
  tfile.c: In function 'write_basic_trace_file':
  tfile.c:113:15: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
     func_addr = (long) &write_basic_trace_file;
 ^
  tfile.c:137:3: warning: passing argument 1 of 'add_memory_block' from incompatible pointer type [enabled by default]
     add_memory_block (&testglob, sizeof (testglob));
     ^
  tfile.c:72:1: note: expected 'char *' but argument is of type 'int *'
   add_memory_block (char *addr, int size)
   ^
  tfile.c:139:3: warning: passing argument 1 of 'add_memory_block' from incompatible pointer type [enabled by default]
     add_memory_block (&testglob2, 1);
     ^
  tfile.c:72:1: note: expected 'char *' but argument is of type 'int *'
   add_memory_block (char *addr, int size)
   ^
  tfile.c: In function 'write_error_trace_file':
  tfile.c:185:3: warning: implicit declaration of function 'alloca' [-Wimplicit-function-declaration]
     char *hex = alloca (len * 2 + 1);
     ^
  tfile.c:185:15: warning: incompatible implicit declaration of built-in function 'alloca' [enabled by default]
     char *hex = alloca (len * 2 + 1);
 ^
  tfile.c:211:6: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
(long) &write_basic_trace_file);
      ^

Tested on x86_64 Fedora 20, -m64 and -m32.
Tested by Yao on arm targets.

gdb/testsuite/
2014-07-16  Pedro Alves  <palves@redhat.com>

* gdb.trace/tfile.c: Include unistd.h and stdint.h.
(start_trace_file): Guard S_IRGRP and S_IROTH uses behind #ifdef.
(tfile_write_64, tfile_write_16, tfile_write_8, tfile_write_addr)
(tfile_write_buf): New functions.
(add_memory_block): Rewrite using the above.
(adjust_function_address): New function.
(FUNCTION_ADDRESS): New macro.
(write_basic_trace_file): Remove short_x local, and use
tfile_write_16. Change type of func_addr local to unsigned long
long.  Use FUNCTION_ADDRESS instead of handling the Thumb bit
here.  Cast argument of add_memory_block to char pointer.
(write_error_trace_file): Avoid alloca.  Use FUNCTION_ADDRESS.
(main): Remove parameters.
* gdb.trace/tfile.exp: Remove nowarnings.

9 years agoMatch PLT entry only for ELFOSABI_GNU input
H.J. Lu [Wed, 16 Jul 2014 18:15:56 +0000 (11:15 -0700)] 
Match PLT entry only for ELFOSABI_GNU input

* elf32-i386.c (elf_i386_plt_sym_val): Match PLT entry only for
ELFOSABI_GNU input.
* elf64-x86-64.c (elf_x86_64_plt_sym_val): Likewise.
(elf_x86_64_plt_sym_val_offset_plt_bnd): Likewise.

9 years agoProperly match PLT entry against .got.plt relocation
H.J. Lu [Wed, 16 Jul 2014 15:16:24 +0000 (08:16 -0700)] 
Properly match PLT entry against .got.plt relocation

Relocations against .got.plt section may not be in the same order as
entries in PLT section.  It is incorrect to assume that the Ith reloction
index against .got.plt section always maps to the (I + 1)th entry in PLT
section.  This patch matches the .got.plt relocation offset/index in PLT
entry against the index in .got.plt relocation table.  It only checks
R_*_JUMP_SLOT and R_*_IRELATIVE relocations.  It ignores R_*_TLS_DESC
and R_*_TLSDESC relocations since they have different PLT entries.

bfd/

PR binutils/17154
* elf32-i386.c (elf_i386_plt_sym_val): Only match R_*_JUMP_SLOT
and R_*_IRELATIVE relocation offset with PLT entry.
* elf64-x86-64.c (elf_x86_64_plt_sym_val): Likewise.
(elf_x86_64_plt_sym_val_offset_plt_bnd): New.
(elf_x86_64_get_synthetic_symtab): Use it.

ld/testsuite/

PR binutils/17154
* ld-ifunc/pr17154-i386.d: New file.
* ld-ifunc/pr17154-x86-64.d: Likewise.
* ld-ifunc/pr17154-x86.s: Likewise.
* ld-x86-64/bnd-ifunc-2.d: Likewise.
* ld-x86-64/bnd-ifunc-2.s: Likewise.
* ld-x86-64/mpx.exp: Run bnd-ifunc-2.
* ld-x86-64/tlsdesc-nacl.pd: Updated.
* ld-x86-64/tlsdesc.pd: Likewise.

9 years agoAdd test for string evaluation with "debug expression" on
Simon Marchi [Tue, 15 Jul 2014 17:04:31 +0000 (13:04 -0400)] 
Add test for string evaluation with "debug expression" on

As Joel pointed out in...
https://sourceware.org/ml/gdb-patches/2014-07/msg00391.html
...it would be nice to add a test for that.

Tested on Linux x86_64 (Ubuntu 14.10).

gdb/testsuite/ChangeLog

2014-07-15  Simon Marchi  <simon.marchi@ericsson.com>

* gdb.base/debug-expr.exp: Test string evaluation with
"debug expression" on.

9 years agoreformat comment in target.h
Tom Tromey [Wed, 16 Jul 2014 14:09:27 +0000 (08:09 -0600)] 
reformat comment in target.h

A comment in target.h went past the column limit.  This patch
reformats it.  I'm pushing this as obvious.

2014-07-16  Tom Tromey  <tromey@redhat.com>

* target.h (struct target_ops) <to_delete_record>: Reformat
comment.

9 years agorebuild target-delegates.c
Tom Tromey [Wed, 16 Jul 2014 14:05:03 +0000 (08:05 -0600)] 
rebuild target-delegates.c

target-delegates.c was out of date.  This patch rebuilds it.
Built and regtested on x86-64 Fedora 20.
Committed as obvious.

2014-07-16  Tom Tromey  <tromey@redhat.com>

* target-delegates.c: Rebuild.

9 years agodaily update
Alan Modra [Wed, 16 Jul 2014 00:00:55 +0000 (09:30 +0930)] 
daily update

9 years agoUpdate elf_i386_compute_jump_table_size
H.J. Lu [Tue, 15 Jul 2014 20:09:55 +0000 (13:09 -0700)] 
Update elf_i386_compute_jump_table_size

Commit e1f987424b7b3f5ac63a2a6ae044a202a44b8ff8 changed how
next_tls_desc_index was set up.  This patch updates
elf_i386_compute_jump_table_size to use elf.srelplt->reloc_count
instead of next_tls_desc_index.

bfd/

PR ld/17057
* elf32-i386.c (elf_i386_compute_jump_table_size): Replace
next_tls_desc_index with elf.srelplt->reloc_count.

ld/testsuite/

PR ld/17057
* ld-i386/i386.exp: Run pr17057.
* ld-i386/pr17057.d: New file.
* ld-i386/pr17057.s: Likewise.

9 years agogdb.base/reread.exp: Really restart GDB
Pedro Alves [Tue, 15 Jul 2014 16:30:34 +0000 (17:30 +0100)] 
gdb.base/reread.exp: Really restart GDB

The other day I noticed that default_gdb_start reuses the GDB process
if it has been spawned already:

proc default_gdb_start { } {
...
    if [info exists gdb_spawn_id] {
return 0
    }

I was a bit surprised, and so I hacked in an error to check whether
anything is relying on it:

 + if [info exists gdb_spawn_id] {
 +    error "GDB already spawned"
 + }

And lo, that tripped on a funny buglet (see below).  The comment in
reread.exp says "Restart GDB entirely", but in reality, due to the
above, that's not what is happening, as a gdb_exit call is missing.
The test is proceeding with the previous GDB process...

I don't really want to go hunt for whether there's an odd setup out
there that assumes this in its board file or something, so for now,
I'm taking the simple route of just making the test do what it says it
does.  I think this much makes it an obvious fix.

 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 (gdb) PASS: gdb.base/reread.exp: run to foo() second time
 ERROR: tcl error sourcing ../src/gdb/testsuite/gdb.base/reread.exp.
 ERROR: GDB already spawned
     while executing
 "error "GDB already spawned""
     invoked from within
 "if [info exists gdb_spawn_id] {
 error "GDB already spawned"
     }"
     (procedure "default_gdb_start" line 22)
     invoked from within
 "default_gdb_start"
     (procedure "gdb_start" line 2)
     invoked from within
 "gdb_start"
     invoked from within
 "if [is_remote target] {
     unsupported "second pass: GDB should check for changes before running"
 } else {

     # Put the older executable back in pl..."
     (file "../src/gdb/testsuite/gdb.base/reread.exp" line 114)
     invoked from within
 "source ../src/gdb/testsuite/gdb.base/reread.exp"
     ("uplevel" body line 1)
     invoked from within
 "uplevel #0 source ../src/gdb/testsuite/gdb.base/reread.exp"
     invoked from within
 "catch "uplevel #0 source $test_file_name""
 testcase ../src/gdb/testsuite/gdb.base/reread.exp completed in 1 seconds
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

gdb/testsuite/
2014-07-15  Pedro Alves  <palves@redhat.com>

* gdb.base/reread.exp: Use clean_restart.

9 years agoAdd support for the __flash qualifier on AVR
Pierre Langlois [Tue, 15 Jul 2014 16:03:09 +0000 (17:03 +0100)] 
Add support for the __flash qualifier on AVR

The __flash qualifier is part of the named address spaces for AVR [1]. It
allows putting read-only data in the flash memory, normally reserved for
code.

When used together with a pointer, the DW_AT_address_class attribute is set
to 1 and allows GDB to detect that when it will be dereferenced, the data
will be loaded from the flash memory (with the LPM instruction).

We can now properly debug the following code:

~~~
const __flash char data_in_flash = 0xab;

int
main (void)
{
  const __flash char *pointer_to_flash = &data_in_flash;
}
~~~

~~~
(gdb) print pointer_to_flash
$1 = 0x1e8 <data_in_flash> "\253"
(gdb) print/x *pointer_to_flash
$2 = 0xab
(gdb) x/x pointer_to_flash
0x1e8 <data_in_flash>: 0xXXXXXXab
~~~

Whereas previously, GDB would revert to the default address space which is
RAM and mapped in higher memory:

~~~
(gdb) print pointer_to_flash
$1 = 0x8001e8 ""
~~~

[1] https://gcc.gnu.org/onlinedocs/gcc/Named-Address-Spaces.html

2014-07-15  Pierre Langlois  <pierre.langlois@embecosm.com>

gdb/
* avr-tdep.c (AVR_TYPE_ADDRESS_CLASS_FLASH): New macro.
(AVR_TYPE_INSTANCE_FLAG_ADDRESS_CLASS_FLASH): Likewise.
(avr_address_to_pointer): Check for AVR_TYPE_ADDRESS_CLASS_FLASH.
(avr_pointer_to_address): Likewise.
(avr_address_class_type_flags): New function.
(avr_address_class_type_flags_to_name): Likewise.
(avr_address_class_name_to_type_flags): Likewise.
(avr_gdbarch_init): Set address_class_type_flags,
address_class_type_flags_to_name and
address_class_name_to_type_flags.

gdb/testsuite/
* gdb.arch/avr-flash-qualifer.c: New.
* gdb.arch/avr-flash-qualifer.exp: New.

9 years ago[GDB/Linux] Avoid stale errno
Pedro Alves [Tue, 15 Jul 2014 15:22:14 +0000 (16:22 +0100)] 
[GDB/Linux] Avoid stale errno

The fix that went into GDBserver is also needed on the GDB side.

Although most compilers follow right-to-left evaluation order, the
order of evaluation of a function call's arguments is really
unspecified.  target_pid_to_str may well clobber errno when we get to
evaluate the third argument to fprintf_unfiltered.

gdb/
2014-07-15  Pedro Alves  <palves@redhat.com>

* linux-nat.c (kill_callback): Save errno and work with saved
copy.

9 years agoHandle OP_STRING in dump_subexp_body_standard
Simon Marchi [Thu, 19 Jun 2014 14:45:33 +0000 (10:45 -0400)] 
Handle OP_STRING in dump_subexp_body_standard

For some reason, OP_STRING is not handled in dump_subexp_body_standard.
This makes the output of "set debug expression 1" very bad when a string
is involved. Example:

(gdb) set debug expression 1
(gdb) print "hello"
... (random garbage, possibly segfault)

This commit handles OP_STRING and skips the appropriate number of exp
elements. The line corresponding to the string now looks like:

    0  OP_STRING             Language-specific string type: 0

gdb/ChangeLog:

2014-07-15  Simon Marchi  <simon.marchi@ericsson.com>

* expprint.c (dump_subexp_body_standard): Handle OP_STRING.

9 years ago[GDBserver] Avoid stale errno
Pedro Alves [Tue, 15 Jul 2014 14:35:28 +0000 (15:35 +0100)] 
[GDBserver] Avoid stale errno

Although most compilers follow right-to-left evaluation order, the
order of evaluation of a function call's arguments is really
unspecified.  target_pid_to_str or ptid_of may well clobber errno when
we get to evaluate the third argument to debug_printf.

gdb/gdbserver/
2014-07-15  Pedro Alves  <palves@redhat.com>

* linux-low.c (linux_kill_one_lwp): Save errno and work with saved
copy.

9 years ago[ARM] Fix 32-bit host build failure.
Jiong Wang [Tue, 15 Jul 2014 09:15:43 +0000 (10:15 +0100)] 
[ARM] Fix 32-bit host build failure.

  gas/
    * config/tc-arm.c (add_to_lit_pool): Use "inst.operands[1].imm" for * sign
    extension.  Casting the type of imm1 and imm2 to offsetT.  Fix one logic
    error when checking X_op.

9 years ago[AArch64] Fix ld testcase linker script glitch.
Jiong Wang [Tue, 15 Jul 2014 09:08:55 +0000 (10:08 +0100)] 
[AArch64] Fix ld testcase linker script glitch.

  Specify -T relocs.ld for emit-relocs-local-addend.d to be consistent
  will all other emit-relocs* testcases

  ld/testsuite/
    * ld-aarch64/emit-relocs-local-addend.d: Use target linker script.

9 years agoDon't complain about dbCC to long branch conversion
Andreas Schwab [Mon, 14 Jul 2014 18:59:50 +0000 (20:59 +0200)] 
Don't complain about dbCC to long branch conversion

* config/tc-m68k.c (md_convert_frag_1): Don't complain with
--pcrel about TAB (DBCCLBR, LONG) conversion.

9 years agoAccount for trailing bytes read from bfd_bread
Alan Modra [Wed, 9 Jul 2014 10:34:40 +0000 (20:04 +0930)] 
Account for trailing bytes read from bfd_bread

* cache.c (cache_bread_1): Don't return -1 when fread returns
a positive value.

9 years agotidy elf_merge_st_other
Alan Modra [Wed, 9 Jul 2014 05:23:00 +0000 (14:53 +0930)] 
tidy elf_merge_st_other

So that we munge isym->st_other once per symbol.

* elflink.c (elf_merge_st_other): Update comments.  Simplify
visibility handling.  Make isym const.  Move code modifying
isym->st_other for --exclude-libs to..
(elf_link_add_object_symbols): ..here.

9 years agodaily update
Alan Modra [Tue, 15 Jul 2014 00:00:48 +0000 (09:30 +0930)] 
daily update

9 years ago2014-07-14 Edjunior Barbosa Machado <emachado@linux.vnet.ibm.com>
Edjunior Barbosa Machado [Mon, 14 Jul 2014 23:18:10 +0000 (20:18 -0300)] 
2014-07-14  Edjunior Barbosa Machado  <emachado@linux.vnet.ibm.com>

* ppc-linux-nat.c (ppc_linux_can_use_hw_breakpoint): Report no hardware
breakpoint support correctly.

9 years agoAdd missing ChangeLog entry for 15cd413a
Pedro Alves [Mon, 14 Jul 2014 19:39:53 +0000 (20:39 +0100)] 
Add missing ChangeLog entry for 15cd413a

Put GDB's terminal settings into effect when paginating
gdb/
2014-07-14  Pedro Alves  <palves@redhat.com>

* utils.c (prompt_for_continue): Call target_terminal_ours.

gdb/testsuite/
2014-07-14  Pedro Alves  <palves@redhat.com>

* gdb.base/paginate-after-ctrl-c-running.c: New file.
* gdb.base/paginate-after-ctrl-c-running.exp: New file.

9 years agoPut GDB's terminal settings into effect when paginating
Pedro Alves [Mon, 14 Jul 2014 18:55:32 +0000 (19:55 +0100)] 
Put GDB's terminal settings into effect when paginating

When the target is resumed in the foreground, we put the inferior's
terminal settings into effect, and remove stdin from the event loop.
When the target stops, we put GDB's terminal settings into effect
again, and re-register stdin in the event loop, ready for user input.
The former is done by target_terminal_inferior, and the latter by
target_terminal_ours.

There's an intermediate -- target_terminal_ours_for_output -- that is
called when printing output related to target events, and we don't
know yet whether we'll stop the program.  That puts our terminal
settings into effect, enough to get proper results from our output,
but leaves input wired into the inferior.

If such output paginates, then we need the full target_terminal_ours
in order for the user to be able to provide input to answer the
pagination query.

The test in this commit hangs in async-capable targets without the fix
(as the user/test can't answer the pagination query).  It doesn't hang
on sync targets because on those we don't unregister stdin from the
event loop while the target is running (because we block in
target_wait instead of in the event loop in that case).

gdb/
2014-07-14  Pedro Alves  <palves@redhat.com>

* utils.c (prompt_for_continue): Call target_terminal_ours.

gdb/testsuite/
2014-07-14  Pedro Alves  <palves@redhat.com>

* gdb.base/paginate-after-ctrl-c-running.c: New file.
  * gdb.base/paginate-after-ctrl-c-running.exp: New file.

9 years agoFix double prompt
Pedro Alves [Mon, 14 Jul 2014 18:55:32 +0000 (19:55 +0100)] 
Fix double prompt

If an error is thrown while handling a target event (within
fetch_inferior_event), and, the interpreter is not async (but the
target is), then GDB prints the prompt twice.

One way to see that in action is throw a QUIT while in a pagination
prompt issued from within fetch_inferior_event (or one of its
callees).  E.g. from the test:

 ---Type <return> to continue, or q <return> to quit---
 ^CQuit
 (gdb) (gdb) p 1
 ^^^^^^^^^^^
 $1 = 1
 (gdb)

The issue is that inferior_event_handler swallows errors and notifies
the observers (the interpreters) about the command error, even if the
interpreter is forced sync while we're handling a nested event loop
(for execute_command).  The observers print a prompt, and then when we
get back to the top event loop, we print another (in
start_event_loop).

I see no reason the error should be swallowed here.  Just cancel the
execution related bits and let the error propagate to the top level
(start_event_loop), which re-enables stdin and notifies observers.

gdb/
2014-07-14  Pedro Alves  <palves@redhat.com>

* inf-loop.c (inferior_event_handler): Use TRY_CATCH instead of
catch_errors.  Don't re-enable stdin or notify observers where,
and rethrow error.
(fetch_inferior_event_wrapper): Delete.

gdb/testsuite/
2014-07-14  Pedro Alves  <palves@redhat.com>

* gdb.base/double-prompt-target-event-error.c: New file.
* gdb.base/double-prompt-target-event-error.exp: New file.

9 years agoRemove the target from the event loop while in secondary prompts
Pedro Alves [Mon, 14 Jul 2014 18:55:32 +0000 (19:55 +0100)] 
Remove the target from the event loop while in secondary prompts

If a pagination prompt triggers while the target is running, and the
target exits before the user responded to the pagination query, this
happens:

  Starting program: foo
  ---Type <return> to continue, or q <return> to quit---No unwaited-for children left.
  Couldn't get registers: No such process.
  Couldn't get registers: No such process.
  Couldn't get registers: No such process.
  (gdb) Couldn't get registers: No such process.
  (gdb)

To reiterate, the user hasn't replied to the pagination prompt above.

A pagination query nests an event loop (in gdb_readline_wrapper).  In
async mode, in addition to stdin and signal handlers, we'll have the
target also installed in the event loop still.  So if the target
reports an event, that wakes up the nested event loop, which calls
into fetch_inferior_event etc. to handle the event which generates
further output, all while we should be waiting for pagination
confirmation...

(TBC, any target event that generates output ends up spuriously waking
up the pagination, though exits seem to be the worse kind.)

I've played with a couple different approaches to fixing this, while
at the same time trying to avoid being invasive.  Both revolve around
not listening to target events while in a pagination prompt (doing
anything else I think would be a much bigger change).

The approach taken just removes the target from the event loop while
within gdb_readline_wrapper.  The other approach used gdb_select
directly, with only input_fd installed, but that had the issue that it
didn't handle the async signal handlers, and turned out to be a bit
more code than the first version.

gdb/
2014-07-14  Pedro Alves  <palves@redhat.com>

PR gdb/17072
* top.c: Include "inf-loop.h".
(struct gdb_readline_wrapper_cleanup) <target_is_async_orig>: New
field.
(gdb_readline_wrapper_cleanup): Make the target async again, if it
was async before.
(gdb_readline_wrapper): Store whether the target is async, and
make it sync.

gdb/testsuite/
2014-07-14  Pedro Alves  <palves@redhat.com>

PR gdb/17072
* gdb.base/paginate-inferior-exit.c: New file.
* gdb.base/paginate-inferior-exit.exp: New file.

9 years agoBackground execution + pagination aborts readline/gdb
Pedro Alves [Mon, 14 Jul 2014 18:55:32 +0000 (19:55 +0100)] 
Background execution + pagination aborts readline/gdb

If pagination occurs as result of output sent as response to a target
event while the target is executing in the background, subsequent
input aborts readline/gdb:

 $ gdb program
 ...
 (gdb) continue&
 Continuing.
 (gdb)
 ---Type <return> to continue, or q <return> to quit---
 *return*
 ---Type <return> to continue, or q <return> to quit---
 Breakpoint 2, after_sleep () at paginate-bg-execution.c:21
 ---Type <return> to continue, or q <return> to quit---
 21        return; /* after sleep */
 p 1
 readline: readline_callback_read_char() called with no handler!
 *abort/SIGABRT*
 $

gdb_readline_wrapper_line removes the handler after a line is
processed.  Usually, we'll end up re-displaying the prompt, and that
reinstalls the handler.  But if the output is coming out of handling
a stop event, we don't re-display the prompt, and nothing restores the
handler.  So the next input wakes up the event loop and calls into
readline, which aborts.

We should do better with the prompt handling while the target is
running (I think we should coordinate with readline, and
hide/redisplay it around output), but that's a more invasive change
better done post 7.8, so this patch is conservative and just
reinstalls the handler as soon as we're out of the readline line
callback.

gdb/
2014-07-14  Pedro Alves  <palves@redhat.com>

PR gdb/17072
* top.c (gdb_readline_wrapper_line): Tweak comment.
(gdb_readline_wrapper_cleanup): If readline is enabled, reinstall
the input handler callback.

gdb/testsuite/
2014-07-14  Pedro Alves  <palves@redhat.com>

PR gdb/17072
* gdb.base/paginate-bg-execution.c: New file.
* gdb.base/paginate-bg-execution.exp: New file.

9 years agoCanceling pagination caused by execution command from command line aborts readline/gdb
Pedro Alves [Mon, 14 Jul 2014 18:55:31 +0000 (19:55 +0100)] 
Canceling pagination caused by execution command from command line aborts readline/gdb

This fixes:

 $ ./gdb program -ex "set height 2" -ex "start"
 ...
 Reading symbols from /home/pedro/gdb/tests/threads...done.
 ---Type <return> to continue, or q <return> to quit---^CQuit  << ctrl-c triggers a Quit

 *type something*
 readline: readline_callback_read_char() called with no handler!
 Aborted
 $

Usually, if an error propagates all the way to the top level, we'll
re-enable stdin, in case the command that was running was a
synchronous command.  That's done in the event loop's actual loop
(event-loop.c:start_event_loop).  However, if a foreground execution
command is run before the event loop starts and throws, nothing is
presently reenabling stdin, which leaves sync_execution set.

When we do start the event loop, because sync_execution is still
(mistakenly) set, display_gdb_prompt removes the readline input
callback, even though stdin is registered in the event loop.  Any
input from here on results in readline aborting.

Such commands are run through catch_command_errors,
catch_command_errors_const, so add the tweak there.

gdb/
2014-07-14  Pedro Alves  <palves@redhat.com>

PR gdb/17072
* main.c: Include event-top.h.
(handle_command_errors): New function.
(catch_command_errors, catch_command_errors_const): Use it.

gdb/testsuite/
2014-07-14  Pedro Alves  <palves@redhat.com>

PR gdb/17072
* gdb.base/paginate-execution-startup.c: New file.
* gdb.base/paginate-execution-startup.exp: New file.
* lib/gdb.exp (pagination_prompt): New global.
(default_gdb_spawn): New procedure, factored out from
default_gdb_spawn.
(default_gdb_start): Adjust to call default_gdb_spawn.
(gdb_spawn): New procedure.

9 years agotestsuite: Introduce gdb_assert
Pedro Alves [Mon, 14 Jul 2014 18:55:31 +0000 (19:55 +0100)] 
testsuite: Introduce gdb_assert

Often we'll do something like:

    if {$ok} {
fail "whatever"
    } else {
pass "whatever"
    }

This adds a helper procedure for that, and converts one random place
to use it, as an example.

2014-07-14  Pedro Alves  <palves@redhat.com>

* lib/gdb.exp (gdb_assert): New procedure.
* gdb.trace/backtrace.exp (gdb_backtrace_tdp_4): Use it.

9 years agoMove catch_command_errors and catch_command_errors_const to main.c
Pedro Alves [Mon, 14 Jul 2014 18:55:31 +0000 (19:55 +0100)] 
Move catch_command_errors and catch_command_errors_const to main.c

We'll need to add error handling code to commands run before the event
loop starts (commands in .gdbinit, -ex commands, etc.).  Turns out
those are run through catch_command_errors, and, catch_command_errors
is used nowhere else.  Move it (and the _const variant) to main.c, so
that we can further specialize it freely.

gdb/
2014-07-14  Pedro Alves  <palves@redhat.com>

* exceptions.c (catch_command_errors, catch_command_errors_const):
Moved to main.c.
* exceptions.h (catch_command_errors_ftype)
(catch_command_errors_const_ftype): Moved to main.c.
(catch_command_errors, catch_command_errors_const): Delete
declarations.
* main.c (catch_command_errors_ftype)
(catch_command_errors_const_ftype): Moved here from exceptions.h.
(catch_command_errors, catch_command_errors_const)): Moved here
from exceptions.c and make static.

9 years agoEliminate exceptions.c:print_any_exception.
Pedro Alves [Mon, 14 Jul 2014 18:55:30 +0000 (19:55 +0100)] 
Eliminate exceptions.c:print_any_exception.

exception_print and exception_fprintf call print_flush, which does all the
same flushing and annotation things that print_any_exception does, and more.

gdb/
2014-07-14  Pedro Alves  <palves@redhat.com>

* exceptions.c (print_any_exception): Delete.
(catch_exceptions_with_msg): Use exception_print instead of
print_any_exception.
(catch_errors): Use exception_fprintf instead of
print_any_exception.
(catch_command_errors, catch_command_errors_const): Use
exception_print instead of print_any_exception.

9 years agoPut the inferior's terminal settings in effect while running (fg) infcalls
Pedro Alves [Mon, 14 Jul 2014 18:55:30 +0000 (19:55 +0100)] 
Put the inferior's terminal settings in effect while running (fg) infcalls

The "call" and "print" commands presently always run synchronously, in
the foreground, but GDB currently forgets to put the inferior's
terminal settings into effect while running them, on async-capable
targets, resulting in:

 (gdb) print func ()
 hello world

 Program received signal SIGTTOU, Stopped (tty output).
 0x000000373bceb8d0 in __libc_tcdrain (fd=1) at ../sysdeps/unix/sysv/linux/tcdrain.c:29
 29          return INLINE_SYSCALL (ioctl, 3, fd, TCSBRK, 1);
 The program being debugged was signaled while in a function called from GDB.
 GDB remains in the frame where the signal was received.
 To change this behavior use "set unwindonsignal on".
 Evaluation of the expression containing the function
 (func) will be abandoned.
 When the function is done executing, GDB will silently stop.
 (gdb)

That's because target_terminal_inferior skips actually doing anything
if running in the background, and, nothing is setting sync_execution
while running infcalls:

 void
 target_terminal_inferior (void)
 {
   /* A background resume (``run&'') should leave GDB in control of the
      terminal.  Use target_can_async_p, not target_is_async_p, since at
      this point the target is not async yet.  However, if sync_execution
      is not set, we know it will become async prior to resume.  */
   if (target_can_async_p () && !sync_execution)
     return;

This would best be all cleaned up by making GDB not even call
target_terminal_inferior and try to pass the terminal to the inferior
if running in the background, but that's a more invasive fix that is
better done post-7.8.

This was originally caught by a patch later in this series that makes
catch_command_errors use exception_print instead of
print_any_exception.  Note that print_flush calls serial_drain_output
while print_any_exception doesnt't have that bit.  And,
gdb.gdb/python-selftest.exp does:

 gdb_test "call catch_command_errors(execute_command, \"python print 5\", 0, RETURN_MASK_ALL)" \
   "Python not initialized.* = 0"

which without this fix results in SIGTTOU...

gdb/
2014-07-14  Pedro Alves  <palves@redhat.com>

* infcall.c (run_inferior_call): Set 'sync_execution' while
running the inferior call.

gdb/testsuite/
2014-07-14  Pedro Alves  <palves@redhat.com>

* gdb.base/execution-termios.c: New file.
* gdb.base/execution-termios.exp: New file.

9 years agoGarbage collect value_contents_equal.
Pedro Alves [Mon, 14 Jul 2014 17:48:09 +0000 (18:48 +0100)] 
Garbage collect value_contents_equal.

Hasn't been used in years.

gdb/
2014-07-14  Pedro Alves  <palves@redhat.com>

* value.c (value_contents_equal): Delete function.
* value.h (value_contents_equal): Delete declaration.

9 years agofix PR 17106
Tom Tromey [Wed, 2 Jul 2014 21:53:31 +0000 (15:53 -0600)] 
fix PR 17106

This fixes PR 17106, a regression in printing.

The bug is that resolve_dynamic_type follows struct members and
references, but doesn't consider the possibility of infinite
recursion.

This patch fixes the problem by limiting reference following to the
topmost layer of calls -- that is, reference-typed struct members are
never considered as being VLAs.

Built and regtested on x86-64 Fedora 20.
New test case included.

2014-07-14  Tom Tromey  <tromey@redhat.com>

PR exp/17106:
* gdbtypes.c (is_dynamic_type_internal): New function, from
is_dynamic_type.
(is_dynamic_type): Rewrite.
(resolve_dynamic_union): Use resolve_dynamic_type_internal.
(resolve_dynamic_struct): Likewise.
(resolve_dynamic_type_internal): New function, from
resolve_dynamic_type.
(resolve_dynamic_type): Rewrite.

2014-07-14  Tom Tromey  <tromey@redhat.com>

* gdb.cp/vla-cxx.cc: New file.
* gdb.cp/vla-cxx.exp: New file.

9 years agofix record "run" regression
Tom Tromey [Tue, 1 Jul 2014 17:43:00 +0000 (11:43 -0600)] 
fix record "run" regression

This fixes the record "run" regression pointed out by Marc Khouzam:

    https://sourceware.org/ml/gdb/2014-06/msg00096.html

The bug is that target_require_runnable must agree with the handling
of the "run" target, but currently it is out of sync.  This patch
fixes the problem by changing target_require_runnable to also ignore
the record_stratum.

Built and regtested on x86-64 Fedora 20.
New test case included.

2014-07-14  Tom Tromey  <tromey@redhat.com>

* target.c (target_require_runnable): Also check record_stratum.
Update comment.

2014-07-14  Tom Tromey  <tromey@redhat.com>

* gdb.reverse/rerun-prec.c: New file.
* gdb.reverse/rerun-prec.exp: New file.

9 years agodaily update
Alan Modra [Mon, 14 Jul 2014 00:00:59 +0000 (09:30 +0930)] 
daily update

9 years agodaily update
Alan Modra [Sun, 13 Jul 2014 00:00:58 +0000 (09:30 +0930)] 
daily update

9 years agoDon't force "set" symbols local for PE
Alan Modra [Sat, 12 Jul 2014 07:35:35 +0000 (17:05 +0930)] 
Don't force "set" symbols local for PE

gas/
* read.c (assign_symbol): Don't force "set" symbols local for PE.
gas/testsuite/
* gas/pe/set.s, * gas/pe/set.d: New test.
* gas/pe/pe.exp: Run it.

9 years agogdb/testsuite: Add a way to send multiple init commands
Maciej W. Rozycki [Sat, 12 Jul 2014 00:22:25 +0000 (01:22 +0100)] 
gdb/testsuite: Add a way to send multiple init commands

Right now we provide a board info entry, `gdb_init_command', that allows
one to send a single command to GDB before the program to be debugged is
started.  This is useful e.g. for slow remote targets to change the
default "remotetimeout" setting.  Occasionally I found a need to send
multiple commands instead, however this cannot be achieved with
`gdb_init_command'.

This change therefore extends the mechanism by adding a TCL list of GDB
commands to send, via a board info entry called `gdb_init_commands'.
There is no limit as to the number of commands put there.  The old
`gdb_init_command' mechanism remains supported for compatibility with
existing people's environments.

* lib/gdb-utils.exp: New file.
* lib/gdb.exp (gdb_run_cmd): Call gdb_init_commands, replacing
inline `gdb_init_command' processing.
(gdb_start_cmd): Likewise.
* lib/mi-support.exp (mi_run_cmd): Likewise.
* README: Document `gdb_init_command' and `gdb_init_commands'.

9 years agodaily update
Alan Modra [Sat, 12 Jul 2014 00:01:38 +0000 (09:31 +0930)] 
daily update

9 years agoFix false argv0-symlink.exp FAIL running under a very long directory name
Jan Kratochvil [Fri, 11 Jul 2014 15:26:42 +0000 (17:26 +0200)] 
Fix false argv0-symlink.exp FAIL running under a very long directory name

Starting program: /home/jkratoch/redhat/gdb-test-fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff/gdb/testsuite/gdb.base/argv0-symlink-filelink ^M
[...]
(gdb) print argv[0]^M
$1 = 0x7fffffffda39 "/home/jkratoch/redhat/gdb-test-", 'f' <repeats 169 times>...^M
(gdb) FAIL: gdb.base/argv0-symlink.exp: kept file symbolic link name

after "set print repeats 10000":

print argv[0]^M
$1 = 0x7fffffffda39 "/home/jkratoch/redhat/gdb-test-fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"...^M
(gdb) FAIL: gdb.base/argv0-symlink.exp: kept file symbolic link name

after "set print elements 10000":

print argv[0]^M
$1 = 0x7fffffffda39 "/home/jkratoch/redhat/gdb-test-fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff/gdb/testsuite/gdb.base/argv0-symlink-filelink"^M
(gdb) PASS: gdb.base/argv0-symlink.exp: kept file symbolic link name

gdb/testsuite/
2014-07-11  Jan Kratochvil  <jan.kratochvil@redhat.com>

Fix false FAIL running under a very long directory name.
* gdb.base/argv0-symlink.exp: Add "set print repeats 10000"
and "set print elements 10000".  Twice.

9 years agoFix typo in _bfd_elf_strtab_add
Maks Naumov [Fri, 11 Jul 2014 14:25:30 +0000 (23:55 +0930)] 
Fix typo in _bfd_elf_strtab_add

PR 17141
* elf.c (_bfd_elf_strtab_add): Check strtab name for failure.

9 years agoStop prologue analysis when past the epilogue
Yao Qi [Wed, 2 Jul 2014 07:16:26 +0000 (15:16 +0800)] 
Stop prologue analysis when past the epilogue

We see a fail in gdb.trace/entry-values.exp on armv4t thumb,

bt^M
 #0  0x000086fc in foo (i=0, i@entry=<optimized out>, j=2, j@entry=<optimized out>)^M
 #1  0x00000002 in ?? ()^M
Backtrace stopped: previous frame identical to this frame (corrupt stack?)^M
(gdb) FAIL: gdb.trace/entry-values.exp: bt (1) (pattern 1)

The fail is caused by incorrect prologue analysis, which can be illustrated by
setting a breakpoint on function foo,

(gdb) disassemble foo
Dump of assembler code for function foo:
   0x000086e8 <+0>: push {r7, lr}
   0x000086ea <+2>: sub sp, #8
   0x000086ec <+4>: add r7, sp, #0
   0x000086ee <+6>: str r0, [r7, #4]
   0x000086f0 <+8>: str r1, [r7, #0]
   0x000086f2 <+10>: movs r3, #0
   0x000086f4 <+12>: adds r0, r3, #0
   0x000086f6 <+14>: mov sp, r7
   0x000086f8 <+16>: add sp, #8
   0x000086fa <+18>: pop {r7}
   0x000086fc <+20>: pop {r1}
   0x000086fe <+22>: bx r1
End of assembler dump.
(gdb) b foo
Breakpoint 1 at 0x86fc

As we can see, GDB analyzes the prologue and skip the prologue to the last
instruction but one.  The breakpoint is set within the epilogue, and GDB
skips too many instruction for prologue.  This patch teaches GDB to stop
prologue analysis when goes into the epilogue.  With this patch applied,
GDB is able to unwind correctly,

(gdb) bt
 #0  0x000086f6 in foo (i=0, i@entry=2, j=2, j@entry=3)
 #1  0x00008718 in bar (i=<optimized out>)
 #2  0x00008758 in main ()

gdb:

2014-07-11  Yao Qi  <yao@codesourcery.com>

* arm-tdep.c (thumb_analyze_prologue): Break the loop if
thumb_instruction_restores_sp return true.

9 years agoMatch instruction adjusts SP in thumb
Yao Qi [Wed, 2 Jul 2014 06:45:12 +0000 (14:45 +0800)] 
Match instruction adjusts SP in thumb

This is a refactor patch, that moves matching instructions adjusting
SP into a new function, thumb_instruction_restores_sp.  The second
call to thumb_instruction_restores_sp in thumb_in_function_epilogue_p
is a little different from the original.  The original code matches
'POP <registers> without PC', but thumb_in_function_epilogue_p matches
'POP <registers> (with and without PC)'.  However, GDB found one
instruction about return and is scanning the previous instruction,
which should be an instruction about return too, so the code change
doesn't affect the functionality.

gdb:

2014-07-11  Yao Qi  <yao@codesourcery.com>

* arm-tdep.c (thumb_instruction_restores_sp): New function.
(thumb_in_function_epilogue_p): Call
thumb_instruction_restores_sp.

9 years agoRestrict matching add/sub sp, #imm
Yao Qi [Tue, 1 Jul 2014 07:36:44 +0000 (15:36 +0800)] 
Restrict matching add/sub sp, #imm

Currently, GDB matches both add/sub sp, #imm in prologue and epilogue,
which is not very precise.  On the instruction level, the immediate
number in both instruction can't be negative, so 'sub sp, #imm' only
appears in prologue while 'add sp, #imm' only appears in epilogue.
Note that on assembly level, we can write 'add sp, -8', but gas will
translate to 'sub sp, 8' instruction.

This patch is to only match 'sub sp, #imm' in prologue and match
'add sp, #immm' in epilogue.  It paves the way for the following
patch.

gdb:

2014-07-11  Yao Qi  <yao@codesourcery.com>

* arm-tdep.c (thumb_analyze_prologue): Don't match instruction
'add sp, #imm'.
(thumb_in_function_epilogue_p): Don't match 'sub sp, #imm'.

9 years agoTidy #include lists
Gary Benson [Fri, 27 Jun 2014 08:52:29 +0000 (09:52 +0100)] 
Tidy #include lists

This commit tidies up the #include lists in {i386,amd64}-linux-nat.c,
removing headers that are no longer required and reordering some lines
so that both files roughly match.  Additionally, an unused definition
was removed from the middle of the #include list in i386-linux-nat.c.

gdb/
2014-07-11  Gary Benson  <gbenson@redhat.com>

* amd64-linux-nat.c (gdbcore.h): Remove include.
(regset.h): Likewise.
(nat/linux-btrace.h): Likewise.
(btrace.h): Likewise.
(gdb_assert.h): Likewise.
(string.h): Likewise.
(sys/uio.h): Likewise.
(sys/debugreg.h): Likewise.
(sys/syscall.h): Likewise.
(sys/procfs.h): Likewise.
(sys/user.h): Likewise.
(asm/ptrace.h): Likewise.
(i386-nat.h): Likewise.
* i386-linux-nat.c (i386-nat.h): Likewise.
(regset.h): Likewise.
(target.h): Likewise.
(linux-nat.h): Likewise.
(nat/linux-btrace.h): Likewise.
(btrace.h): Likewise.
(gdb_assert.h): Likewise.
(string.h): Likewise.
(sys/uio.h): Likewise.
(sys/user.h): Likewise.
(sys/procfs.h): Likewise.
(sys/reg.h): Likewise.
(sys/debugreg.h): Likewise.
(ORIG_EAX): Remove definition.

9 years agoMove duplicated code into new files
Gary Benson [Thu, 10 Jul 2014 14:43:56 +0000 (15:43 +0100)] 
Move duplicated code into new files

This commit moves the duplicated code in {i386,amd64}-linux-nat.c
into the new files x86-linux-nat.[ch].  Additionally, a new
file i386-linux-nat.h was required to expose a value required
by the 32-bit code in x86-linux-nat.c.

gdb/
2014-07-11  Gary Benson  <gbenson@redhat.com>

* i386-linux-nat.h: New file.
* x86-linux-nat.h: Likewise.
* x86-linux-nat.c: Likewise.
* Makefile.in (HFILES_NO_SRCDIR): Add the above new headers.
* config/i386/linux.mh (NATDEPFILES): Add x86-linux-nat.o.
* config/i386/linux64.mh (NATDEPFILES): Likewise.
* amd64-linux-nat.c (x86-linux-nat.h): New include.
(PTRACE_GETREGSET): Now in x86-linux-nat.h.
(PTRACE_SETREGSET): Likewise.
(arch_lwp_info): Now in x86-linux-nat.c.
(have_ptrace_getregset): Now in x86-linux-nat.h.
(x86_linux_dr_get): Now in x86-linux-nat.c.
(x86_linux_dr_set): Likewise.
(x86_linux_dr_get_addr): Likewise.
(x86_linux_dr_get_control): Likewise.
(x86_linux_dr_get_status): Likewise.
(update_debug_registers_callback): Likewise.
(x86_linux_dr_set_control): Likewise.
(x86_linux_dr_set_addr): Likewise.
(x86_linux_prepare_to_resume): Likewise.
(x86_linux_new_thread): Likewise.
(x86_linux_new_fork): Likewise.
(x86_linux_get_thread_area): Likewise.
(super_post_startup_inferior): Likewise.
(x86_linux_child_post_startup_inferior): Likewise.
(AMD64_LINUX_USER64_CS): Likewise.
(AMD64_LINUX_X32_DS): Likewise.
(x86_linux_read_description): Likewise.
(x86_linux_enable_btrace): Likewise.
(x86_linux_disable_btrace): Likewise.
(x86_linux_teardown_btrace): Likewise.
(x86_linux_read_btrace): Likewise.
(x86_linux_create_target): Likewise.
(x86_linux_add_target): Likewise.
* i386-linux-nat.c (x86-linux-nat.h): New include.
(PTRACE_GETREGSET): Now in x86-linux-nat.h.
(PTRACE_SETREGSET): Likewise.
(arch_lwp_info): Now in x86-linux-nat.c.
(have_ptrace_getregset): Now in x86-linux-nat.h.
(x86_linux_dr_get): Now in x86-linux-nat.c.
(x86_linux_dr_set): Likewise.
(x86_linux_dr_get_addr): Likewise.
(x86_linux_dr_get_control): Likewise.
(x86_linux_dr_get_status): Likewise.
(update_debug_registers_callback): Likewise.
(x86_linux_dr_set_control): Likewise.
(x86_linux_dr_set_addr): Likewise.
(x86_linux_prepare_to_resume): Likewise.
(x86_linux_new_thread): Likewise.
(x86_linux_new_fork): Likewise.
(x86_linux_get_thread_area): Likewise.
(super_post_startup_inferior): Likewise.
(x86_linux_child_post_startup_inferior): Likewise.
(AMD64_LINUX_USER64_CS): Likewise.
(AMD64_LINUX_X32_DS): Likewise.
(x86_linux_read_description): Likewise.
(x86_linux_enable_btrace): Likewise.
(x86_linux_disable_btrace): Likewise.
(x86_linux_teardown_btrace): Likewise.
(x86_linux_read_btrace): Likewise.
(x86_linux_create_target): Likewise.
(x86_linux_add_target): Likewise.

9 years agoComment and whitespace changes
Gary Benson [Wed, 25 Jun 2014 13:57:42 +0000 (14:57 +0100)] 
Comment and whitespace changes

This commit merges the comments and whitespace in the common
parts of i386-linux-nat.c and amd64-linux-nat.c.

gdb/
2014-07-11  Gary Benson  <gbenson@redhat.com>

* amd64-linux-nat.c: Comment and whitespace changes.
* i386-linux-nat.c: Comment and whitespace changes.

9 years agoPull out common parts of _initialize_{i386,amd64}_linux_nat
Gary Benson [Tue, 24 Jun 2014 12:43:30 +0000 (13:43 +0100)] 
Pull out common parts of _initialize_{i386,amd64}_linux_nat

This commit adds two new helpers, x86_linux_create_target and
x86_linux_add_target, to hold the parts of _initialize_i386_linux_nat
and _initialize_amd64_linux_nat which are common.

gdb/
2014-07-11  Gary Benson  <gbenson@redhat.com>

* amd64-linux-nat.c (x86_linux_create_target): New function.
(x86_linux_add_target): Likewise.
(_initialize_amd64_linux_nat): Delegate to the above new functions.
* i386-linux-nat.c (x86_linux_create_target): New function.
(x86_linux_add_target): Likewise.
(_initialize_i386_linux_nat): Delegate to the above new functions.

9 years agoMerge ps_get_thread_area
Gary Benson [Wed, 25 Jun 2014 10:49:55 +0000 (11:49 +0100)] 
Merge ps_get_thread_area

This commit adds a new helper, x86_linux_get_thread_area, to
hold the common parts of the ps_get_thread_area functions in
i386-linux-nat.c and amd64-linux-nat.c.

gdb/
2014-07-11  Gary Benson  <gbenson@redhat.com>

* amd64-linux-nat.c (x86_linux_get_thread_area): New function.
(ps_get_thread_area): Delegate to the above in 32-bit mode.
* i386-linux-nat.c (x86_linux_get_thread_area): New function.
(ps_get_thread_area): Delegate to the above.

9 years agoMerge {i386,amd64}_linux_read_description
Gary Benson [Fri, 27 Jun 2014 08:29:06 +0000 (09:29 +0100)] 
Merge {i386,amd64}_linux_read_description

This commit merges i386_ and amd64_linux_read_description, renaming
both to x86_linux_read_description.

gdb/
2014-07-11  Gary Benson  <gbenson@redhat.com>

* amd64-linux-nat.c (amd64_linux_read_description): Renamed to
x86_linux_read_description.  All uses updated.  amd64-specific
code conditionalized.  Conditionalized i386-specific code added.
Redundant cast removed.
* i386-linux-nat.c (i386_linux_read_description): Renamed to
x86_linux_read_description.  All uses updated.  i386-specific
code conditionalized.  Conditionalized amd64-specific code added.
One sizeof replaced with the actual type it is describing.

9 years agoRename identical functions
Gary Benson [Tue, 24 Jun 2014 09:07:12 +0000 (10:07 +0100)] 
Rename identical functions

amd64-linux-nat.c and i386-linux-nat.c contain a number of functions
which are identical but for prefix on their names.  This commit
renames all such functions to have the prefix x86_ instead of the
prefixes amd64_ or i386_ and updates all uses of those functions.
The now-identical x86_ functions will be pulled out to a separate
shared file in a later commit.

gdb/
2014-07-11  Gary Benson  <gbenson@redhat.com>

* amd64-linux-nat.c (amd64_linux_dr_get): Renamed to
x86_linux_dr_get.  All uses updated.
(amd64_linux_dr_set): Renamed to
x86_linux_dr_set.  All uses updated.
(amd64_linux_dr_get_addr): Renamed to
x86_linux_dr_get_addr.  All uses updated.
(amd64_linux_dr_get_control): Renamed to
x86_linux_dr_get_control.  All uses updated.
(amd64_linux_dr_get_status): Renamed to
x86_linux_dr_get_status.  All uses updated.
(amd64_linux_dr_set_control): Renamed to
x86_linux_dr_set_control.  All uses updated.
(amd64_linux_dr_set_addr): Renamed to
x86_linux_dr_set_addr.  All uses updated.
(amd64_linux_prepare_to_resume): Renamed to
x86_linux_prepare_to_resume.  All uses updated.
(amd64_linux_new_thread): Renamed to
x86_linux_new_thread.  All uses updated.
(amd64_linux_new_fork): Renamed to
x86_linux_new_fork.  All uses updated.
(amd64_linux_child_post_startup_inferior): Renamed to
x86_linux_child_post_startup_inferior.  All uses updated.
(amd64_linux_enable_btrace): Renamed to
x86_linux_enable_btrace.  All uses updated.
(amd64_linux_disable_btrace): Renamed to
x86_linux_disable_btrace.  All uses updated.
(amd64_linux_teardown_btrace): Renamed to
x86_linux_teardown_btrace.  All uses updated.
(amd64_linux_read_btrace): Renamed to
x86_linux_read_btrace.  All uses updated.
* i386-linux-nat.c (i386_linux_dr_get): Renamed to
x86_linux_dr_get.  All uses updated.
(i386_linux_dr_set): Renamed to
x86_linux_dr_set.  All uses updated.
(i386_linux_dr_get_addr): Renamed to
x86_linux_dr_get_addr.  All uses updated.
(i386_linux_dr_get_control): Renamed to
x86_linux_dr_get_control.  All uses updated.
(i386_linux_dr_get_status): Renamed to
x86_linux_dr_get_status.  All uses updated.
(i386_linux_dr_set_control): Renamed to
x86_linux_dr_set_control.  All uses updated.
(i386_linux_dr_set_addr): Renamed to
x86_linux_dr_set_addr.  All uses updated.
(i386_linux_prepare_to_resume): Renamed to
x86_linux_prepare_to_resume.  All uses updated.
(i386_linux_new_thread): Renamed to
x86_linux_new_thread.  All uses updated.
(i386_linux_new_fork): Renamed to
x86_linux_new_fork.  All uses updated.
(i386_linux_child_post_startup_inferior): Renamed to
x86_linux_child_post_startup_inferior.  All uses updated.
(i386_linux_enable_btrace): Renamed to
x86_linux_enable_btrace.  All uses updated.
(i386_linux_disable_btrace): Renamed to
x86_linux_disable_btrace.  All uses updated.
(i386_linux_teardown_btrace): Renamed to
x86_linux_teardown_btrace.  All uses updated.
(i386_linux_read_btrace): Renamed to
x86_linux_read_btrace.  All uses updated.

9 years agoDon't print symbol on address 0x0
Yao Qi [Fri, 11 Jul 2014 10:46:33 +0000 (18:46 +0800)] 
Don't print symbol on address 0x0

We see the following fails on arm-none-eabi target,

print (void*)v_signed_char^M
$190 = (void *) 0x0 <_ftext>^M
(gdb) FAIL: gdb.base/exprs.exp: print (void*)v_signed_char (print
(void*)v_signed_char)

GDB behaves correctly but the test assumes there is no symbol on
address 0x0.  This patch is set print symbol off, so that tests below
can match the address only.

gdb/testsuite:

2014-07-11  Yao Qi  <yao@codesourcery.com>

* gdb.base/exprs.exp: "set print symbol off".

9 years agoGDBserver crashes when killing a multi-thread process
Pedro Alves [Fri, 11 Jul 2014 10:07:13 +0000 (11:07 +0100)] 
GDBserver crashes when killing a multi-thread process

Here's an example, with the new test:

 gdbserver :9999 gdb.threads/kill
 gdb gdb.threads/kill
 (gdb) b 52
 Breakpoint 1 at 0x4007f4: file kill.c, line 52.
 Continuing.

 Breakpoint 1, main () at kill.c:52
 52        return 0; /* set break here */
 (gdb) k
 Kill the program being debugged? (y or n) y

 gdbserver :9999 gdb.threads/kill
 Process gdb.base/watch_thread_num created; pid = 9719
 Listening on port 1234
 Remote debugging from host 127.0.0.1
 Killing all inferiors
 Segmentation fault (core dumped)

Backtrace:

 (gdb) bt
 #0  0x00000000004068a0 in find_inferior (list=0x66b060 <all_threads>, func=0x427637 <kill_one_lwp_callback>, arg=0x7fffffffd3fc) at src/gdb/gdbserver/inferiors.c:199
 #1  0x00000000004277b6 in linux_kill (pid=15708) at src/gdb/gdbserver/linux-low.c:966
 #2  0x000000000041354d in kill_inferior (pid=15708) at src/gdb/gdbserver/target.c:163
 #3  0x00000000004107e9 in kill_inferior_callback (entry=0x6704f0) at src/gdb/gdbserver/server.c:2934
 #4  0x0000000000406522 in for_each_inferior (list=0x66b050 <all_processes>, action=0x4107a6 <kill_inferior_callback>) at src/gdb/gdbserver/inferiors.c:57
 #5  0x0000000000412377 in process_serial_event () at src/gdb/gdbserver/server.c:3767
 #6  0x000000000041267c in handle_serial_event (err=0, client_data=0x0) at src/gdb/gdbserver/server.c:3880
 #7  0x00000000004189ff in handle_file_event (event_file_desc=4) at src/gdb/gdbserver/event-loop.c:434
 #8  0x00000000004181c6 in process_event () at src/gdb/gdbserver/event-loop.c:189
 #9  0x0000000000418f45 in start_event_loop () at src/gdb/gdbserver/event-loop.c:552
 #10 0x0000000000411272 in main (argc=3, argv=0x7fffffffd8d8) at src/gdb/gdbserver/server.c:3283

The problem is that linux_wait_for_event deletes lwps that have exited
(even those not passed in as lwps of interest), while the lwp/thread
list is being walked on with find_inferior.  find_inferior can handle
the current iterated inferior being deleted, but not others.

When killing lwps, we don't really care about any of the pending
status handling of linux_wait_for_event.  We can just waitpid the lwps
directly, which is also what GDB does (see
linux-nat.c:kill_wait_callback).  This way the lwps are not deleted
while we're walking the list.  They'll be deleted by linux_mourn
afterwards.

This crash triggers several times when running the testsuite against
GDBserver with the native-gdbserver board (target remote), but as GDB
can't distinguish between GDBserver crashing and "kill" being
sucessful, as in both cases the connection is closed (the 'k' packet
doesn't require a reply), and the inferior is gone, that results in no
FAIL.

The patch adds a generic test that catches the issue with
extended-remote mode (and works fine with native testing too).  Here's
how it fails with the native-extended-gdbserver board without the fix:

 (gdb) info threads
   Id   Target Id         Frame
   6    Thread 15367.15374 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81
   5    Thread 15367.15373 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81
   4    Thread 15367.15372 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81
   3    Thread 15367.15371 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81
   2    Thread 15367.15370 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81
 * 1    Thread 15367.15367 main () at .../gdb.threads/kill.c:52
 (gdb) kill
 Kill the program being debugged? (y or n) y
 Remote connection closed
 ^^^^^^^^^^^^^^^^^^^^^^^^
 (gdb) FAIL: gdb.threads/kill.exp: kill

Extended remote should remain connected after the kill.

gdb/gdbserver/
2014-07-11  Pedro Alves  <palves@redhat.com>

* linux-low.c (kill_wait_lwp): New function, based on
kill_one_lwp_callback, but use my_waitpid directly.
(kill_one_lwp_callback, linux_kill): Use it.

gdb/testsuite/
2014-07-11  Pedro Alves  <palves@redhat.com>

* gdb.threads/kill.c: New file.
* gdb.threads/kill.exp: New file.

9 years agoremote: call remote_check_symbols after attaching
Adrian Sendroiu [Fri, 11 Jul 2014 09:51:48 +0000 (10:51 +0100)] 
remote: call remote_check_symbols after attaching

When debugging a remote bare-metal target with "target
extended-remote" + attach, GDB won't send a qSymbol packet to initiate
symbol lookup.  This happens because all the previous places in which
GDB might have done this are guarded by conditions that don't hold in
the said scenario: there are no shared libraries, no vsyscall page and
the binary file didn't change in the time passed between the "file"
and the "attach" commands.

To solve this problem remote_check_symbols is called in the
target_post_attach hook.

gdb/
2014-07-11  Adrian Sendroiu  <adrian.sendroiu@freescale.com>

* remote.c (extended_remote_post_attach): New function.
(init_extended_remote_ops): Install it as to_post_attach method.

9 years agodaily update
Alan Modra [Fri, 11 Jul 2014 00:01:14 +0000 (09:31 +0930)] 
daily update

9 years agoRevert gdbthread.h (any_running): Declare.
Doug Evans [Thu, 10 Jul 2014 19:30:05 +0000 (12:30 -0700)] 
Revert gdbthread.h (any_running): Declare.
Not properly marked as 1/2.
This reverts commit 1a76d598884a052dacd8feb49f1999e1a0d537f1.

9 years ago * gdbthread.h (any_running): Declare.
Doug Evans [Thu, 10 Jul 2014 18:15:32 +0000 (11:15 -0700)] 
* gdbthread.h (any_running): Declare.
* thread.c (any_running): New function.

9 years agoFix xtensa ld segfault when linking linux modules
Max Filippov [Wed, 9 Jul 2014 21:47:33 +0000 (01:47 +0400)] 
Fix xtensa ld segfault when linking linux modules

is_inconsistent_linkonce_section makes an assumption that section name
that starts with ".gnu.linkonce.prop." has one more dot in its suffix.
However gas generates such section name by insertion of "prop." right
after ".gnu.linkonce." part of the name of the original section. So, for
section named ".gnu.linkonce.this_module" corresponding property section
name does not satisfy the assumption. Such section names are common in
linux modules. This bug was exposed by the patch "a35d5e8 Fix alignment
for the first section frag on xtensa", that makes gas produce property
section for each section that has ".align" directive in it.

Use suffix that immediately follows ".gnu.linkonce.prop." when there are
no more dots following it.

2014-07-10  Max Filippov  <jcmvbkbc@gmail.com>

ld/
    * emultempl/xtensaelf.em (is_inconsistent_linkonce_section):
    correctly handle missing dot in section name after
    ".gnu.linkonce.prop.".

9 years agogas/ARM: Fix testsuite failure for arm-elf
Will Newton [Tue, 8 Jul 2014 09:23:27 +0000 (10:23 +0100)] 
gas/ARM: Fix testsuite failure for arm-elf

At some point the arm-elf output became the same as arm-eabi. Remove
the special handling of arm-elf.

gas/testsuite/ChangeLog:

2014-07-10  Will Newton  <will.newton@linaro.org>

* gas/elf/elf.exp: Remove special handling of arm-elf for
section2 test.
* gas/elf/section2.e-armeabi: Rename to...
* gas/elf/section2.e-arm: ...here.
* gas/elf/section2.e-armelf: Remove file.

9 years agoFix tests when configured for arm-linux and arm-elf
Will Newton [Mon, 7 Jul 2014 16:33:34 +0000 (17:33 +0100)] 
Fix tests when configured for arm-linux and arm-elf

With this change all gas and most ld tests pass when configured for
arm-linux. It doesn't look like these configurations have been
tested in a long time but this attempts to stem the bit-rot slightly.

gas/testsuite/ChangeLog:

2014-07-10  Will Newton  <will.newton@linaro.org>

* gas/arm/bl-local-2.d: Only enable the test on EABI and
NaCl configurations.
* gas/arm/bl-local-v4t.d: Likewise.
* gas/arm/blx-local.d: Likewise.
* gas/arm/branch-reloc.d: Likewise.

ld/testsuite/ChangeLog:

2014-07-10  Will Newton  <will.newton@linaro.org>

* ld-arm/arm-elf.exp (armelftests_nonacl): Move Cortex-A8 fix
tests, IFUNC tests and other EABI requiring tests to...
(armeabitests_nonacl): ...here.
* ld-arm/arm-app-abs32.d: Loosen regex for architecture type
to allow test to pass on configurations without an attributes
section.
* ld-arm/arm-app.d: Likewise.
* ld-arm/arm-lib-plt32.d: Likewise.
* ld-arm/arm-lib.d: Likewise.
* ld-arm/arm-static-app.d: Likewise.
* ld-arm/armthumb-lib.d: Likewise.
* ld-arm/cortex-a8-far.d: Likewise.
* ld-arm/farcall-mixed-app.d: Likewise.
* ld-arm/farcall-mixed-lib-v4t.d: Likewise.
* ld-arm/farcall-mixed-lib.d: Likewise.
* ld-arm/mixed-app-v5.d: Likewise.
* ld-arm/mixed-app.d: Likewise.
* ld-arm/mixed-lib.d: Likewise.
* ld-arm/tls-app.d: Likewise.
* ld-arm/tls-descrelax-be32.d: Likewise.
* ld-arm/tls-descrelax.d: Likewise.
* ld-arm/tls-descseq.d: Likewise.
* ld-arm/tls-gdesc-got.d: Likewise.
* ld-arm/tls-gdesc.d: Likewise.
* ld-arm/tls-gdierelax.d: Likewise.
* ld-arm/tls-gdierelax2.d: Likewise.
* ld-arm/tls-gdlerelax.d: Likewise.
* ld-arm/tls-lib-loc.d: Likewise.
* ld-arm/tls-lib.d: Likewise.
* ld-arm/tls-thumb1.d: Likewise.

9 years agobinutils/testsuite: Disable strip-10 test on ARM non-EABI
Will Newton [Mon, 7 Jul 2014 16:26:48 +0000 (17:26 +0100)] 
binutils/testsuite: Disable strip-10 test on ARM non-EABI

Non-EABI ARM targets set OSABI to ARM regardless of whether or not GNU
features have been used which causes this test to fail.

binutils/testsuite/ChangeLog:

2014-07-10  Will Newton  <will.newton@linaro.org>

* binutils-all/objcopy.exp: Disable the strip-10 test on
non-EABI ARM configurations.

9 years agold/testsuite: Disable non-PIC shared library tests on ARM
Will Newton [Mon, 7 Jul 2014 16:30:58 +0000 (17:30 +0100)] 
ld/testsuite: Disable non-PIC shared library tests on ARM

ARM doesn't support non-PIC shared libraries so don't run those
tests.

ld/testsuite/ChangeLog:

2014-07-10  Will Newton  <will.newton@linaro.org>

* ld-elfvers/vers.exp: Set pic to yes for ARM targets.

9 years agoTweak gdb.trace/tfile.c for thumb mode
Yao Qi [Mon, 30 Jun 2014 03:47:51 +0000 (11:47 +0800)] 
Tweak gdb.trace/tfile.c for thumb mode

We see the fail below happens on thumb related multi-libs
(-mthumb -march={armv4t,armv7-a}),

target tfile tfile-basic.tf ^M
warning: Uploaded tracepoint 1 has no source location, using raw address^M
warning: Breakpoint address adjusted from 0x00008959 to 0x00008958.^M
Tracepoint 3 at 0x8958: file /scratch/yqi/arm-none-linux-gnueabi/src/gdb-trunk/gdb/testsuite/gdb.trace/tfile.c, line 91.^M
Created tracepoint 3 for target's tracepoint 1 at 0x8959.^M
warning: Breakpoint address adjusted from 0x00008959 to 0x00008958.^M
warning: Breakpoint address adjusted from 0x00008959 to 0x00008958.^M
warning: Breakpoint address adjusted from 0x00008959 to 0x00008958.^M
(gdb) FAIL: gdb.trace/tfile.exp: complete-command 'target tfile'

The address of write_basic_trace_file is two-bytes aligned,

(gdb) p write_basic_trace_file
$1 = {void (void)} 0x8958 <write_basic_trace_file>

but the ld sets the LSB of every reference to the function address
(indicating the address is in thumb mode), so "&write_basic_trace_file"
in the program becomes 0x8959, which is saved in the trace file.  That
is why the warnnings are emitted.

This patch is to clear the LSB of the function address written to trace
file in thumb and thumb2 mode.  This patch fixes the fail above.

gdb/testsuite:

2014-07-10  Yao Qi  <yao@codesourcery.com>

* gdb.trace/tfile.c (write_basic_trace_file)
[__thumb__||__thumb2__]: Clear the Thumb bit of the function
address written to trace file.

9 years agodaily update
Alan Modra [Thu, 10 Jul 2014 00:01:24 +0000 (09:31 +0930)] 
daily update

9 years agoFix "attach" command vs user input race
Pedro Alves [Wed, 9 Jul 2014 14:59:02 +0000 (15:59 +0100)] 
Fix "attach" command vs user input race

On async targets, a synchronous attach is done like this:

   #1 - target_attach is called (PTRACE_ATTACH is issued)
   #2 - a continuation is installed
   #3 - we go back to the event loop
   #4 - target reports stop (SIGSTOP), event loop wakes up, and
        attach continuation is called
   #5 - among other things, the continuation calls
        target_terminal_inferior, which removes stdin from the event
        loop

Note that in #3, GDB is still processing user input.  If the user is
fast enough, e.g., with something like:

  echo -e "attach PID\nset xxx=1" | gdb

... then the "set" command is processed before the attach completes.

We get worse behavior even, if input is a tty and therefore
readline/editing is enabled, with e.g.,:

 (gdb) attach PID\nset xxx=1

we then crash readline/gdb, with:

 Attaching to program: attach-wait-input, process 14537
 readline: readline_callback_read_char() called with no handler!
 Aborted
 $

Fix this by calling target_terminal_inferior before #3 above.

The test covers both scenarios by running with editing/readline forced
to both on and off.

gdb/
2014-07-09  Pedro Alves  <palves@redhat.com>

* infcmd.c (attach_command_post_wait): Don't call
target_terminal_inferior here.
(attach_command): Call it here instead.

gdb/testsuite/
2014-07-09  Pedro Alves  <palves@redhat.com>

* gdb.base/attach-wait-input.exp: New file.
* gdb.base/attach-wait-input.c: New file.

9 years agoImprove MI -var-info-path-expression for nested struct/union case.
Andrew Burgess [Mon, 7 Jul 2014 18:22:36 +0000 (19:22 +0100)] 
Improve MI -var-info-path-expression for nested struct/union case.

  https://sourceware.org/ml/gdb-patches/2014-05/msg00383.html

The MI command -var-info-path-expression currently does not handle
non-anonymous structs / unions nested within other structs / unions,
it will skip parts of the expression.  Consider this example:

  ## START EXAMPLE ##
  $ cat ex.c
  #include <string.h>

  int
  main ()
  {
    struct s1
    {
      int a;
    };

    struct ss
    {
      struct s1 x;
    };

    struct ss an_ss;
    memset (&an_ss, 0, sizeof (an_ss));
    return 0;
  }
  $ gcc -g -o ex.x ex.c
  $ gdb ex.x
  (gdb) break 18
  Breakpoint 1 at 0x80483ba: file ex.c, line 18.
  (gdb) run
  Starting program: /home/user/ex.x

  Breakpoint 1, main () at ex.c:18
  18   return 0;
  (gdb) interpreter-exec mi "-var-create an_ss * an_ss"
  (gdb) interpreter-exec mi "-var-list-children an_ss"
  ^done,numchild="1",children=[child={name="an_ss.x",exp="x",numchild="1",type="struct s1",thread-id="1"}],has_more="0"
  (gdb) interpreter-exec mi "-var-list-children an_ss.x"
  ^done,numchild="1",children=[child={name="an_ss.x.a",exp="a",numchild="0",type="int",thread-id="1"}],has_more="0"
  (gdb) interpreter-exec mi "-var-list-children an_ss.x.a"
  ^done,numchild="0",has_more="0"
  (gdb) interpreter-exec mi "-var-info-path-expression an_ss.x.a"
  ^done,path_expr="(an_ss).a"
  (gdb) print (an_ss).a
  There is no member named a.
  ## END EXAMPLE ##

Notice that the path expression returned is wrong, and as a result
the print command fails.

This patch adds a new method to the varobj_ops structure called
is_path_expr_parent, to allow language specific control over finding
the parent varobj, the current logic becomes the C/C++ version and is
extended to handle the nested cases.  No other language currently uses
this code, so all other languages just get a default method.

With this patch, the above example now finishes like this:

  ## START EXAMPLE ##
  $ gdb ex.x
  (gdb) break 18
  Breakpoint 1 at 0x80483ba: file ex.c, line 18.
  (gdb) run
  Starting program: /home/user/ex.x

  Breakpoint 1, main () at ex.c:18
  18   return 0;
  (gdb) interpreter-exec mi "-var-list-children an_ss"
  ^done,numchild="1",children=[child={name="an_ss.x",exp="x",numchild="1",type="struct s1",thread-id="1"}],has_more="0"
  (gdb) interpreter-exec mi "-var-list-children an_ss.x"
  ^done,numchild="1",children=[child={name="an_ss.x.a",exp="a",numchild="0",type="int",thread-id="1"}],has_more="0"
  (gdb) interpreter-exec mi "-var-list-children an_ss.x.a"
  ^done,numchild="0",has_more="0"
  (gdb) interpreter-exec mi "-var-info-path-expression an_ss.x.a"
  ^done,path_expr="((an_ss).x).a"
  (gdb) print ((an_ss).x).a
  $1 = 0
  ## END EXAMPLE ##

Notice that the path expression is now correct, and the print is a
success.

gdb/ChangeLog:

* ada-varobj.c (ada_varobj_ops): Fill in is_path_expr_parent
field.
* c-varobj.c (c_is_path_expr_parent): New function, moved core
from varobj.c, with additional checks.
(c_varobj_ops): Fill in is_path_expr_parent field.
(cplus_varobj_ops): Fill in is_path_expr_parent field.
* jv-varobj.c (java_varobj_ops): Fill in is_path_expr_parent
field.
* varobj.c (is_path_expr_parent): Call is_path_expr_parent varobj
ops method.
(varobj_default_is_path_expr_parent): New function.
* varobj.h (lang_varobj_ops): Add is_path_expr_parent field.
(varobj_default_is_path_expr_parent): Declare new function.

gdb/testsuite/ChangeLog:

* gdb.mi/var-cmd.c (do_nested_struct_union_tests): New function
setting up test structures.
(main): Call new test function.
* gdb.mi/mi2-var-child.exp: Create additional breakpoint in new
test function, continue into test function and walk test
structures.

9 years agoFix --defsym to copy symbol attributes.
Cary Coutant [Wed, 9 Jul 2014 05:34:27 +0000 (22:34 -0700)] 
Fix --defsym to copy symbol attributes.

Alan Modra committed a patch to Gnu ld to fix a problem encountered on
PPC where the --defsym option wasn't copying the st_other bits to the
newly-defined symbol.

    https://sourceware.org/ml/binutils/2014-07/msg00094.html

Gold has the same problem, and additionally wasn't copying the symbol type.
This patch fixes both problems, by copying the symbol type, visibility, and
the remaining st_other bits to the new symbol for --defsym=sym1=sym2
assignments.

gold/
* expression.cc (struct Expression::Expression_eval_info): Add
new fields type_pointer, vis_pointer, and nonvis_pointer.
(Expression::eval_maybe_dot): Add type_pointer, vis_pointer, and
nonvis_pointer parameters. Adjust all calls.
(Symbol_expression::value): Update type, visibility, and nonvis bits
in caller.
* script.cc (Symbol_assignment::sized_finalize): Update type,
visibility, and remaining st_other bits for new symbol.
* script.h: (Expression::eval_maybe_dot): Add type_pointer,
vis_pointer, and nonvis_pointer parameters.
* symtab.h (Symbol::set_type): New method.

* testsuite/Makefile.am (defsym_test): New test.
* testsuite/Makefile.in: Regenerate.
* testsuite/defsym_test.c: New file.
* testsuite/defsym_test.sh: New file.

9 years agodaily update
Alan Modra [Wed, 9 Jul 2014 00:01:22 +0000 (09:31 +0930)] 
daily update

9 years agoFix internal error with LTO on ARM.
Cary Coutant [Mon, 7 Jul 2014 17:14:45 +0000 (10:14 -0700)] 
Fix internal error with LTO on ARM.

This prevents the target-specific do_read_symbols methods from being called
twice when do_layout_deferred_sections needs to layout an .eh_frame section.

gold/
PR gold/15639
* dynobj.h (Sized_dynobj::base_read_symbols): New method.
* dynobj.cc (Sized_dynobj::do_read_symbols): Move body to...
(Sized_dynobj::base_read_symbols): ...new method.
* object.h (Sized_relobj_file::base_read_symbols): New method.
* object.cc (Sized_relobj_file::do_read_symbols): Move body to...
(Sized_relobj_file::base_read_symbols): ...new method.
* arm.cc (Arm_relobj::do_read_symbols): Call base_read_symbols.
* mips.cc: (Mips_relobj::do_read_symbols): Likewise.
* powerpc.cc (Powerpc_dynobj::do_read_symbols): Likewise.

9 years ago * scripttempl/avr.sc: Remove KEEP for .data and
Denis Chertykov [Tue, 8 Jul 2014 16:15:18 +0000 (20:15 +0400)] 
* scripttempl/avr.sc: Remove KEEP for .data and
force .bss VMA to end of .data VMA.

9 years agoThis fixes PR 17110 which shows that the SH section relocation code can be called
Nick Clifton [Tue, 8 Jul 2014 15:20:48 +0000 (16:20 +0100)] 
This fixes PR 17110 which shows that the SH section relocation code can be called
for input BFDs as well as output BFDs.

PR ld/17110
* elf32-sh.c (sh_elf_osec_to_segment): Do not look for output
segments in input bfds.

9 years agoFix disasm of vmovsd/vmovss with different length values.
Ilya Tocar [Tue, 8 Jul 2014 09:45:43 +0000 (13:45 +0400)] 
Fix disasm of vmovsd/vmovss with different length values.

gas/testsuite

* gas/i386/evex-lig256-intel.d: Updated.
* gas/i386/evex-lig256.d: Updated.
* gas/i386/evex-lig512-intel.d: Updated.
* gas/i386/evex-lig512-intel.d: Updated.
* gas/i386/x86-64-evex-lig256-intel.d: Updated.
* gas/i386/x86-64-evex-lig256.d: Updated.
* gas/i386/x86-64-evex-lig512-intel.d: Updated.
* gas/i386/x86-64-evex-lig512-intel.d: Updated.

opcodes

* i386-dis-evex.h (EVEX_W_0F10_P_1_M_1): Fix vmovss.
(EVEX_W_0F10_P_3_M_1): Fix vmovsd.

9 years agold/ARM: Increase maximum page size to 64kB
Will Newton [Thu, 26 Jun 2014 14:23:31 +0000 (15:23 +0100)] 
ld/ARM: Increase maximum page size to 64kB

Increase the maximum page size to 64kB and align the TEXT_START_ADDR
to a 64kB boundary. This brings AArch32 in line with AArch64 and
improves compatability under certain conditions.

bfd/ChangeLog:

2014-07-08  Will Newton  <will.newton@linaro.org>

* elf32-arm.c (ELF_MAXPAGESIZE): Increase the default
value to 64kB and remove custom setting for NaCl.

ld/ChangeLog:

2014-07-08  Will Newton  <will.newton@linaro.org>

* emulparams/armelf_linux.sh (TEXT_START_ADDR): Increase
alignment to 64kB boundary.

ld/testsuite/ChangeLog:

2014-07-08  Will Newton  <will.newton@linaro.org>

* ld-arm/arm-lib.ld: Increase MAXPAGESIZE value to
match bfd.
* ld-arm/cortex-a8-fix-bl-rel-plt.d: Update offsets to
take into account increased segment alignment.
* ld-arm/ifunc-gdesc.r: Likewise.
* ld-arm/tls-lib.d: Likewise.

9 years agoFix PR 16722 by adding support for 8-byte vector constants.
Jiong Wang [Tue, 8 Jul 2014 11:14:56 +0000 (12:14 +0100)] 
Fix PR 16722 by adding support for 8-byte vector constants.

 * config/tc-arm.c (literal_pool): New field "alignment".
  (find_or_make_literal_pool): Initialize "alignment" to 2.
  (s_ltorg): Align the pool using value of "alignment"
  (parse_big_immediate): New parameter "in_exp". Return
  parsed expression if "in_exp" is not null.
  (parse_address_main): Invoke "parse_big_immediate" for
  constant parameter.
  (add_to_lit_pool): Add one parameter 'nbytes'.
  Split 8 byte entry into two 4 byte entry.
  Add padding to align 8 byte entry to 8 byte boundary.
  (encode_arm_cp_address): Generate literal pool entry if possible.
  (move_or_literal_pool): Generate entry for vldr case.
  (enum lit_type): New enum type.
  (do_ldst): Use new enum type.
  (do_ldstv4): Likewise.
  (do_t_ldst): Likewise.
  (neon_write_immbits): Support Thumb-2 mode.

  * gas/arm/ldconst.s: Add test cases for symbol literal.
  * gas/arm/ldconst.d: Likewise.
  * gas/arm/vldconst.s: Add test cases for vldr.
  * gas/arm/thumb2_vpool.s: Likewise.
  * gas/arm/vldconst.d: New pattern for little-endian.
  * gas/arm/thumb2_vpool.d: Likewise.
  * gas/arm/vldconst_be.d: New pattern for big-endian.
  * gas/arm/thumb2_vpool_be.d: Likewise.

9 years agoCopy st_other for linker script symbol assignments
Alan Modra [Tue, 8 Jul 2014 05:54:06 +0000 (15:24 +0930)] 
Copy st_other for linker script symbol assignments

This fixes a problem seen on powerpc64le ELFv2 when creating a
function symbol alias with ld --defsym.  st_other needs to be copied
from the source symbol to the alias in order to set up the local entry
offset for the alias.  I decided to make this change in the generic
ELF code rather than in elf64-ppc.c since it looks like other targets
that use st_other bits might benefit too.

bfd/
* elflink.c (_bfd_elf_copy_link_hash_symbol_type): Copy st_other
bits from source to dest.
* linker.c (_bfd_generic_copy_link_hash_symbol_type): Update comment.
* targets.c (struct bfd_target <_bfd_copy_link_hash_symbol_type>):
Likewise.
* bfd-in2.h: Regenerate.
ld/testsuite/
* ld-powerpc/defsym.s, * ld-powerpc/defsym.d: New test.
* ld-powerpc/powerpc.exp: Run it.

9 years agoFix gdb.trace/entry-values.exp for thumb mode
Yao Qi [Tue, 1 Jul 2014 11:30:54 +0000 (19:30 +0800)] 
Fix gdb.trace/entry-values.exp for thumb mode

We see some fails in gdb.trace/entry-values.exp in thumb mode
(-mthumb -march={armv4t,armv7-a}).

In thumb mode, the lsb of references to 'foo' and 'bar' in the assembly
(produced by dwarf assember) is set, so the generated debug
information is incorrect.

This patch copies the approach used by

  [PATCH 4/4] Fix dw2-ifort-parameter.exp on PPC64
  https://sourceware.org/ml/gdb-patches/2014-03/msg00202.html

to introduce new labels 'foo_start' and 'bar_start' which are about
the correct function address (without lsb set).  This patch fixes
these fails we've seen.

gdb/testsuite:

2014-07-08  Yao Qi  <yao@codesourcery.com>

* gdb.trace/entry-values.c: Define labels 'foo_start' and
'bar_start' at the beginning of functions 'foo' and 'bar'
respectively.
* gdb.trace/entry-values.exp: Use 'foo_start' and 'bar_start'
instead of 'foo' and 'bar'.

9 years agoEnable elf_backend_rela_normal for AArch64
Jiong Wang [Tue, 8 Jul 2014 08:29:06 +0000 (09:29 +0100)] 
Enable elf_backend_rela_normal for AArch64

  If we are generating non-relocatable object and --emit-relocs specified,
  aarch64 ld is actually generating wrong addend for rela entry when
  relocate against local symbol.

  for example, for simple testcase

  foo.c
  ===

  const char * const a = "foo";

  const char *
  foo ()
  {
    return a;
  }

  bar.c
  ===

  const char * const b = "bar";

  const char * bar ()
  {
    return b;
  }

  aarch64-none-linux-gnu-ld --emit-relocs -o x.o  foo.o bar.o
  aarch64-none-linux-gnu-readelf -r x.o

   ... R_AARCH64_ADR_PRE 0000000000400018 .rodata + 0
   ... R_AARCH64_ADD_ABS 0000000000400018 .rodata + 0
   ... R_AARCH64_ADR_PRE 0000000000400018 .rodata + 0
   ... R_AARCH64_ADD_ABS 0000000000400018 .rodata + 0

   while it should be:

   ... R_AARCH64_ADR_PRE 0000000000400018 .rodata + 0
   ... R_AARCH64_ADD_ABS 0000000000400018 .rodata + 0
   ... R_AARCH64_ADR_PRE 0000000000400018 .rodata + 10
   ... R_AARCH64_ADD_ABS 0000000000400018 .rodata + 10

   bfd generic code could actually handle this properly, but only when
   elf_backend_rela_normal set to '1'.

   this patch enable this and remove those target specific hack.

    bfd/
      * elfnn-aarch64.c (elf_backend_rela_normal): Set to 1.
      (elfNN_aarch64_relocate_section): Remove duplicated addend adjustment
      when info->relocatable be true.

    ld/testsuite/
      * ld-aarch64/emit-relocs-local-addend-bar.s: * New source file.
      * ld-aarch64/emit-relocs-local-addend-foo.s: * Likewise.
      * ld-aarch64/emit-relocs-local-addend.d: * New testcase.
      * ld-aarch64/local-addend-r.d: Likewise.

9 years agoreverse-finish: turn internal error into normal error
Markus Metzger [Mon, 30 Jun 2014 09:47:30 +0000 (11:47 +0200)] 
reverse-finish: turn internal error into normal error

The reverse-finish command results in an internal error if it cannot determine
the current function.

  (gdb) c
  Continuing.

  Program received signal SIGSEGV, Segmentation fault.
  0x0000000000000000 in ?? ()
  (gdb) reverse-finish
  Run back to call of #0  0x0000000000000000 in ?? ()
  gdb/infcmd.c:1576: internal-error: Finish: couldn't find function.
  A problem internal to GDB has been detected,
  further debugging may prove unreliable.
  Quit this debugging session? (y or n) y

This is not an internal error case since the command may be used in scenarios
where there is no function at the current PC, e.g. after calling through a bad
function pointer.

Turn this into a normal error.

gdb/
* infcmd.c (finish_backward): Turn internal error into normal error.

testsuite/
* gdb.btrace/segv.c: New.
* gdb.btrace/segv.exp: New.

9 years agoRun ar with --plugin for LTO 11 test
Alan Modra [Sat, 5 Jul 2014 02:35:01 +0000 (12:05 +0930)] 
Run ar with --plugin for LTO 11 test

Objects built with -fno-fat-lto-objects (the default for gcc-4.9) have
no normal symbols, except things like __gnu_lto_slim.  These useless
symbols are the ones put into the archive index, and of course nothing
references them so no objects are extracted by the linker.  Running
ar with --plugin changes ar behaviour to put the lto symbols into the
archive index.

PR 17112
* ld-plugin/lto.exp: When building liblti-11.a, pass
--plugin path_to_gcc/liblto_plugin.so to ar.

9 years agodaily update
Alan Modra [Tue, 8 Jul 2014 00:00:45 +0000 (09:30 +0930)] 
daily update

9 years agoMention PR gdb/17096 in ChangeLog
Pedro Alves [Mon, 7 Jul 2014 18:05:04 +0000 (19:05 +0100)] 
Mention PR gdb/17096 in ChangeLog

9 years agoPR gdb/17096: async support breaks remote debugging on Windows
Pedro Alves [Mon, 7 Jul 2014 16:51:04 +0000 (17:51 +0100)] 
PR gdb/17096: async support breaks remote debugging on Windows

On Windows, with "maint set target-async on" (the default since
a09dd441), Ctrl-C fails to stop a remote target.

With maint target-async on, the SIGINT signal handler doesn't send the
remote interrupt request immediately.  Instead, it marks an async
handler as ready, and then the main event loop wakes up and notices
that the SIGINT async signal handler token was set, and calls the
corresponding event handler, which sends the remote interrupt request.

On POSIX-like systems, the SIGINT signal makes the select/poll in the
main event loop wake up / return with EINTR.  However, on Windows,
signal handlers run on a separate thread, and Windows doesn't really
have a concept of EINTR.  So, just marking the async handler
(effectively just setting a flag) does not wake up gdb_select.
Instead, we need to call gdb_call_async_signal_handler from the signal
handler.  The Windows version (in mingw-hdep.c) sets a Windows event
that gdb_select's WaitForMultipleObjects is waiting for.

Confirmed that with this, Ctrl-C interrupts the remote target on
Windows.  Also regression tested on x86_64 Fedora 20 against
GDBserver.

gdb/
2014-07-07  Pedro Alves  <palves@redhat.com>

* remote.c (async_handle_remote_sigint)
(async_handle_remote_sigint_twice): Call
gdb_call_async_signal_handler instead of
mark_async_signal_handler.

9 years agoRemove an accidental commit.
Nick Clifton [Mon, 7 Jul 2014 16:46:05 +0000 (17:46 +0100)] 
Remove an accidental commit.

* readelf.c (get_symbol_type): Revert accidental change to
detection of thumb function symbols.

9 years agoAdds support for writing values to AVR system I/O registers.
Barney Stratford [Mon, 7 Jul 2014 15:15:19 +0000 (16:15 +0100)] 
Adds support for writing values to AVR system I/O registers.

* elf32-avr.c: Handle R_AVR_PORT5 and R_AVR_PORT6.
* reloc.c: Add BFD_RELOC_AVR_PORT5 and BFD_RELOC_AVR_PORT6.
* bfd-in2.h: Regenerate.
* libbfd.h: Regenerate.

* avr.h: Add R_AVR_PORT5 and R_AVR_PORT6.

* config/tc-avr.c (avr_operand): Permit referring to r26-r31 by
name as [xyz][hl].  Permit using a symbol whoes name begins with
`r' to refer to a register.
Allow arbitrary expressions for the P and p operators.
(md_apply_fix): Check the BFD_RELOC_AVR_PORT5 and
BFD_RELOC_AVR_PORT6 relocations.

9 years agochange to_info_record to use target delegation
Tom Tromey [Wed, 25 Jun 2014 16:23:35 +0000 (10:23 -0600)] 
change to_info_record to use target delegation

This changes to_info_record to use target delegation.
Also, target_info_record was unused, so this patch removes it.

2014-07-07  Tom Tromey  <tromey@redhat.com>

* target-delegates.c: Rebuild.
* target.c (target_info_record): Remove.
* record.c (info_record_command): Unconditionally call
to_info_record.
* target.h (struct target_ops) <to_info_record>: Use
TARGET_DEFAULT_IGNORE.
(target_info_record): Remove.

9 years agoconvert to_get_thread_local_address to use target delegation
Tom Tromey [Wed, 25 Jun 2014 16:16:55 +0000 (10:16 -0600)] 
convert to_get_thread_local_address to use target delegation

This converts to_get_thread_local_address to use
TARGET_DEFAULT_NORETURN.  One possible oddity is that this changes the
text of the kind of exception thrown in some cases.  This doesn't seem
to be a problem; in fact perhaps the final call to 'error' in
target_translate_tls_address should be changed to call
generic_tls_error.

2014-07-07  Tom Tromey  <tromey@redhat.com>

* target.h (struct target_ops) <to_get_thread_local_address>: Use
TARGET_DEFAULT_NORETURN.
* target.c (generic_tls_error): New function.
(target_translate_tls_address): Don't search target stack.
* target-delegates.c: Rebuild.
* ppc-linux-tdep.c (ppc_linux_spe_context): Don't search target
stack.
* linux-thread-db.c (thread_db_get_thread_local_address):
Unconditionally call beneath target.

9 years agoReinstate compiler check
Alan Modra [Mon, 7 Jul 2014 14:12:45 +0000 (23:42 +0930)] 
Reinstate compiler check

* lib/ld-lib.exp (check_lto_shared_available): Reinstate compiler
check here too.

9 years agoThis patch prevents a linker testsuite error if the checks are run with a
Nick Clifton [Mon, 7 Jul 2014 13:41:10 +0000 (14:41 +0100)] 
This patch prevents a linker testsuite error if the checks are run with a
toolchain that just contains the binutils - ie without a compiler.

* lib/ld-lib.exp (check_lto_available): Check that a compiler is
available before testing for LTO support.

9 years agoEnsure ld testsuite gcc -B options precede $CC -B options
Alan Modra [Mon, 7 Jul 2014 04:07:16 +0000 (13:37 +0930)] 
Ensure ld testsuite gcc -B options precede $CC -B options

Various ld-elf/shared.exp and ld-plugin/lto.exp tests simply appended
the testsuite -B options intended to force gcc use the linker under test.
This fails if $CC itself has -B options, as when setting CC to run gcc
out of a build directory.  Net result is that tests were run using
the gcc build dir collect-ld.

* config/default.exp: Don't make tmpdir/gas.  Put as symlink into
tmpdir/ld.
(gcc_gas_flag, gcc_ld_flag): Delete.
(gcc_B_opt, ld_L_opt): New globals.
ld-elf/shared.exp: Remove all refs to gcc_gas_flag and gcc_ld_flag.
ld-plugin/lto.exp: Likewise.
lib/ld-lib.exp (run_host_cmd): Add gcc_B_opt and ld_L_opt here.
(ld_simple_link): Remove -B handling now that this is done in
run_host_cmd.  Simplify.
(default_ld_compile): Simplify.
(check_lto_available): Use run_host_cmd_yesno.
(check_lto_shared_available): Likewise.

9 years agodaily update
Alan Modra [Mon, 7 Jul 2014 00:00:39 +0000 (09:30 +0930)] 
daily update

This page took 0.061867 seconds and 4 git commands to generate.