deliverable/binutils-gdb.git
10 years agoAdd new infrun.h header.
Pedro Alves [Thu, 22 May 2014 11:29:11 +0000 (12:29 +0100)] 
Add new infrun.h header.

Move infrun.c declarations out of inferior.h to a new infrun.h file.

Tested by building on:

 i686-w64-mingw32, enable-targets=all
 x86_64-linux, enable-targets=all
 i586-pc-msdosdjgpp

And also grepped the whole tree for each symbol moved to find where
infrun.h might be necessary.

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

* inferior.h (debug_infrun, debug_displaced, stop_on_solib_events)
(sync_execution, sched_multi, step_stop_if_no_debug, non_stop)
(disable_randomization, enum exec_direction_kind)
(execution_direction, stop_registers, start_remote)
(clear_proceed_status, proceed, resume, user_visible_resume_ptid)
(wait_for_inferior, normal_stop, get_last_target_status)
(prepare_for_detach, fetch_inferior_event, init_wait_for_inferior)
(insert_step_resume_breakpoint_at_sal)
(follow_inferior_reset_breakpoints, stepping_past_instruction_at)
(set_step_info, print_stop_event, signal_stop_state)
(signal_print_state, signal_pass_state, signal_stop_update)
(signal_print_update, signal_pass_update)
(update_signals_program_target, clear_exit_convenience_vars)
(displaced_step_dump_bytes, update_observer_mode)
(signal_catch_update, gdb_signal_from_command): Move
declarations ...
* infrun.h: ... to this new file.
* amd64-tdep.c: Include infrun.h.
* annotate.c: Include infrun.h.
* arch-utils.c: Include infrun.h.
* arm-linux-tdep.c: Include infrun.h.
* arm-tdep.c: Include infrun.h.
* break-catch-sig.c: Include infrun.h.
* breakpoint.c: Include infrun.h.
* common/agent.c: Include infrun.h instead of inferior.h.
* corelow.c: Include infrun.h.
* event-top.c: Include infrun.h.
* go32-nat.c: Include infrun.h.
* i386-tdep.c: Include infrun.h.
* inf-loop.c: Include infrun.h.
* infcall.c: Include infrun.h.
* infcmd.c: Include infrun.h.
* infrun.c: Include infrun.h.
* linux-fork.c: Include infrun.h.
* linux-nat.c: Include infrun.h.
* linux-thread-db.c: Include infrun.h.
* monitor.c: Include infrun.h.
* nto-tdep.c: Include infrun.h.
* procfs.c: Include infrun.h.
* record-btrace.c: Include infrun.h.
* record-full.c: Include infrun.h.
* remote-m32r-sdi.c: Include infrun.h.
* remote-mips.c: Include infrun.h.
* remote-notif.c: Include infrun.h.
* remote-sim.c: Include infrun.h.
* remote.c: Include infrun.h.
* reverse.c: Include infrun.h.
* rs6000-tdep.c: Include infrun.h.
* s390-linux-tdep.c: Include infrun.h.
* solib-irix.c: Include infrun.h.
* solib-osf.c: Include infrun.h.
* solib-svr4.c: Include infrun.h.
* target.c: Include infrun.h.
* top.c: Include infrun.h.
* windows-nat.c: Include infrun.h.
* mi/mi-interp.c: Include infrun.h.
* mi/mi-main.c: Include infrun.h.
* python/py-threadevent.c: Include infrun.h.

10 years agoDon't store the inferior's exit code for --return-child-result in a print routine.
Pedro Alves [Thu, 27 Mar 2014 13:13:59 +0000 (13:13 +0000)] 
Don't store the inferior's exit code for --return-child-result in a print routine.

A small cleanup - so we can call the print routine without affecting
--return-child-result.

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

* infrun.c (handle_inferior_event): Store the exit code for
--return-child-result here, instead of ...
(print_exited_reason): ... here.

10 years agoFix whitespace in gas listing errors and warnings
Alan Modra [Thu, 22 May 2014 09:23:22 +0000 (18:53 +0930)] 
Fix whitespace in gas listing errors and warnings

gas/
* listing.c (listing_warning, listing_error): Add space after colon.
* messages.c (as_warn_internal, as_bad_internal): Use the same
string as above.
gas/testsuite/
* gas/d30v/bittest.l: Update for changed whitespace.
* gas/d30v/serial.l: Likewise.
* gas/d30v/serial2.l: Likewise.
* gas/d30v/serial2O.l: Likewise.
* gas/d30v/warn_oddreg.l: Likewise.
* gas/i386/inval-equ-2.l: Likewise.
* gas/i386/mpx-inval-1.l: Likewise.
* gas/i386/sse-check-error.l: Likewise.
* gas/i386/x86-64-mpx-inval-1.l: Likewise.
* gas/i386/x86-64-mpx-inval-2.l: Likewise.
* gas/i386/x86-64-size-inval-1.l: Likewise.
* gas/i386/x86-64-sse-check-error.l: Likewise.

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

10 years agoPR gdb/13860: don't lose '-interpreter-exec console EXECUTION_COMMAND''s output in...
Pedro Alves [Tue, 11 Mar 2014 20:31:36 +0000 (20:31 +0000)] 
PR gdb/13860: don't lose '-interpreter-exec console EXECUTION_COMMAND''s output in async mode.

The other part of PR gdb/13860 is about console execution commands in
MI getting their output half lost.  E.g., take the finish command,
executed on a frontend's GDB console:

sync:

  finish
  &"finish\n"
  ~"Run till exit from #0  usleep (useconds=10) at ../sysdeps/unix/sysv/linux/usleep.c:27\n"
  ^running
  *running,thread-id="1"
  (gdb)
  ~"0x00000000004004d7 in foo () at stepinf.c:6\n"
  ~"6\t    usleep (10);\n"
  ~"Value returned is $1 = 0\n"
  *stopped,reason="function-finished",frame={addr="0x00000000004004d7",func="foo",args=[],file="stepinf.c",fullname="/home/pedro/gdb/tests/stepinf.c",line="6"},thread-id="1",stopped-threads="all",core="1"

async:

  finish
  &"finish\n"
  ~"Run till exit from #0  usleep (useconds=10) at ../sysdeps/unix/sysv/linux/usleep.c:27\n"
  ^running
  *running,thread-id="1"
  (gdb)
  *stopped,reason="function-finished",frame={addr="0x00000000004004d7",func="foo",args=[],file="stepinf.c",fullname="/home/pedro/gdb/tests/stepinf.c",line="6"},gdb-result-var="$1",return-value="0",thread-id="1",stopped-threads="all",core="0"

Note how all the "Value returned" etc. output is missing in async mode.

The same happens with e.g., catchpoints:

  =breakpoint-modified,bkpt={number="1",type="catchpoint",disp="keep",enabled="y",what="22016",times="1"}
  ~"\nCatchpoint "
  ~"1 (forked process 22016), 0x0000003791cbd8a6 in __libc_fork () at ../nptl/sysdeps/unix/sysv/linux/fork.c:131\n"
  ~"131\t  pid = ARCH_FORK ();\n"
  *stopped,reason="fork",disp="keep",bkptno="1",newpid="22016",frame={addr="0x0000003791cbd8a6",func="__libc_fork",args=[],file="../nptl/sysdeps/unix/sysv/linux/fork.c",fullname="/usr/src/debug/glibc-2.14-394-g8f3b1ff/nptl/sysdeps/unix/sysv/linux/fork.c",line="131"},thread-id="1",stopped-threads="all",core="0"

where all those ~ lines are missing in async mode, or just the "step"
current line indication:

  s
  &"s\n"
  ^running
  *running,thread-id="all"
  (gdb)
  ~"13\t  foo ();\n"
  *stopped,frame={addr="0x00000000004004ef",func="main",args=[{name="argc",value="1"},{name="argv",value="0x7fffffffdd78"}],file="stepinf.c",fullname="/home/pedro/gdb/tests/stepinf.c",line="13"},thread-id="1",stopped-threads="all",core="3"
  (gdb)

Or in the case of the PRs example, the "Stopped due to shared library
event" note:

  start
  &"start\n"
  ~"Temporary breakpoint 1 at 0x400608: file ../../../src/gdb/testsuite/gdb.mi/solib-main.c, line 21.\n"
  =breakpoint-created,bkpt={number="1",type="breakpoint",disp="del",enabled="y",addr="0x0000000000400608",func="main",file="../../../src/gdb/testsuite/gdb.mi/solib-main.c",fullname="/home/pedro/gdb/mygit/src/gdb/testsuite/gdb.mi/solib-main.c",line="21",times="0",original-location="main"}
  ~"Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.mi/solib-main \n"
  =thread-group-started,id="i1",pid="21990"
  =thread-created,id="1",group-id="i1"
  ^running
  *running,thread-id="all"
  (gdb)
  =library-loaded,id="/lib64/ld-linux-x86-64.so.2",target-name="/lib64/ld-linux-x86-64.so.2",host-name="/lib64/ld-linux-x86-64.so.2",symbols-loaded="0",thread-group="i1"
  ~"Stopped due to shared library event (no libraries added or removed)\n"
  *stopped,reason="solib-event",thread-id="1",stopped-threads="all",core="3"
  (gdb)

IMO, if you're typing execution commands in a frontend's console, you
expect to see their output.  Indeed it's what you get in sync mode.  I
think async mode should do the same.  Deciding what to mirror to the
console wrt to breakpoints and random stops gets messy real fast.
E.g., say "s" trips on a breakpoint.  We'd clearly want to mirror the
event to the console in this case.  But what about more complicated
cases like "s&; thread n; s&", and one of those steps spawning a new
thread, and that thread hitting a breakpoint?  It's impossible in
general to track whether the thread had any relation to the commands
that had been executed.  So I think we should just simplify and always
mirror breakpoints and random events to the console.

Notes:

  - mi->out is the same as gdb_stdout when MI is the current
    interpreter.  I think that referring to that directly is cleaner.
    An earlier revision of this patch made the changes that are now
    done in mi_on_normal_stop directly in infrun.c:normal_stop, and so
    not having an obvious place to put the new uiout by then, and not
    wanting to abuse CLI's uiout, I made a temporary uiout when
    necessary.

  - Hopefuly the rest of the patch is more or less obvious given the
    comments added.

Tested on x86_64 Fedora 20, no regressions.

2014-05-21  Pedro Alves  <palves@redhat.com>

PR gdb/13860
* gdbthread.h (struct thread_control_state): New field
`command_interp'.
* infrun.c (follow_fork): Copy the new thread control field to the
child fork thread.
(clear_proceed_status_thread): Clear the new thread control field.
(proceed): Set the new thread control field.
* interps.h (command_interp): Declare.
* interps.c (command_interpreter): New global.
(command_interp): New function.
(interp_exec): Set `command_interpreter' while here.
* cli-out.c (cli_uiout_dtor): New function.
(cli_ui_out_impl): Install it.
* mi/mi-interp.c: Include cli-out.h.
(mi_cmd_interpreter_exec): Add comment.
(restore_current_uiout_cleanup): New function.
(ui_out_free_cleanup): New function.
(mi_on_normal_stop): If finishing an execution command started by
a CLI command, or any kind of breakpoint-like event triggered,
print the stop event to the output (CLI) stream.
* mi/mi-out.c (mi_ui_out_impl): Install NULL `dtor' handler.

2014-05-21  Pedro Alves  <palves@redhat.com>

PR gdb/13860
* gdb.mi/mi-cli.exp (line_callee4_next_step): New global.
(top level): Test that output related to execution commands is
sent to the console with CLI commands, but not with MI commands.
Test that breakpoint events are always mirrored to the console.
Also expect the new source line to be output after a "next" in
async mode too.  Make it a pass/fail test.
* gdb.mi/mi-solib.exp: Test that the CLI solib event note is
output.
* lib/mi-support.exp (mi_gdb_expect_cli_output): New procedure.

10 years agoPR gdb/13860: make -interpreter-exec console "list" behave more like "list".
Pedro Alves [Wed, 21 May 2014 22:15:27 +0000 (23:15 +0100)] 
PR gdb/13860: make -interpreter-exec console "list" behave more like "list".

I noticed that "list" behaves differently in CLI vs MI.  Particularly:

  $ ./gdb -nx -q ./testsuite/gdb.mi/mi-cli
  Reading symbols from /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.mi/mi-cli...done.
  (gdb) start
  Temporary breakpoint 1 at 0x40054d: file ../../../src/gdb/testsuite/gdb.mi/basics.c, line 62.
  Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.mi/mi-cli

  Temporary breakpoint 1, main () at ../../../src/gdb/testsuite/gdb.mi/basics.c:62
  62        callee1 (2, "A string argument.", 3.5);
  (gdb) list
  57      {
  58      }
  59
  60      main ()
  61      {
  62        callee1 (2, "A string argument.", 3.5);
  63        callee1 (2, "A string argument.", 3.5);
  64
  65        do_nothing (); /* Hello, World! */
  66
  (gdb)

Note the list started at line 57.  IOW, the program stopped at line
62, and GDB centered the list on that.

compare with:

  $ ./gdb -nx -q ./testsuite/gdb.mi/mi-cli -i=mi
  =thread-group-added,id="i1"
  ~"Reading symbols from /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.mi/mi-cli..."
  ~"done.\n"
  (gdb)
  start
  &"start\n"
...
 ~"\nTemporary breakpoint "
  ~"1, main () at ../../../src/gdb/testsuite/gdb.mi/basics.c:62\n"
  ~"62\t  callee1 (2, \"A string argument.\", 3.5);\n"
  *stopped,reason="breakpoint-hit",disp="del",bkptno="1",frame={addr="0x000000000040054d",func="main",args=[],file="../../../src/gdb/testsuite/gdb.mi/basics.c",fullname="/home/pedro/gdb/mygit/src/gdb/testsuite/gdb.mi/basics.c",line="62"},thread-id="1",stopped-threads="all",core="0"
  =breakpoint-deleted,id="1"
  (gdb)
  -interpreter-exec console list
  ~"62\t  callee1 (2, \"A string argument.\", 3.5);\n"
  ~"63\t  callee1 (2, \"A string argument.\", 3.5);\n"
  ~"64\t\n"
  ~"65\t  do_nothing (); /* Hello, World! */\n"
  ~"66\t\n"
  ~"67\t  callme (1);\n"
  ~"68\t  callme (2);\n"
  ~"69\t\n"
  ~"70\t  return 0;\n"
  ~"71\t}\n"
  ^done
  (gdb)

Here the list starts at line 62, where the program was stopped.

This happens because print_stack_frame, called from both normal_stop
and mi_on_normal_stop, is the function responsible for setting the
current sal from the selected frame, overrides the PRINT_WHAT
argument, and only after that does it decide whether to center the
current sal line or not, based on the overridden value, and it will
always decide false.

(The print_stack_frame call in mi_on_normal_stop is a little different
from the call in normal_stop, in that it is an unconditional
SRC_AND_LOC call.  A future patch will make those uniform.)

A previous version of this patch made MI uniform with CLI here, by
making print_stack_frame also center when MI is active.  That changed
the output of a "list" command in mi-cli.exp, to expect line 57
instead of 62, as per the example above.

However, looking deeper, that list in question is the first "list"
after the program stops, and right after the stop, before the "list",
the test did "set listsize 1".  Let's try the same thing with the CLI:

 (gdb) start
 62        callee1 (2, "A string argument.", 3.5);
 (gdb) set listsize 1
 (gdb) list
 57      {

Huh, that's unexpected.  Why the 57?  It's because print_stack_frame,
called in reaction to the breakpoint stop, expecting the next "list"
to show 10 lines (the listsize at the time) around line 62, sets the
lines listed range to 57-67 (62 +/- 5).  If the user changes the
listsize before "list", why would we still show that range?  Looks
bogus to me.

So the fix for this whole issue should be delay trying to center the
listing to until actually listing, so that the correct listsize can be
taken into account.  This makes MI and CLI uniform too, as it deletes
the center code from print_stack_frame.

A series of tests are added to list.exp to cover this.  mi-cli.exp was
after all correct all along, but it now gains an additional test that
lists lines with listsize 10, to ensure the centering is consistent
with CLI's.

One related Python test changed related output -- it's a test that
prints the line number after stopping for a breakpoint, similar to the
new list.exp tests.  Previously we'd print the stop line minus 5 (due
to the premature centering), now we print the stop line.  I think
that's a good change.

Tested on x86_64 Fedora 20.

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

* cli/cli-cmds.c (list_command): Handle the first "list" after the
current source line having changed.
* frame.h (set_current_sal_from_frame): Remove 'center' parameter.
* infrun.c (normal_stop): Adjust call to
set_current_sal_from_frame.
* source.c (clear_lines_listed_range): New function.
(set_current_source_symtab_and_line, identify_source_line): Clear
the lines listed range.
(line_info): Handle the first "info line" after the current source
line having changed.
* stack.c (print_stack_frame): Remove center handling.
(set_current_sal_from_frame): Remove 'center' parameter.  Don't
center sal.line.

gdb/testsuite/
2014-05-21  Pedro Alves  <palves@redhat.com>

* gdb.base/list.exp (build_pattern, test_list): New procedures.
Use them to test variations of "list" after reaching a breakpoint.
* gdb.mi/mi-cli.exp (line_main_callme_2): New global.
Test "list" with listsize 10 after reaching a breakpoint.
* gdb.python/python.exp (decode_line current location line
number): Adjust expected line number.

10 years agofix file names in earlier checkin
Doug Evans [Wed, 21 May 2014 22:00:31 +0000 (15:00 -0700)] 
fix file names in earlier checkin

10 years agoRevert "Fix argument passing in mi_run_cmd_full"
Simon Marchi [Wed, 21 May 2014 21:22:48 +0000 (17:22 -0400)] 
Revert "Fix argument passing in mi_run_cmd_full"

This reverts commit 8c217a4b684386aa5ce6a078dffbe63265a524e6.

Following this

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

I suggest reverting my previous commit. I will follow with another
patch to add comments, to clarify some things as stated in the mail
thread.

I ran make check with on gdb.mi, and the test that the commit broke
passes again.

gdb/testsuite/ChangeLog:

2014-05-21  Simon Marchi  <simon.marchi@ericsson.com>

* lib/mi-support.exp (mi_run_cmd_full): Revert to original
behavior for $args, pass it directly to "run".

10 years agoNative targets: Add inf-child.c:inf_child_mourn_inferior and use it.
Pedro Alves [Wed, 21 May 2014 21:28:23 +0000 (22:28 +0100)] 
Native targets: Add inf-child.c:inf_child_mourn_inferior and use it.

Most ports do the same thing in the tail of their mourn routine - call
generic_mourn_inferior+inf_child_maybe_unpush_target.

This factors that out to a convenience function.  More could be done,
but this converts only the really obvious ones.

Tested by building GDB on x86_64 Fedora 20, mingw32 and djgpp.  The
rest is untested, but I think a patch can't get more obvious.

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

* inf-child.c (inf_child_mourn_inferior): New function.
* inf-child.h (inf_child_mourn_inferior): New declaration.
* darwin-nat.c (darwin_mourn_inferior): Use
inf_child_mourn_inferior.
* gnu-nat.c (gnu_mourn_inferior): Likewise.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Likewise.
* inf-ttrace.c (inf_ttrace_mourn_inferior): Likewise.
* nto-procfs.c (procfs_mourn_inferior): Likewise.
* windows-nat.c (windows_mourn_inferior): Likewise.

10 years agogdb/testsuite: Bump up `match_max'
Maciej W. Rozycki [Wed, 21 May 2014 19:34:57 +0000 (20:34 +0100)] 
gdb/testsuite: Bump up `match_max'

This fixes:

PASS: gdb.base/info-macros.exp: info macro  -a  --  FOO
ERROR: internal buffer is full.
UNRESOLVED: gdb.base/info-macros.exp: info macros 2
ERROR: internal buffer is full.
UNRESOLVED: gdb.base/info-macros.exp: info macros 3
ERROR: internal buffer is full.
UNRESOLVED: gdb.base/info-macros.exp: info macros 4
FAIL: gdb.base/info-macros.exp: info macros *$pc
ERROR: internal buffer is full.
UNRESOLVED: gdb.base/info-macros.exp: next
FAIL: gdb.base/info-macros.exp: info macros
ERROR: internal buffer is full.
UNRESOLVED: gdb.base/info-macros.exp: next
FAIL: gdb.base/info-macros.exp: info macros 6
ERROR: internal buffer is full.
UNRESOLVED: gdb.base/info-macros.exp: next
FAIL: gdb.base/info-macros.exp: info macros 7
ERROR: internal buffer is full.
UNRESOLVED: gdb.base/info-macros.exp: info macros info-macros.c:42 (PRMS
gdb/NNNN)

with the arm-eabi target tested on the i686-mingw32 host where GCC
defines enough macros to exhaust expect's 30000 characters of buffer
space.

* lib/gdb.exp (default_gdb_init): Bump `match_max' up from
30000 to 65536.

10 years ago* scm-breakpoint.c (breakpoint_functions): Fix typo.
Doug Evans [Wed, 21 May 2014 19:04:45 +0000 (12:04 -0700)] 
* scm-breakpoint.c (breakpoint_functions): Fix typo.

10 years agoMake exception throwers have void result. Delete unused gdbscm_scm_to_target_string_...
Doug Evans [Wed, 21 May 2014 18:52:51 +0000 (11:52 -0700)] 
Make exception throwers have void result.  Delete unused gdbscm_scm_to_target_string_unsafe.

* scm-exception.c (gdbscm_invalid_object_error): Make result is void.
(gdbscm_out_of_range_error): Ditto.
(gdbscm_memory_error): Ditto.
* scm-string.c (gdbscm_scm_to_target_string_unsafe): Delete.
* guile-internal.h (gdbscm_invalid_object_error): Update.
(gdbscm_out_of_range_error): Update.
(gdbscm_memory_error): Update.
(gdbscm_scm_to_target_string_unsafe): Delete.

10 years agoAllow making GDB not automatically connect to the native target.
Pedro Alves [Wed, 21 May 2014 17:30:47 +0000 (18:30 +0100)] 
Allow making GDB not automatically connect to the native target.

Sometimes it's useful to be able to disable the automatic connection
to the native target.  E.g., sometimes GDB disconnects from the
extended-remote target I was debugging, without me noticing it, and
then I do "run".  That starts the program locally, and only after a
little head scratch session do I figure out the program is running
locally instead of remotely as intended.  Same thing with "attach",
"info os", etc.

With the patch, we now can have this instead:

 (gdb) set auto-connect-native-target off
 (gdb) target extended-remote :9999
 ...
 *gdb disconnects*
 (gdb) run
 Don't know how to run.  Try "help target".

To still be able to connect to the native target with
auto-connect-native-target set to off, I've made "target native" work
instead of erroring out as today.

Before:

 (gdb) target native
 Use the "run" command to start a native process.

After:

 (gdb) target native
 Done.  Use the "run" command to start a process.
 (gdb) maint print target-stack
 The current target stack is:
   - native (Native process)
   - exec (Local exec file)
   - None (None)
 (gdb) run
 Starting program: ./a.out
 ...

I've also wanted this for the testsuite, when running against the
native-extended-gdbserver.exp board (runs against gdbserver in
extended-remote mode).  With a non-native-target board, it's always a
bug to launch a program with the native target.  Turns out we still
have one such case this patch catches:

 (gdb) break main
 Breakpoint 1 at 0x4009e5: file ../../../src/gdb/testsuite/gdb.base/coremaker.c, line 138.
 (gdb) run
 Don't know how to run.  Try "help target".
 (gdb) FAIL: gdb.base/corefile.exp: run: with core

On the patch itself, probably the least obvious bit is the need to go
through all targets, and move the unpush_target call to after the
generic_mourn_inferior call instead of before.  This is what
inf-ptrace.c does too, ever since multi-process support was added.
The reason inf-ptrace.c does things in that order is that in the
current multi-process/single-target model, we shouldn't unpush the
target if there are still other live inferiors being debugged.  The
check for that is "have_inferiors ()" (a misnomer nowadays...), which
does:

 have_inferiors (void)
 {
   for (inf = inferior_list; inf; inf = inf->next)
     if (inf->pid != 0)
       return 1;

It's generic_mourn_inferior that ends up clearing inf->pid, so we need
to call it before the have_inferiors check.  To make all native
targets behave the same WRT to explicit "target native", I've added an
inf_child_maybe_unpush_target function that targets call instead of
calling unpush_target directly, and as that includes the
have_inferiors check, I needed to adjust the targets.

Tested on x86_64 Fedora 20, native, and also with the
extended-gdbserver board.

Confirmed a cross build of djgpp gdb still builds.

Smoke tested a cross build of Windows gdb under Wine.

Untested otherwise.

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

* inf-child.c (inf_child_ops, inf_child_explicitly_opened): New
globals.
(inf_child_open_target): New function.
(inf_child_open): Use inf_child_open_target to push the target
instead of erroring out.
(inf_child_disconnect, inf_child_close)
(inf_child_maybe_unpush_target): New functions.
(inf_child_target): Install inf_child_disconnect and
inf_child_close.  Store a pointer to the returned object.
* inf-child.h (inf_child_open_target, inf_child_maybe_unpush): New
declarations.
* target.c (auto_connect_native_target): New global.
(show_default_run_target): New function.
(find_default_run_target): Return NULL if automatically connecting
to the native target is disabled.
(_initialize_target): Install set/show auto-connect-native-target.
* NEWS: Mention "set auto-connect-native-target", and "target
native".
* linux-nat.c (super_close): New global.
(linux_nat_close): Call super_close.
(linux_nat_add_target): Store a pointer to the base class's
to_close method.
* inf-ptrace.c (inf_ptrace_mourn_inferior, inf_ptrace_detach): Use
inf_child_maybe_unpush.
* inf-ttrace.c (inf_ttrace_him): Don't push the target if it is
already pushed.
(inf_ttrace_mourn_inferior): Only unpush the target after mourning
the inferior.  Use inf_child_maybe_unpush_target.
(inf_ttrace_attach): Don't push the target if it is already
pushed.
(inf_ttrace_detach): Use inf_child_maybe_unpush_target.
* darwin-nat.c (darwin_mourn_inferior): Only unpush the target
after mourning the inferior.  Use inf_child_maybe_unpush_target.
(darwin_attach_pid): Don't push the target if it is already
pushed.
* gnu-nat.c (gnu_mourn_inferior): Only unpush the target after
mourning the inferior.  Use inf_child_maybe_unpush_target.
(gnu_detach): Use inf_child_maybe_unpush_target.
* go32-nat.c (go32_create_inferior): Don't push the target if it
is already pushed.
(go32_mourn_inferior): Use inf_child_maybe_unpush_target.
* nto-procfs.c (procfs_is_nto_target): Adjust comment.
(procfs_open): Rename to ...
(procfs_open_1): ... this.  Add target_ops parameter.  Adjust
comments.  Can target_preopen before changing node.  Call
inf_child_open_target to push the target explicitly.
(procfs_attach): Don't push the target if it is already pushed.
(procfs_detach): Use inf_child_maybe_unpush_target.
(procfs_create_inferior): Don't push the target if it is already
pushed.
(nto_native_ops): New global.
(procfs_open): Reimplement.
(procfs_native_open): New function.
(init_procfs_targets): Install procfs_native_open as to_open of
"target native".  Store a pointer to the "native" target in
nto_native_ops.
* procfs.c (procfs_attach): Don't push the target if it is already
pushed.
(procfs_detach): Use inf_child_maybe_unpush_target.
(procfs_mourn_inferior): Only unpush the target after mourning the
inferior.  Use inf_child_maybe_unpush_target.
(procfs_init_inferior): Don't push the target if it is already
pushed.
* windows-nat.c (do_initial_windows_stuff): Don't push the target
if it is already pushed.
(windows_detach): Use inf_child_maybe_unpush_target.
(windows_mourn_inferior): Only unpush the target after mourning
the inferior.  Use inf_child_maybe_unpush_target.

gdb/doc/
2014-05-21  Pedro Alves  <palves@redhat.com>

* gdb.texinfo (Starting): Document "set/show
auto-connect-native-target".
(Target Commands): Document "target native".

gdb/testsuite/
2014-05-21  Pedro Alves  <palves@redhat.com>

* boards/gdbserver-base.exp (GDBFLAGS): Set to "set
auto-connect-native-target off".
* gdb.base/auto-connect-native-target.c: New file.
* gdb.base/auto-connect-native-target.exp: New file.

10 years agoNEWS: Mention native target renames.
Pedro Alves [Wed, 21 May 2014 17:30:46 +0000 (18:30 +0100)] 
NEWS: Mention native target renames.

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

* NEWS: Mention that the "child", "GNU, "djgpp", "darwin-child"
and "procfs" targets are now called "native" instead.

10 years agogo32-nat.c: Don't override to_open.
Pedro Alves [Wed, 21 May 2014 17:30:46 +0000 (18:30 +0100)] 
go32-nat.c: Don't override to_open.

Although the string says "Done.", nothing is pushing the target as is.
Removing the method override let's us fall through to the the base
to_open implemention in inf-child.c, which will push the target in
reaction to "target native" in a follow up patch.

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

* go32-nat.c (go32_open): Delete.
(go32_target): Don't override the to_open method.

10 years agonto-procfs.c: Add "target native".
Pedro Alves [Wed, 21 May 2014 17:30:45 +0000 (18:30 +0100)] 
nto-procfs.c: Add "target native".

This makes QNX/NTO end up with two targets.  It preserves "target
procfs <node>", and adds a "native" target to be like other native
ports.

Not tested.

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

* nto-procfs.c (procfs_can_run): New function.
(nto_procfs_ops): New global.
(init_procfs_targets): New, based on procfs_target.  Install
"target native" in addition to "target procfs".
(_initialize_procfs): Call init_procfs_targets instead of adding
the target here.

10 years agoWindows: Rename "target child" -> "target native"
Pedro Alves [Wed, 21 May 2014 17:30:45 +0000 (18:30 +0100)] 
Windows: Rename "target child" -> "target native"

To be like other native targets.

Leave to_shortname, to_longname, to_doc as inf-child.c sets them:

  t->to_shortname = "native";
  t->to_longname = "Native process";
  t->to_doc = "Native process (started by the \"run\" command).";

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

* windows-nat.c (windows_target): Don't override to_shortname,
to_longname or to_doc.

10 years agoRename "target GNU" -> "target native"
Pedro Alves [Wed, 21 May 2014 17:30:44 +0000 (18:30 +0100)] 
Rename "target GNU" -> "target native"

To be like other native targets.

Leave to_shortname, to_longname, to_doc as inf-child.c sets them:

  t->to_shortname = "native";
  t->to_longname = "Native process";
  t->to_doc = "Native process (started by the \"run\" command).";

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

* gnu-nat.c (gnu): Don't override to_shortname, to_longname or
to_doc.

10 years agoRename "target darwin-child" -> "target native"
Pedro Alves [Wed, 21 May 2014 17:30:43 +0000 (18:30 +0100)] 
Rename "target darwin-child" -> "target native"

To be like other native targets.

Leave to_shortname, to_longname, to_doc as inf-child.c sets them:

  t->to_shortname = "native";
  t->to_longname = "Native process";
  t->to_doc = "Native process (started by the \"run\" command).";

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

* darwin-nat.c (_initialize_darwin_inferior): Don't override
to_shortname, to_longname or to_doc.

10 years agoRename "target djgpp" -> "target native"
Pedro Alves [Wed, 21 May 2014 17:30:43 +0000 (18:30 +0100)] 
Rename "target djgpp" -> "target native"

To be like other native targets.

Leave to_shortname, to_longname, to_doc as inf-child.c sets them:

  t->to_shortname = "native";
  t->to_longname = "Native process";
  t->to_doc = "Native process (started by the \"run\" command).";

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

* go32-nat.c (go32_target): Don't override to_shortname,
to_longname or to_doc.

10 years agoRename "target child" to "target native".
Pedro Alves [Wed, 21 May 2014 17:30:43 +0000 (18:30 +0100)] 
Rename "target child" to "target native".

I had been pondering renaming "target child" to something else.
"child" is a little lie in case of "attach", and not exactly very
clear to users, IMO.  By best suggestion is "target native".  If I
were to explain what "target child" is, I'd just start out with "it's
the native target" anyway.  I was worrying a little that "native"
might be a lie too if some port comes up with a default target that
can run but is not really native, but I think that's a very minor
issue - we can consider that "native" really means the default built
in target that GDB supports, instead of saying that's the target that
debugs host native processes, if it turns out necessary.

This change doesn't affect users much, because "target child" results
in error today:

 (gdb) target child
 Use the "run" command to start a child process.

Other places "child" is visible:

 (gdb) help target
 ...
 List of target subcommands:

 target child -- Child process (started by the "run" command)
 target core -- Use a core file as a target
 target exec -- Use an executable file as a target
 ...

 (gdb) info target
 Symbols from "/home/pedro/gdb/mygit/build/gdb/gdb".
 Child process:
 Using the running image of child Thread 0x7ffff7fc9740 (LWP 4818).
 While running this, GDB does not access memory from...
 ...

These places will say "native" instead.  I think that's a good thing.

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

* inf-child.c (inf_child_open): Remove mention of "child".
(inf_child_target): Rename target to "native" instead of "child".

gdb/testsuite/
2014-05-21  Pedro Alves  <palves@redhat.com>

* gdb.base/default.exp: Test "target native" instead of "target
child".

10 years agoDrop regset_alloc().
Andreas Arnez [Fri, 22 Nov 2013 18:49:51 +0000 (18:49 +0000)] 
Drop regset_alloc().

Now that all invocations of regset_alloc() have been removed, the
function is dropped.  Since regset_alloc() was the only function
provided by regset.c, this source file is removed as well.

10 years agoSPARC: Replace regset_alloc() invocations by static regset structures.
Andreas Arnez [Mon, 24 Feb 2014 10:58:15 +0000 (10:58 +0000)] 
SPARC: Replace regset_alloc() invocations by static regset structures.

10 years agoSPARC: Rename register maps from "*regset" to "*regmap"
Andreas Arnez [Fri, 28 Mar 2014 17:34:19 +0000 (17:34 +0000)] 
SPARC: Rename register maps from "*regset" to "*regmap"

Clear the naming confusion about "regset" versus "sparc*regset".  The
latter was used to represent the *map* of a register set, not the
register set itself, and is thus renamed accordingly.

The following identifiers are renamed:

  sparc32_bsd_fpregset => sparc32_bsd_fpregmap
  sparc32_linux_core_gregset => sparc32_linux_core_gregmap
  sparc32_sol2_fpregset => sparc32_sol2_fpregmap
  sparc32_sol2_gregset => sparc32_sol2_gregmap
  sparc32_sunos4_fpregset => sparc32_sunos4_fpregmap
  sparc32_sunos4_gregset => sparc32_sunos4_gregmap
  sparc32nbsd_gregset => sparc32nbsd_gregmap
  sparc64_bsd_fpregset => sparc64_bsd_fpregmap
  sparc64_linux_core_gregset => sparc64_linux_core_gregmap
  sparc64_linux_ptrace_gregset => sparc64_linux_ptrace_gregmap
  sparc64_sol2_fpregset => sparc64_sol2_fpregmap
  sparc64_sol2_gregset => sparc64_sol2_gregmap
  sparc64fbsd_gregset => sparc64fbsd_gregmap
  sparc64nbsd_gregset => sparc64nbsd_gregmap
  sparc64obsd_core_gregset => sparc64obsd_core_gregmap
  sparc64obsd_gregset => sparc64obsd_gregmap
  sparc_fpregset => sparc_fpregmap
  sparc_gregset => sparc_gregmap
  sparc_sol2_fpregset => sparc_sol2_fpregmap
  sparc_sol2_gregset => sparc_sol2_gregmap

Also, all local variables 'gregset' and 'fpregset' are renamed to
'gregmap' and 'fpregmap', respectively.

10 years agoSCORE: Replace regset_alloc() invocation by a static regset structure.
Andreas Arnez [Mon, 31 Mar 2014 09:07:42 +0000 (09:07 +0000)] 
SCORE: Replace regset_alloc() invocation by a static regset structure.

Since this changes makes the only member of the tdep structure
obsolete, the tdep structure is removed.

10 years agoMN10300: Replace regset_alloc() invocations by static regset structures.
Andreas Arnez [Fri, 22 Nov 2013 18:43:00 +0000 (18:43 +0000)] 
MN10300: Replace regset_alloc() invocations by static regset structures.

On this architecture the change may fix a small memory leak.

10 years agoMIPS: Replace regset_alloc() invocations by static regset structures.
Andreas Arnez [Fri, 22 Nov 2013 18:40:06 +0000 (18:40 +0000)] 
MIPS: Replace regset_alloc() invocations by static regset structures.

After removal of the regset_alloc invocations, the appropriate tdep
fields become obsolete and are thus removed.

10 years agoX86: Replace regset_alloc() invocations by static regset structures.
Andreas Arnez [Mon, 5 May 2014 12:58:11 +0000 (12:58 +0000)] 
X86: Replace regset_alloc() invocations by static regset structures.

After removal of the regset_alloc invocations, the appropriate tdep
fields become obsolete and are thus removed.

10 years agoARM: Replace regset_alloc() invocations by static regset structures.
Andreas Arnez [Fri, 28 Mar 2014 17:21:39 +0000 (17:21 +0000)] 
ARM: Replace regset_alloc() invocations by static regset structures.

After removal of the regset_alloc invocations, the appropriate tdep
fields become obsolete and are thus removed.

10 years agoAARCH64: Replace regset_alloc() invocations by static regset structures.
Andreas Arnez [Fri, 22 Nov 2013 18:29:26 +0000 (18:29 +0000)] 
AARCH64: Replace regset_alloc() invocations by static regset structures.

After removal of the regset_alloc invocations, the tdep fields
'gregset' and 'fpregset' become obsolete and are thus removed.

10 years agoRemove 'arch' field from regset structure.
Andreas Arnez [Tue, 13 May 2014 11:05:57 +0000 (11:05 +0000)] 
Remove 'arch' field from regset structure.

Removes the 'arch' field from the regset structure, since it
represents the only "dynamic" data in a regset.  It was referenced in
some regset supply- and collect routines, to get access to the gdbarch
associated with the regset.  Naturally, the affected routines always
have access to the regcache to be supplied to or collected from.  Thus
the gdbarch associated with that regcache can be used instead.

10 years agoConstify regset structures.
Andreas Arnez [Mon, 3 Mar 2014 09:31:21 +0000 (09:31 +0000)] 
Constify regset structures.

10 years agogdb/testsuite: Handle underlying type in gdb.cp/var-tag.exp.
Mark Wielaard [Wed, 21 May 2014 14:00:05 +0000 (16:00 +0200)] 
gdb/testsuite: Handle underlying type in gdb.cp/var-tag.exp.

* gdb.cp/var-tag.exp (do_global_tests): Handle underlying type.

10 years agoFix TLS access for -static -pthread
Jan Kratochvil [Wed, 21 May 2014 14:25:53 +0000 (16:25 +0200)] 
Fix TLS access for -static -pthread

I have posted:
TLS variables access for -static -lpthread executables
https://sourceware.org/ml/libc-help/2014-03/msg00024.html
and the GDB patch below has been confirmed as OK for current glibcs.

Further work should be done for newer glibcs:
Improve TLS variables glibc compatibility
https://sourceware.org/bugzilla/show_bug.cgi?id=16954

Still the patch below implements the feature in a fully functional way backward
compatible with current glibcs, it depends on the following glibc source line:
csu/libc-tls.c
main_map->l_tls_modid = 1;

gdb/
2014-05-21  Jan Kratochvil  <jan.kratochvil@redhat.com>

Fix TLS access for -static -pthread.
* linux-thread-db.c (struct thread_db_info): Add td_thr_tlsbase_p.
(try_thread_db_load_1): Initialize it.
(thread_db_get_thread_local_address): Call it if LM is zero.
* target.c (target_translate_tls_address): Remove LM_ADDR zero check.
* target.h (struct target_ops) (to_get_thread_local_address): Add
load_module_addr comment.

gdb/gdbserver/
2014-05-21  Jan Kratochvil  <jan.kratochvil@redhat.com>

Fix TLS access for -static -pthread.
* gdbserver/thread-db.c (struct thread_db): Add td_thr_tlsbase_p.
(thread_db_get_tls_address): Call it if LOAD_MODULE is zero.
(thread_db_load_search, try_thread_db_load_1): Initialize it.

gdb/testsuite/
2014-05-21  Jan Kratochvil  <jan.kratochvil@redhat.com>

Fix TLS access for -static -pthread.
* gdb.threads/staticthreads.c <HAVE_TLS> (tlsvar): New.
<HAVE_TLS> (thread_function, main): Initialize it.
* gdb.threads/staticthreads.exp: Try gdb_compile_pthreads for $have_tls.
Add clean_restart.
<$have_tls != "">: Check TLSVAR.

Message-ID: <20140410115204.GB16411@host2.jankratochvil.net>

10 years agoMake the dcache (code/stack cache) handle line reading errors better
Pedro Alves [Wed, 21 May 2014 12:58:16 +0000 (13:58 +0100)] 
Make the dcache (code/stack cache) handle line reading errors better

The dcache (code/stack cache) is supposed to be transparent, but it's
actually not in one case.  dcache tries to read chunks (cache lines)
at a time off of the target.  This may end up trying to read
unaccessible or unavailable memory.  Currently the caller gets an xfer
error in this case.  But if the specific bits of memory the caller
actually wanted are available and accessible, then the caller should
get the memory it wanted, not an error.

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

* dcache.c (dcache_read_memory_partial): If reading the cache line
fails, fallback to reading just the memory the caller wanted.

gdb/testsuite/
2014-05-21  Pedro Alves  <palves@redhat.com>

* gdb.base/dcache-line-read-error.c: New.
* gdb.base/dcache-line-read-error.exp: New.

10 years agodaily update
Alan Modra [Wed, 21 May 2014 00:01:09 +0000 (09:31 +0930)] 
daily update

10 years agoAdd ChangeLog from previous MIPS .module commit
mfortune [Tue, 20 May 2014 22:50:21 +0000 (23:50 +0100)] 
Add ChangeLog from previous MIPS .module commit

10 years agoAdd MIPS .module directive
mfortune [Tue, 20 May 2014 12:28:20 +0000 (13:28 +0100)] 
Add MIPS .module directive

gas/

* config/tc-mips.c (file_mips_opts_checked): New static global.
(s_module): New static function.
(file_ase): Remove.
(mips_pseudo_table): Add .module handler.
(mips_set_ase): Add opts argument and use instead of mips_opts.
  (md_assemble): Use file_mips_check_options.
(md_parse_option): Update to use file_mips_opts instead of mips_opts.
(mips_set_architecture): Delete function.  Moved to...
(mips_after_parse_args): Here.  All logic now applies to
file_mips_opts first and then copies the final state to mips_opts.
Move error checking and defaults inference to mips_check_options and
file_mips_check_options.
(mips_check_options): New static function.  Common option checking for
command line, .module and .set.  Use .module values in error messages
instead of refering to command line options.
(file_mips_check_options): New static function.  A wrapper for
mips_check_options with file_mips_opts.  Updates BFD arch based on
final options.
(s_mipsset): Split into s_mipsset and parse_code_option.  Settings
supported by both .set and .module are moved to parse_code_option.
Warnings and errors are kept in s_mipsset because when
parse_code_option is used with s_module the warnings are deferred
until code is generated.  Any setting supporting 'default' value is
kept in s_mipsset as it is not applicable to s_module. Inferred
settings are also kept in s_mipsset as s_module does not infer any
settings.  Use mips_check_options.
(parse_code_option): New static function derived from s_mipsset.
(s_module): New static function that implements .module.  Allows file
level settings to be changed until code is generated.
(s_cpload, s_cpsetup, s_cplocal): Use file_mips_check_options.
(s_cprestore, s_cpreturn, s_cpadd, mips_address_bytes): Likewise.
(mips_elf_final_processing): Update file_ase to file_mips_opts.ase.
(md_mips_end): Use file_mips_check_options.
* doc/c-mips.texi: Document .module.

gas/testsuite

* gas/mips/mips.exp: Add new tests.  Use 64-bit ABI for relax-bc1any.
Fix micromips arch definition to use mips64r2 consistently.
* gas/mips/module-defer-warn1.s: New.
* gas/mips/module-defer-warn1.d: New.
* gas/mips/module-defer-warn2.s: New.
* gas/mips/module-defer-warn2.l: New.
* gas/mips/module-override.d: New.
* gas/mips/module-override.s: New.
* gas/mips/mips-gp32-fp64.l: Update expected output.
* gas/mips/mips-gp64-fp32-pic.l: Update expected output.
* gas/mips/mips-gp64-fp32.l: Update expected output.

10 years agoRemove newly introduced whitespace from warnings.
mfortune [Tue, 20 May 2014 22:34:19 +0000 (23:34 +0100)] 
Remove newly introduced whitespace from warnings.

* messages.c (as_warn_internal): Remove extra whitespace from
warning messages.

10 years agoMark MSA as requiring FP64
mfortune [Tue, 20 May 2014 11:45:47 +0000 (12:45 +0100)] 
Mark MSA as requiring FP64

gas/
* config/tc-mips.c (FP64_ASES): Add ASE_MSA.
(mips_after_parse_args): Do not select ASE_MSA without -mfp64.

gas/testsuite/

* gas/mips/micromips@msa-branch.d: Rework expected output for fp64.
* gas/mips/msa-branch.d: Likewise.

10 years agold: Add missing eelf32mbel_linux.c to ALL_EMULATION_SOURCES.
Hans-Peter Nilsson [Tue, 20 May 2014 21:13:08 +0000 (23:13 +0200)] 
ld: Add missing eelf32mbel_linux.c to ALL_EMULATION_SOURCES.

ld:
* Makefile.am (ALL_EMULATION_SOURCES): Add missing eelf32mbel_linux.c.
* Makefile.in: Regenerate.

10 years agoFix gdb.multi/base.exp failures.
Doug Evans [Tue, 20 May 2014 20:06:26 +0000 (13:06 -0700)] 
Fix gdb.multi/base.exp failures.

UNRESOLVED: gdb.multi/base.exp: remove-inferiors 2-3
UNRESOLVED: gdb.multi/base.exp: check remove-inferiors

gdb is crashing because it's accessing/freeing already freed memory.

==16368== Invalid read of size 4
==16368==    at 0x660A9D: find_pc_section (binutils-gdb/gdb/objfiles.c:1349)
==16368==    by 0x663ECB: lookup_minimal_symbol_by_pc_section (binutils-gdb/gdb/minsyms.c:734)
==16368==    by 0x5D987A: find_pc_sect_symtab (binutils-gdb/gdb/symtab.c:2153)
==16368==    by 0x5D4D77: blockvector_for_pc_sect (binutils-gdb/gdb/block.c:168)
==16368==    by 0x5D4F59: block_for_pc_sect (binutils-gdb/gdb/block.c:246)
==16368==    by 0x5D4F9B: block_for_pc (binutils-gdb/gdb/block.c:258)
==16368==    by 0x734C5D: inline_frame_sniffer (binutils-gdb/gdb/inline-frame.c:218)
==16368==    by 0x732104: frame_unwind_try_unwinder (binutils-gdb/gdb/frame-unwind.c:108)
==16368==    by 0x73223F: frame_unwind_find_by_frame (binutils-gdb/gdb/frame-unwind.c:159)
==16368==    by 0x72D5AA: compute_frame_id (binutils-gdb/gdb/frame.c:453)
==16368==    by 0x7300EC: get_prev_frame_if_no_cycle (binutils-gdb/gdb/frame.c:1758)
==16368==    by 0x73079A: get_prev_frame_always (binutils-gdb/gdb/frame.c:1931)
==16368==  Address 0x5b13500 is 16 bytes inside a block of size 24 free'd
==16368==    at 0x403072E: free (valgrind/coregrind/m_replacemalloc/vg_replace_malloc.c:445)
==16368==    by 0x762134: xfree (binutils-gdb/gdb/common/common-utils.c:108)
==16368==    by 0x65DACF: objfiles_pspace_data_cleanup (binutils-gdb/gdb/objfiles.c:91)
==16368==    by 0x75E546: program_spaceregistry_callback_adaptor (binutils-gdb/gdb/progspace.c:45)
==16368==    by 0x7644F6: registry_clear_data (binutils-gdb/gdb/registry.c:82)
==16368==    by 0x7645AB: registry_container_free_data (binutils-gdb/gdb/registry.c:95)
==16368==    by 0x75E5B4: program_space_free_data (binutils-gdb/gdb/progspace.c:45)
==16368==    by 0x75E9BA: release_program_space (binutils-gdb/gdb/progspace.c:167)
==16368==    by 0x75EB9B: prune_program_spaces (binutils-gdb/gdb/progspace.c:269)
==16368==    by 0x75303D: remove_inferior_command (binutils-gdb/gdb/inferior.c:792)
==16368==    by 0x50B5FD: do_cfunc (binutils-gdb/gdb/cli/cli-decode.c:107)
==16368==    by 0x50E6F2: cmd_func (binutils-gdb/gdb/cli/cli-decode.c:1886)

The problem originates from the get_current_arch call in
py-progspace.c:py_free_pspace.  The inferior associated with the
pspace is gone, and the current inferior is a different one and is running.
Therefore get_current_arch tries to read the current frame which
causes reads of data in the current program space which we've just deleted.

* python/py-progspace.c (py_free_pspace): Call target_gdbarch
instead of get_current_arch.

10 years ago * messages.c (as_warn_internal): Ensure we don't interleave output
Mike Stump [Tue, 20 May 2014 19:45:30 +0000 (12:45 -0700)] 
* messages.c (as_warn_internal): Ensure we don't interleave output
within a single line when make -j is used.
(as_bad_internal): Likewise.

10 years ago* elf32-msp430.c (msp430_elf_relax_adjust_locals): Avoid overflow.
DJ Delorie [Tue, 20 May 2014 19:42:23 +0000 (15:42 -0400)] 
* elf32-msp430.c (msp430_elf_relax_adjust_locals): Avoid overflow.

10 years agoMake compare-sections work against all targets; add compare-sections [-r] tests.
Pedro Alves [Tue, 20 May 2014 18:11:39 +0000 (19:11 +0100)] 
Make compare-sections work against all targets; add compare-sections [-r] tests.

This does two things:

1. Adds a test.

Recently compare-sections got a new "-r" switch, but given no test
existed for compare-sections, the patch was allowed in with no
testsuite addition.  This now adds a test for both compare-sections
and compare-sections -r.

2. Makes the compare-sections command work against all targets.

Currently, compare-sections only works with remote targets, and only
those that support the qCRC packet.  The patch makes it so that if the
target doesn't support accelerating memory verification, then GDB
falls back to comparing memory itself.  This is of course slower, but
it's better than nothing, IMO.  While testing against extended-remote
GDBserver I noticed that we send the qCRC request to the target if
we're connected, but not yet running a program.  That can't work of
course -- the patch fixes that.  This all also goes in the direction
of bridging the local/remote parity gap.

I didn't decouple 1. from 2., because that would mean that the test
would need to handle the case of the target not supporting the
command.

Tested on x86_64 Fedora 17, native, remote GDBserver, and
extended-remote GDBserver.  I also hack-disabled qCRC support to make
sure the fallback paths in remote.c work.

gdb/doc/
2014-05-20  Pedro Alves  <palves@redhat.com>

* gdb.texinfo (Memory) <compare-sections>: Generalize comments to
not be remote specific.  Add cross reference to the qCRC packet.
(Separate Debug Files): Update cross reference to the qCRC packet.
(General Query Packets) <qCRC packet>: Add anchor.

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

* NEWS: Mention that compare-sections now works with all targets.

* remote.c (PACKET_qCRC): New enum value.
(remote_verify_memory): Don't send qCRC if the target has no
execution.  Use packet_support/packet_ok.  If the target doesn't
support the qCRC packet, fallback to a deep memory copy.
(compare_sections_command): Say "target image" instead of "remote
executable".
(_initialize_remote): Add PACKET_qCRC to the list of config
packets that have no associated command.  Extend comment.
* target.c (simple_verify_memory, default_verify_memory): New
function.
* target.h (struct target_ops) <to_verify_memory>: Default to
default_verify_memory.
(simple_verify_memory): New declaration.
* target-delegates.c: Regenerate.

gdb/testsuite/
2014-05-20  Pedro Alves  <palves@redhat.com>

* gdb.base/compare-sections.c: New file.
* gdb.base/compare-sections.exp: New file.

10 years agogas/
Richard Sandiford [Tue, 20 May 2014 18:02:41 +0000 (19:02 +0100)] 
gas/
* config/obj-elf.h (obj_elf_seen_attribute): Declare.
* config/obj-elf.c (recorded_attribute_info): New structure.
(recorded_attributes): New variable.
(record_attribute, obj_elf_seen_attribute): New functions.
(obj_elf_vendor_attribute): Record which attributes have been seen.

10 years ago[GDBserver] Make Zx/zx packet handling idempotent.
Pedro Alves [Tue, 20 May 2014 17:24:28 +0000 (18:24 +0100)] 
[GDBserver] Make Zx/zx packet handling idempotent.

This patch fixes hardware breakpoint regressions exposed by my fix for
"PR breakpoints/7143 - Watchpoint does not trigger when first set", at
https://sourceware.org/ml/gdb-patches/2014-03/msg00167.html

The testsuite caught them on Linux/x86_64, at least.  gdb.sum:

gdb.sum:

 FAIL: gdb.base/hbreak2.exp: next over recursive call
 FAIL: gdb.base/hbreak2.exp: backtrace from factorial(5.1)
 FAIL: gdb.base/hbreak2.exp: continue until exit at recursive next test

gdb.log:

 (gdb) next

 Program received signal SIGTRAP, Trace/breakpoint trap.
 factorial (value=4) at ../../../src/gdb/testsuite/gdb.base/break.c:113
 113       if (value > 1) {  /* set breakpoint 7 here */
 (gdb) FAIL: gdb.base/hbreak2.exp: next over recursive call

Actually, that patch just exposed a latent issue to "breakpoints
always-inserted off" mode, not really caused it.  After that patch,
GDB no longer removes breakpoints at each internal event, thus making
some scenarios behave like breakpoint always-inserted on.  The bug is
easy to trigger with always-inserted on.

The issue is that since the target-side breakpoint conditions support,
if the stub/server supports evaluating breakpoint conditions on the
target side, then GDB is sending duplicate Zx packets to the target
without removing them before, and GDBserver is not really expecting
that for Z packets other than Z0/z0.  E.g., with "set breakpoint
always-inserted on" and "set debug remote 1":

 (gdb) b main
 Sending packet: $m410943,1#ff...Packet received: 48
 Breakpoint 4 at 0x410943: file ../../../src/gdb/gdbserver/server.c, line 3028.
 Sending packet: $Z0,410943,1#48...Packet received: OK
                 ^^^^^^^^^^^^
 (gdb) b main
 Note: breakpoint 4 also set at pc 0x410943.
 Sending packet: $m410943,1#ff...Packet received: 48
 Breakpoint 5 at 0x410943: file ../../../src/gdb/gdbserver/server.c, line 3028.
 Sending packet: $Z0,410943,1#48...Packet received: OK
                 ^^^^^^^^^^^^
 (gdb) b main
 Note: breakpoints 4 and 5 also set at pc 0x410943.
 Sending packet: $m410943,1#ff...Packet received: 48
 Breakpoint 6 at 0x410943: file ../../../src/gdb/gdbserver/server.c, line 3028.
 Sending packet: $Z0,410943,1#48...Packet received: OK
                 ^^^^^^^^^^^^
 (gdb) del
 Delete all breakpoints? (y or n) y
 Sending packet: $Z0,410943,1#48...Packet received: OK
 Sending packet: $Z0,410943,1#48...Packet received: OK
 Sending packet: $z0,410943,1#68...Packet received: OK

And for Z1, similarly:

 (gdb) hbreak main
 Sending packet: $m410943,1#ff...Packet received: 48
 Hardware assisted breakpoint 4 at 0x410943: file ../../../src/gdb/gdbserver/server.c, line 3028.
 Sending packet: $Z1,410943,1#49...Packet received: OK
                 ^^^^^^^^^^^^
 Packet Z1 (hardware-breakpoint) is supported
 (gdb) hbreak main
 Note: breakpoint 4 also set at pc 0x410943.
 Sending packet: $m410943,1#ff...Packet received: 48
 Hardware assisted breakpoint 5 at 0x410943: file ../../../src/gdb/gdbserver/server.c, line 3028.
 Sending packet: $Z1,410943,1#49...Packet received: OK
                 ^^^^^^^^^^^^
 (gdb) hbreak main
 Note: breakpoints 4 and 5 also set at pc 0x410943.
 Sending packet: $m410943,1#ff...Packet received: 48
 Hardware assisted breakpoint 6 at 0x410943: file ../../../src/gdb/gdbserver/server.c, line 3028.
 Sending packet: $Z1,410943,1#49...Packet received: OK
                 ^^^^^^^^^^^^
 (gdb) del
 Delete all breakpoints? (y or n) y
 Sending packet: $Z1,410943,1#49...Packet received: OK
                 ^^^^^^^^^^^^
 Sending packet: $Z1,410943,1#49...Packet received: OK
                 ^^^^^^^^^^^^
 Sending packet: $z1,410943,1#69...Packet received: OK
                 ^^^^^^^^^^^^

So GDB sent a bunch of Z1 packets, and then when finally removing the
breakpoint, only one z1 packet was sent.  On the GDBserver side (with
monitor set debug-hw-points 1), in the Z1 case, we see:

 $ ./gdbserver :9999 ./gdbserver
 Process ./gdbserver created; pid = 8629
 Listening on port 9999
 Remote debugging from host 127.0.0.1
 insert_watchpoint (addr=410943, len=1, type=instruction-execute):
 CONTROL (DR7): 00000101          STATUS (DR6): 00000000
 DR0: addr=0x410943, ref.count=1  DR1: addr=0x0, ref.count=0
 DR2: addr=0x0, ref.count=0  DR3: addr=0x0, ref.count=0
 insert_watchpoint (addr=410943, len=1, type=instruction-execute):
 CONTROL (DR7): 00000101          STATUS (DR6): 00000000
 DR0: addr=0x410943, ref.count=2  DR1: addr=0x0, ref.count=0
 DR2: addr=0x0, ref.count=0  DR3: addr=0x0, ref.count=0
 insert_watchpoint (addr=410943, len=1, type=instruction-execute):
 CONTROL (DR7): 00000101          STATUS (DR6): 00000000
 DR0: addr=0x410943, ref.count=3  DR1: addr=0x0, ref.count=0
 DR2: addr=0x0, ref.count=0  DR3: addr=0x0, ref.count=0
 insert_watchpoint (addr=410943, len=1, type=instruction-execute):
 CONTROL (DR7): 00000101          STATUS (DR6): 00000000
 DR0: addr=0x410943, ref.count=4  DR1: addr=0x0, ref.count=0
 DR2: addr=0x0, ref.count=0  DR3: addr=0x0, ref.count=0
 insert_watchpoint (addr=410943, len=1, type=instruction-execute):
 CONTROL (DR7): 00000101          STATUS (DR6): 00000000
 DR0: addr=0x410943, ref.count=5  DR1: addr=0x0, ref.count=0
 DR2: addr=0x0, ref.count=0  DR3: addr=0x0, ref.count=0
 remove_watchpoint (addr=410943, len=1, type=instruction-execute):
 CONTROL (DR7): 00000101          STATUS (DR6): 00000000
 DR0: addr=0x410943, ref.count=4  DR1: addr=0x0, ref.count=0
 DR2: addr=0x0, ref.count=0  DR3: addr=0x0, ref.count=0

That's one insert_watchpoint call for each Z1 packet, and then one
remove_watchpoint call for the z1 packet.  Notice how ref.count
increased for each insert_watchpoint call, and then in the end, after
GDB told GDBserver to forget about the hardware breakpoint, GDBserver
ends with the the first debug register still with ref.count=4!  IOW,
the hardware breakpoint is left armed on the target, while on the GDB
end it's gone.  If the program happens to execute 0x410943 afterwards,
then the CPU traps, GDBserver reports the trap to GDB, and GDB not
having a breakpoint set at that address anymore, reports to the user a
spurious SIGTRAP.

This is exactly what is happening in the hbreak2.exp test, though in
that case, it's a shared library event that triggers a
breakpoint_re_set, when breakpoints are still inserted (because
nowadays GDB doesn't remove breakpoints while handling internal
events), and that recreates breakpoint locations, which likewise
forces breakpoint reinsertion and Zx packet resends...

That is a lot of bogus Zx duplication that should possibly be
addressed on the GDB side.  GDB resends Zx packets because the way to
change the target-side condition, is to resend the breakpoint to the
server with the new condition.  (That's an option in the packet: e.g.,
"Z1,410943,1;X3,220027" for "hbreak main if 0".  The packets in the
examples above are shorter because the breakpoints don't have
conditions attached).  GDB doesn't remove the breakpoint first before
reinserting it because that'd be bad for non-stop, as it'd open a
window where the inferior could miss the breakpoint.  The conditions
actually haven't changed between the resends, but GDB isn't smart
enough to realize that.

(TBC, if the target doesn't support target-side conditions, then GDB
doesn't trigger these resends (init_bp_location calls
mark_breakpoint_location_modified, and that does nothing if condition
evaluation is on the host side.  The resends are caused by the
'loc->condition_changed = condition_modified.'  line.)

But, even if GDB was made smarter, GDBserver should really still
handle the resends anyway.  So target-side conditions also aren't
really to blame.  The documentation of the Z/z packets says:

 "To avoid potential problems with duplicate packets, the operations
 should be implemented in an idempotent way."

As such, we may want to fix GDB, but we should definitely fix
GDBserver.  The fix is a prerequisite for target-side conditions on
hardware breakpoints anyway (and while at it, on watchpoints too).

GDBserver indeed already treats duplicate Z0 packets in an idempotent
way.  mem-break.c has the concept of high-level and low-level
breakpoints, somewhat similar to GDB's split of breakpoints vs
breakpoint locations, and keeps track of multiple breakpoints
referencing the same address/location, for the case of an internal
GDBserver breakpoint or a tracepoint being set at the same address as
a GDB breakpoint.  But, it only allows GDB to ever contribute one
reference to a software breakpoint location.  IOW, if gdbserver sees a
Z0 packet for the same address where it already had a GDB breakpoint
set, then GDBserver won't create another high-level GDB breakpoint.

However, mem-break.c only tracks GDB Z0 breakpoints.  The same logic
should apply to all kinds of Zx packets.  Currently, gdbserver passes
down each duplicate Zx (other than Z0) request directly to the
target->insert_point routine.  The x86 watchpoint support itself
refcounts watchpoint / hw breakpoint requests, to handle overlapping
watchpoints, and save debug registers.  But that code doesn't (and
really shouldn't) handle the duplicate requests, assuming that for
each insert there will be a corresponding remove.

So the fix is to generalize mem-break.c to track all kinds of Zx
breakpoints, and filter out duplicates.  As mentioned, this ends up
adding support for target-side conditions on hardware breakpoints and
watchpoints too (though GDB itself doesn't support the latter yet).

Probably the least obvious change in the patch is that it kind of
turns the breakpoint insert/remove APIs inside out.  Before, the
target methods were only called for GDB breakpoints.  The internal
breakpoint set/delete methods inserted memory breakpoints directly
bypassing the insert/remove target methods.  That's not good when the
target should use a debug API to set software breakpoints, instead of
relying on GDBserver patching memory with breakpoint instructions, as
is the case of NTO.

Now removal/insertion of all kinds of breakpoints/watchpoints, either
internal, or from GDB, always go through the target methods.  The
insert_point/remove_point methods no longer get passed a Z packet
type, but an internal/raw breakpoint type.  They're also passed a
pointer to the raw breakpoint itself (note that's still opaque outside
mem-break.c), so that insert_memory_breakpoint /
remove_memory_breakpoint have access to the breakpoint's shadow
buffer.  I first tried passing down a new structure based on GDB's
"struct bp_target_info" (actually with that name exactly), but then
decided against it as unnecessary complication.

As software/memory breakpoints work by poking at memory, when setting
a GDB Z0 breakpoint (but not internal breakpoints, as those can assume
the conditions are already right), we need to tell the target to
prepare to access memory (which on Linux means stop threads).  If that
operation fails, we need to return error to GDB.  Seeing an error, if
this is the first breakpoint of that type that GDB tries to insert,
GDB would then assume the breakpoint type is supported, but it may
actually not be.  So we need to check whether the type is supported at
all before preparing to access memory.  And to solve that, the patch
adds a new target->supports_z_point_type method that is called before
actually trying to insert the breakpoint.

Other than that, hopefully the change is more or less obvious.

New test added that exercises the hbreak2.exp regression in a more
direct way, without relying on a breakpoint re-set happening before
main is reached.

Tested by building GDBserver for:

 aarch64-linux-gnu
 arm-linux-gnueabihf
 i686-pc-linux-gnu
 i686-w64-mingw32
 m68k-linux-gnu
 mips-linux-gnu
 mips-uclinux
 nios2-linux-gnu
 powerpc-linux-gnu
 sh-linux-gnu
 tilegx-unknown-linux-gnu
 x86_64-redhat-linux
 x86_64-w64-mingw32

And also regression tested on x86_64 Fedora 20.

gdb/gdbserver/
2014-05-20  Pedro Alves  <palves@redhat.com>

* linux-aarch64-low.c (aarch64_insert_point)
(aarch64_remove_point): No longer check whether the type is
supported here.  Adjust to new interface.
(the_low_target): Install aarch64_supports_z_point_type as
supports_z_point_type method.
* linux-arm-low.c (raw_bkpt_type_to_arm_hwbp_type): New function.
(arm_linux_hw_point_initialize): Take an enum raw_bkpt_type
instead of a Z packet char.  Adjust.
(arm_supports_z_point_type): New function.
(arm_insert_point, arm_remove_point): Adjust to new interface.
(the_low_target): Install arm_supports_z_point_type.
* linux-crisv32-low.c (cris_supports_z_point_type): New function.
(cris_insert_point, cris_remove_point): Adjust to new interface.
Don't check whether the type is supported here.
(the_low_target): Install cris_supports_z_point_type.
* linux-low.c (linux_supports_z_point_type): New function.
(linux_insert_point, linux_remove_point): Adjust to new interface.
* linux-low.h (struct linux_target_ops) <insert_point,
remove_point>: Take an enum raw_bkpt_type instead of a char.  Add
raw_breakpoint pointer parameter.
<supports_z_point_type>: New method.
* linux-mips-low.c (mips_supports_z_point_type): New function.
(mips_insert_point, mips_remove_point): Adjust to new interface.
Use mips_supports_z_point_type.
(the_low_target): Install mips_supports_z_point_type.
* linux-ppc-low.c (the_low_target): Install NULL as
supports_z_point_type method.
* linux-s390-low.c (the_low_target): Install NULL as
supports_z_point_type method.
* linux-sparc-low.c (the_low_target): Install NULL as
supports_z_point_type method.
* linux-x86-low.c (x86_supports_z_point_type): New function.
(x86_insert_point): Adjust to new insert_point interface.  Use
insert_memory_breakpoint.  Adjust to new
i386_low_insert_watchpoint interface.
(x86_remove_point): Adjust to remove_point interface.  Use
remove_memory_breakpoint.  Adjust to new
i386_low_remove_watchpoint interface.
(the_low_target): Install x86_supports_z_point_type.
* lynx-low.c (lynx_target_ops): Install NULL as
supports_z_point_type callback.
* nto-low.c (nto_supports_z_point_type): New.
(nto_insert_point, nto_remove_point): Adjust to new interface.
(nto_target_ops): Install nto_supports_z_point_type.
* mem-break.c: Adjust intro comment.
(struct raw_breakpoint) <raw_type, size>: New fields.
<inserted>: Update comment.
<shlib_disabled>: Delete field.
(enum bkpt_type) <gdb_breakpoint>: Delete value.
<gdb_breakpoint_Z0, gdb_breakpoint_Z1, gdb_breakpoint_Z2,
gdb_breakpoint_Z3, gdb_breakpoint_Z4>: New values.
(raw_bkpt_type_to_target_hw_bp_type): New function.
(find_enabled_raw_code_breakpoint_at): New function.
(find_raw_breakpoint_at): New type and size parameters.  Use them.
(insert_memory_breakpoint): New function, based off
set_raw_breakpoint_at.
(remove_memory_breakpoint): New function.
(set_raw_breakpoint_at): Reimplement.
(set_breakpoint): New, based on set_breakpoint_at.
(set_breakpoint_at): Reimplement.
(delete_raw_breakpoint): Go through the_target->remove_point
instead of assuming memory breakpoints.
(find_gdb_breakpoint_at): Delete.
(Z_packet_to_bkpt_type, Z_packet_to_raw_bkpt_type): New functions.
(find_gdb_breakpoint): New function.
(set_gdb_breakpoint_at): Delete.
(z_type_supported): New function.
(set_gdb_breakpoint_1): New function, loosely based off
set_gdb_breakpoint_at.
(check_gdb_bp_preconditions, set_gdb_breakpoint): New functions.
(delete_gdb_breakpoint_at): Delete.
(delete_gdb_breakpoint_1): New function, loosely based off
delete_gdb_breakpoint_at.
(delete_gdb_breakpoint): New function.
(clear_gdb_breakpoint_conditions): Rename to ...
(clear_breakpoint_conditions): ... this.  Don't handle a NULL
breakpoint.
(add_condition_to_breakpoint): Make static.
(add_breakpoint_condition): Take a struct breakpoint pointer
instead of an address.  Adjust.
(gdb_condition_true_at_breakpoint): Rename to ...
(gdb_condition_true_at_breakpoint_z_type): ... this, and add
z_type parameter.
(gdb_condition_true_at_breakpoint): Reimplement.
(add_breakpoint_commands): Take a struct breakpoint pointer
instead of an address.  Adjust.
(gdb_no_commands_at_breakpoint): Rename to ...
(gdb_no_commands_at_breakpoint_z_type): ... this.  Add z_type
parameter.  Return true if no breakpoint was found.  Change debug
output.
(gdb_no_commands_at_breakpoint): Reimplement.
(run_breakpoint_commands): Rename to ...
(run_breakpoint_commands_z_type): ... this.  Add z_type parameter,
and change return type to boolean.
(run_breakpoint_commands): New function.
(gdb_breakpoint_here): Also check for Z1 breakpoints.
(uninsert_raw_breakpoint): Don't try to reinsert a disabled
breakpoint.  Go through the_target->remove_point instead of
assuming memory breakpoint.
(uninsert_breakpoints_at, uninsert_all_breakpoints): Uninsert
software and hardware breakpoints.
(reinsert_raw_breakpoint): Go through the_target->insert_point
instead of assuming memory breakpoint.
(reinsert_breakpoints_at, reinsert_all_breakpoints): Reinsert
software and hardware breakpoints.
(check_breakpoints, breakpoint_here, breakpoint_inserted_here):
Check both software and hardware breakpoints.
(validate_inserted_breakpoint): Assert the breakpoint is a
software breakpoint.  Set the inserted flag to -1 instead of
setting shlib_disabled.
(delete_disabled_breakpoints): Adjust.
(validate_breakpoints): Only validate software breakpoints.
Adjust to inserted flag change.
(check_mem_read, check_mem_write): Skip breakpoint types other
than software breakpoints.  Adjust to inserted flag change.
* mem-break.h (enum raw_bkpt_type): New enum.
(raw_breakpoint, struct process_info): Forward declare.
(Z_packet_to_target_hw_bp_type): Delete declaration.
(raw_bkpt_type_to_target_hw_bp_type, Z_packet_to_raw_bkpt_type)
(set_gdb_breakpoint, delete_gdb_breakpoint)
(clear_breakpoint_conditions): New declarations.
(set_gdb_breakpoint_at, clear_gdb_breakpoint_conditions): Delete.
(breakpoint_inserted_here): Update comment.
(add_breakpoint_condition, add_breakpoint_commands): Replace
address parameter with a breakpoint pointer parameter.
(gdb_breakpoint_here): Update comment.
(delete_gdb_breakpoint_at): Delete.
(insert_memory_breakpoint, remove_memory_breakpoint): Declare.
* server.c (process_point_options): Take a struct breakpoint
pointer instead of an address.  Adjust.
(process_serial_event) <Z/z packets>: Use set_gdb_breakpoint and
delete_gdb_breakpoint.
* spu-low.c (spu_target_ops): Install NULL as
supports_z_point_type method.
* target.h: Include mem-break.h.
(struct target_ops) <prepare_to_access_memory>: Update comment.
<supports_z_point_type>: New field.
<insert_point, remove_point>: Take an enum raw_bkpt_type argument
instead of a char.  Also take a raw breakpoint pointer.
* win32-arm-low.c (the_low_target): Install NULL as
supports_z_point_type.
* win32-i386-low.c (i386_supports_z_point_type): New function.
(i386_insert_point, i386_remove_point): Adjust to new interface.
(the_low_target): Install i386_supports_z_point_type.
* win32-low.c (win32_supports_z_point_type): New function.
(win32_insert_point, win32_remove_point): Adjust to new interface.
(win32_target_ops): Install win32_supports_z_point_type.
* win32-low.h (struct win32_target_ops):
<supports_z_point_type>: New method.
<insert_point, remove_point>: Take an enum raw_bkpt_type argument
instead of a char.  Also take a raw breakpoint pointer.

gdb/testsuite/
2014-05-20  Pedro Alves  <palves@redhat.com>

* gdb.base/break-idempotent.c: New file.
* gdb.base/break-idempotent.exp: New file.

10 years ago[GDBserver] Move Z packet defines and type convertion routines to shared code.
Pedro Alves [Tue, 20 May 2014 17:24:27 +0000 (18:24 +0100)] 
[GDBserver] Move Z packet defines and type convertion routines to shared code.

The Aarch64, MIPS and x86 Linux backends all have Z packet number
defines and corresponding protocol number to internal type convertion
routines.  Factor them all out to gdbserver's core code, so we only
have one shared copy.

Tested on x86_64 Fedora 20, and also cross built for aarch64-linux-gnu
and mips-linux-gnu.

gdb/gdbserver/
2014-05-20  Pedro Alves  <palves@redhat.com>

* mem-break.h: Include break-common.h.
(Z_PACKET_SW_BP, Z_PACKET_HW_BP, Z_PACKET_WRITE_WP)
(Z_PACKET_READ_WP, Z_PACKET_ACCESS_WP): New defines.
(Z_packet_to_target_hw_bp_type): New declaration.
* mem-break.c (Z_packet_to_target_hw_bp_type): New function.
* i386-low.c (Z_PACKET_HW_BP, Z_PACKET_WRITE_WP, Z_PACKET_READ_WP)
(Z_PACKET_ACCESS_WP): Delete macros.
(Z_packet_to_hw_type): Delete function.
* i386-low.h: Don't include break-common.h here.
(Z_packet_to_hw_type): Delete declaration.
* linux-x86-low.c (x86_insert_point, x86_insert_point): Call
Z_packet_to_target_hw_bp_type instead of Z_packet_to_hw_type.
* win32-i386-low.c (i386_insert_point, i386_remove_point): Call
Z_packet_to_target_hw_bp_type instead of Z_packet_to_hw_type.
* linux-aarch64-low.c: Don't include break-common.h here.
(Z_PACKET_SW_BP, Z_PACKET_HW_BP, Z_PACKET_WRITE_WP)
(Z_PACKET_READ_WP, Z_PACKET_ACCESS_WP): Delete macros.
(Z_packet_to_target_hw_bp_type): Delete function.
* linux-mips-low.c (rsp_bp_type_to_target_hw_bp_type): Delete
function.
(mips_insert_point, mips_remove_point): Use
Z_packet_to_target_hw_bp_type.

10 years ago[GDBserver][AArch64] Make watchpoint support use target_hw_bp_type.
Pedro Alves [Tue, 20 May 2014 17:24:27 +0000 (18:24 +0100)] 
[GDBserver][AArch64] Make watchpoint support use target_hw_bp_type.

This makes linux-aarch64-low.c use target_hw_bp_type, like gdb's
aarch64-linux-nat.c.  The original motivation is decoupling
insert_point/remove_point from Z packet numbers, but I think making
the files a little bit more similar is a good thing on its own right.
Ideally we'd merge these files even...  The
aarch64_point_encode_ctrl_reg change is taken straight from GDB's
copy.

I confirmed with a cross compiler that this builds, but it's otherwise
untested.

gdb/gdbserver/
2014-05-20  Pedro Alves  <palves@redhat.com>

* linux-aarch64-low.c: Include break-common.h.
(enum target_point_type): Delete.
(Z_packet_to_point_type): Rename to ...
(Z_packet_to_target_hw_bp_type): ... this, and return a
target_hw_bp_type instead.
(aarch64_show_debug_reg_state): Take an enum target_hw_bp_type
instead of an enum target_point_type.
(aarch64_point_encode_ctrl_reg): Likewise.  Compute type mask from
breakpoint type.
(aarch64_dr_state_insert_one_point)
(aarch64_dr_state_remove_one_point, aarch64_handle_breakpoint)
(aarch64_handle_aligned_watchpoint)
(aarch64_handle_unaligned_watchpoint, aarch64_handle_watchpoint):
Take an enum target_hw_bp_type instead of an enum
target_point_type.
(aarch64_supports_z_point_type): New function.
(aarch64_insert_point, aarch64_remove_point): Use it.  Adjust to
use Z_packet_to_target_hw_bp_type.

10 years agoDo not build gdbserver with -Werror by default if development=false
Joel Brobecker [Mon, 19 May 2014 21:16:24 +0000 (14:16 -0700)] 
Do not build gdbserver with -Werror by default if development=false

On GDB release branches, we change $development in gdb/development.sh
to false, in order to build the GDB release without -Werror by default,
thus avoiding harmless compiler warnings from breaking the build of
someone who's only interested in building GDB rather than working
on it.

This patch implements the same strategy for gdbserver, using the exact
same method.

gdb/gdbserver/ChangeLog:

        * configure.ac: Only use -Werror by default when DEVELOPMENT
        is true.
        * configure: Regenerate.

Tested on x86_64-linux, by rebuilding GDBserver first with development
set to true, and then doing it again with development set to false.
Werror was used in the first case, but not in the second.

10 years agobtrace: no replay without history
Markus Metzger [Thu, 15 May 2014 08:57:36 +0000 (10:57 +0200)] 
btrace: no replay without history

When using a reverse execution command without execution history, GDB
might end up in a state where replaying has been started but remains
at the current instruction.  This state is illegal.

Do not step if there is no execution history to avoid this.

2014-05-20  Markus Metzger  <markus.t.metzger@intel.com>

* record-btrace.c (record_btrace_step_thread): Check for empty history.

testsuite/
* gdb.btrace/nohist.exp: New.

10 years agoFix MSP430 assembler to support #hi(<symbol>).
Nick Clifton [Tue, 20 May 2014 09:28:42 +0000 (10:28 +0100)] 
Fix MSP430 assembler to support #hi(<symbol>).

* config/tc-msp430.c (CHECK_RELOC_MSP430): Add OP parameter.
Generate BFD_RELOC_MSP430_ABS_HI16 if vshift is 1.
(msp430_srcoperand): Store vshift value in operand.

* msp430.h (struct msp430_operand_s): Add vshift field.

* gas/elf/struct.d: Expect extra output from some toolchains.
* gas/symver/symver0.d: Likewise.
* gas/symver/symver1.d: Likewise.

10 years agold/aarch64: xfail non-PIC shared object tests on aarch64
Will Newton [Fri, 16 May 2014 14:22:58 +0000 (15:22 +0100)] 
ld/aarch64: xfail non-PIC shared object tests on aarch64

aarch64 does not support building non-PIC shared objects, so mark
tests for these as xfail.

ld/testsuite/ChangeLog:

2014-05-20  Will Newton  <will.newton@linaro.org>

* ld-shared/shared.exp: Mark non-PIC shared object tests
as xfail on aarch64.

10 years agoSet timeout for gdb.reverse/*.exp test cases
Yao Qi [Fri, 9 May 2014 07:06:12 +0000 (15:06 +0800)] 
Set timeout for gdb.reverse/*.exp test cases

Hi,
This patch is to add a new board setting gdb_reverse_timeout, which is
used to set timeout for all gdb.reverse test cases, which are usually
very slow and cause some TIMEOUT failures, for example, on some arm
boards.  We have some alternatives to this approach, but I am not
satisfied with them:

 - Increase the timeout value.  This is the global change, and it may
   cause some delay where actual failures happen.
 - Set timeout by gdb_reverse_timeout in every gdb.reverse/*.exp.
   Then, we have to touch every file under gdb.reverse.

In this patch, we choose a central place to set timeout for all tests
in gdb.reverse, which is convenient.

gdb/testsuite:

2014-05-20  Yao Qi  <yao@codesourcery.com>

* lib/gdb.exp (gdb_init): Set timeout if test file is under
gdb.reverse directory and gdb_reverse_timeout exists in board
setting.
* README: Document gdb_reverse_timeout.

10 years agogdb_init argument ARGS is a string rather than a list
Yao Qi [Fri, 9 May 2014 03:01:07 +0000 (11:01 +0800)] 
gdb_init argument ARGS is a string rather than a list

The argument ARGS of gdb_init is passed from dejagnu is a string, the
test file name.  In dejagnu/runtest.exp:

proc runtest { test_file_name } {
....
....
        if [info exists tool] {
            if { [info procs "${tool}_init"] != "" } {
                ${tool}_init $test_file_name;
            }
        }
....
}

but inn default_gdb_init (callee of gdb_init), we have

    set gdb_test_file_name [file rootname [file tail [lindex $args 0]]]

In tcl, all actual arguments are combined to a list and assigned to
args.  This code here isn't wrong, but unnecessary, because its caller
(proc runtest) only passes one string to it, and IMO, we don't need
such tricky tcl "args".

I doubt that "[lindex $args 0]" is to be backward compatible with old
dejagnu, but dejagnu-1.4 release started to pass $test_file_name to
${too}_init, as I showed above.  dejagnu-1.4 was released in 2001, and
it should be old enough.  I also tried to check whether gdb testusite
works with dejagnu-1.3 or not, but failed to build dejagnu-1.3 on my
machine.  Supposing GDB testsuite requires at least dejagnu-1.4, this
change should be safe.

This patch is update default_gdb_init to treat ARGS as a string instead
of a list.  Then, 'args' sounds like a list, and this patch also renames
it by 'test_file_name', to align with dejagnu.

gdb/testsuite:

2014-05-20  Yao Qi  <yao@codesourcery.com>

* lib/gdb.exp (default_gdb_init): Rename argument 'args' by
'test_file_name'.  Treat args as a string instead of a list.
(gdb_init): Rename argument 'args' by 'test_file_name'.

10 years agoFix issue #15778: GDB Aarch64 signal frame unwinder issue
Hui Zhu [Tue, 20 May 2014 05:19:06 +0000 (13:19 +0800)] 
Fix issue #15778: GDB Aarch64 signal frame unwinder issue

The root cause of this issue is unwinder of "#3  <signal handler called>"
doesn't supply right values of registers.
When GDB want to get the previous frame of "#3  <signal handler called>",
it will call cache init function of unwinder "aarch64_linux_sigframe_init".
The address or the value of the registers is get from this function.
So the bug is inside thie function.

I check the asm code of "#3  <signal handler called>":
(gdb) frame 3
(gdb) p $pc
$1 = (void (*)()) 0x7f931fa4d0
(gdb) disassemble $pc, +10
Dump of assembler code from 0x7f931fa4d0 to 0x7f931fa4da:
=> 0x0000007f931fa4d0: mov x8, #0x8b                   // #139
   0x0000007f931fa4d4: svc #0x0
   0x0000007f931fa4d8: nop

This is the syscall sys_rt_sigreturn, Linux kernel function "restore_sigframe"
will set the frame:
for (i = 0; i < 31; i++)
__get_user_error(regs->regs[i], &sf->uc.uc_mcontext.regs[i],
 err);
__get_user_error(regs->sp, &sf->uc.uc_mcontext.sp, err);
__get_user_error(regs->pc, &sf->uc.uc_mcontext.pc, err);
The struct of uc_mcontext is:
struct sigcontext {
__u64 fault_address;
/* AArch64 registers */
__u64 regs[31];
__u64 sp;
__u64 pc;
__u64 pstate;
/* 4K reserved for FP/SIMD state and future expansion */
__u8 __reserved[4096] __attribute__((__aligned__(16)));
};

But in GDB function "aarch64_linux_sigframe_init", the code the get address
of registers is:
  for (i = 0; i < 31; i++)
    {
      trad_frame_set_reg_addr (this_cache,
       AARCH64_X0_REGNUM + i,
       sigcontext_addr + AARCH64_SIGCONTEXT_XO_OFFSET
       + i * AARCH64_SIGCONTEXT_REG_SIZE);
    }

  trad_frame_set_reg_addr (this_cache, AARCH64_FP_REGNUM, fp);
  trad_frame_set_reg_addr (this_cache, AARCH64_LR_REGNUM, fp + 8);
  trad_frame_set_reg_addr (this_cache, AARCH64_PC_REGNUM, fp + 8);

The code that get pc and sp is not right, so I change the code according
to Linux kernel code:
  trad_frame_set_reg_addr (this_cache, AARCH64_SP_REGNUM,
   sigcontext_addr + AARCH64_SIGCONTEXT_XO_OFFSET
     + 31 * AARCH64_SIGCONTEXT_REG_SIZE);
  trad_frame_set_reg_addr (this_cache, AARCH64_PC_REGNUM,
   sigcontext_addr + AARCH64_SIGCONTEXT_XO_OFFSET
     + 32 * AARCH64_SIGCONTEXT_REG_SIZE);

The issue was fixed by this change, and I did the regression test.  It
also fixed a lot of other XFAIL and FAIL.

2014-05-20  Hui Zhu  <hui@codesourcery.com>
    Yao Qi  <yao@codesourcery.com>

PR backtrace/16558
* aarch64-linux-tdep.c (aarch64_linux_sigframe_init): Update comments
and change address of sp and pc.

10 years agoRemove unnecessary header from m68k-dis.c
Alan Modra [Tue, 20 May 2014 03:45:18 +0000 (13:15 +0930)] 
Remove unnecessary header from m68k-dis.c

* m68k-dis.c: Don't include setjmp.h.

10 years agoRewrite ppc32 backend .sdata and .sdata2 handling
Alan Modra [Tue, 20 May 2014 02:12:42 +0000 (11:42 +0930)] 
Rewrite ppc32 backend .sdata and .sdata2 handling

1) _SDA_BASE_ and _SDA2_BASE_ and defined automatically, in a similar
   manner to the way _GLOBAL_OFFSET_TABLE_ is handled.  It's a little
   more complicated to remove the symbols because _SDA_BASE_ needs to
   be there if either .sdata or .sbss is present, and similarly for
   _SDA2_BASE.
2) The linker created .sdata and .sdata2 sections used for
   R_PPC_EMB_SDAI16 and R_PPC_EMB_SDA2I16 pointers are created early.
   Nowadays we strip unneeded sections from the output, so it isn't
   necessary to delay creating the sections.
3) The output section for targets of various SDA relocs is now checked
   as per the ABI(s).  We previously allowed .sdata.foo and similar,
   most likely because at some stage we were checking input sections.

Also, the patch fixes a long-standing bug in size_input_sections
that affects the values of symbols defined in stripped input
sections.

PR 16952
bfd/
* elf32-ppc.c (ppc_elf_create_linker_section): Move earlier.
Remove redundant setting of htab->elf.dynobj.  Don't align.
Define .sdata symbols using _bfd_elf_define_linkage_sym.
(ppc_elf_create_glink): Call ppc_elf_create_linker_section.
(create_sdata_sym): Delete.
(elf_allocate_pointer_linker_section): Rename from
elf_create_pointer_linker_section.  Align section.
(ppc_elf_check_relocs): Don't call ppc_elf_creat_linker_section
directly here, or create_sdata_sym.  Set ref_regular on _SDA_BASE_
and _SDA2_BASE_.
(ppc_elf_size_dynamic_sections): Remove ATTRIBUTE_UNUSED on param.
Remove unnecessary tests on _SDA_BASE_ sym.
(maybe_strip_sdasym, ppc_elf_maybe_strip_sdata_syms): New functions.
(ppc_elf_relocate_section): Tighten SDA reloc symbol section checks.
* elf32-ppc.h (ppc_elf_set_sdata_syms): Delete.
(ppc_elf_maybe_strip_sdata_syms): Declare.
ld/
* emulparams/elf32ppccommon.sh (_SDA_BASE_, _SDA2_BASE_): Delete.
* emultempl/ppc32elf.em (ppc_before_allocation): Call
ppc_elf_maybe_strip_sdata_syms.
* ldlang.c (size_input_section): Correct output_offset value
for excluded input sections.

10 years agodaily update
Alan Modra [Tue, 20 May 2014 00:00:38 +0000 (09:30 +0930)] 
daily update

10 years agobuild_type_unit_groups and moved closer to only caller and renamed
Doug Evans [Mon, 19 May 2014 23:05:01 +0000 (16:05 -0700)] 
build_type_unit_groups and moved closer to only caller and renamed

* dwarf2read.c (build_type_psymtabs_1): Renamed from
build_type_unit_groups and moved closer to only caller.  Remove
arguments.  All references updated.  Remove outdated .gdb_index
comment.
(struct tu_abbrev_offset, sort_tu_by_abbrev_offset): Move with
build_type_psymtabs_1.

10 years agofix two latent type errors
Tom Tromey [Mon, 19 May 2014 19:10:21 +0000 (13:10 -0600)] 
fix two latent type errors

I'm checking this in as obvious.

I was looking at instances of "alloc.*sizeof" and noticed a couple
where the types in question are incorrect.

In gdbtypes, the code allocates sizeof(int) to represent a struct rank.
In mi-cmds, the code uses "struct mi_cmd **" -- one "*" too many.

In both cases the problems are latent because in practice the sizes
are the same as the sizes of the correct types.  Still, it's better to
be correct.

I think gdb would be improved by a wholesale change from explicit
sizeofs to using the libiberty.h allocation macros.  In most cases
they are both shorter and have better type safety.  However, the
resulting patch is rather large.

Built and regtested on x86-64 Fedora 20.

2014-05-19  Tom Tromey  <tromey@redhat.com>

* gdbtypes.c (rank_function): Use XNEWVEC.
* mi/mi-cmds.c (build_table): Use XCNEWVEC.

10 years agoRemove all_type_unit_groups, unused.
Doug Evans [Mon, 19 May 2014 19:50:44 +0000 (12:50 -0700)] 
Remove all_type_unit_groups, unused.

* dwarf2read.c (struct dwarf2_per_objfile): Delete unused members
n_type_unit_groups, all_type_unit_groups.  All uses removed.
(get_type_unit_group, build_type_unit_groups): Delete forward decls.
(dw2_get_cutu): Renamed from dw2_get_cu.  All callers updated.
(dw2_get_cu): Renamed from dw2_get_primary_cu.  All callers updated.
(add_type_unit_group_to_table): Delete.

10 years agoFix gdbserver qGetTLSAddr for x86_64 -m32
Jan Kratochvil [Mon, 19 May 2014 18:20:27 +0000 (20:20 +0200)] 
Fix gdbserver qGetTLSAddr for x86_64 -m32

gdbserver makes libthread_db to access uninitialized memory.  Surprisingly it
does not harm normally, even -fsanitize=address works with current gdbserver.
I have found just valgrind detects it as a very first warning for gdbserver:

Syscall param ptrace(addr) contains uninitialised byte(s)
   at 0x3721EECEBE: ptrace (ptrace.c:45)
   by 0x436EE5: ps_get_thread_area (linux-x86-low.c:252)
   by 0x5559D02: __td_ta_lookup_th_unique (td_ta_map_lwp2thr.c:157)
   by 0x5559EC3: td_ta_map_lwp2thr (td_ta_map_lwp2thr.c:207)
   by 0x43F87D: find_one_thread (thread-db.c:281)
   by 0x440038: thread_db_get_tls_address (thread-db.c:505)
   by 0x40F6D0: handle_query (server.c:2004)
   by 0x4124CF: process_serial_event (server.c:3445)
   by 0x4136B6: handle_serial_event (server.c:3889)
   by 0x419571: handle_file_event (event-loop.c:434)
   by 0x418D38: process_event (event-loop.c:189)
   by 0x419AB7: start_event_loop (event-loop.c:552)

Reproducible with:
cd gdb/testsuite
g++ -o gdb.threads/tls gdb.threads/tls{,2}.c -m32 -pthread
../gdbserver/gdbserver :1234 gdb.threads/tls
../gdb -batch gdb.threads/tls -ex 'target remote :1234' -ex 'b spin' -ex c -ex 'p a_thread_local'

It is more easily reproducible even without valgrind using s/0x00/0xff/ in the
attached patch.  It will then turn the output of reproducer above:
$1 = 0
->
Cannot find thread-local storage for Thread 29044, executable file .../gdb/testsuite/gdb.threads/tls:
Remote target failed to process qGetTLSAddr request

gdb/gdbserver/
2014-05-19  Jan Kratochvil  <jan.kratochvil@redhat.com>

Fix gdbserver qGetTLSAddr for x86_64 -m32.
* linux-x86-low.c (X86_64_USER_REGS): New.
(x86_fill_gregset): Call memset for BUF first in x86_64 -m32 case.

Message-ID: <20140410114901.GA16411@host2.jankratochvil.net>

10 years ago* eval.c (evaluate_subexp_standard): Add some comments.
Doug Evans [Mon, 19 May 2014 17:51:08 +0000 (10:51 -0700)] 
* eval.c (evaluate_subexp_standard): Add some comments.

10 years ago[testsuite patch] Test power{5,6,7} disassembly
Jan Kratochvil [Mon, 19 May 2014 13:39:24 +0000 (15:39 +0200)] 
[testsuite patch] Test power{5,6,7} disassembly

Power5, Power6 and Power7 disassembly testing.

gdb/testsuite/
2014-05-19  Jan Kratochvil  <jan.kratochvil@redhat.com>

* gdb.arch/powerpc-power.exp: New file.
* gdb.arch/powerpc-power.s: New file.

Message-ID: <20140514205425.GA15398@host2.jankratochvil.net>

10 years agoExtend the fix already created for PR 16858 so that it works with x86 PE targets...
Nick Clifton [Mon, 19 May 2014 13:29:31 +0000 (14:29 +0100)] 
Extend the fix already created for PR 16858 so that it works with x86 PE targets as well.

PR gas/16858
* config/tc-i386.c (md_apply_fix): Improve the detection of code
symbols for 32-bit PE targets.

10 years agoDon't link FreeBSD tests with -ldl.
Andreas Tobler [Mon, 19 May 2014 06:49:55 +0000 (08:49 +0200)] 
Don't link FreeBSD tests with -ldl.

    * ld-elf/shared.exp: Introduce the extralibs variable to control
    the libraries to be linked. Don't link -ldl on *-*-freebsd*.

    * ld-bootstrap/bootstrap.exp: Do not add -ldl to the extralibs on
    *-*-freebsd*.

10 years agodaily update
Alan Modra [Mon, 19 May 2014 00:00:38 +0000 (09:30 +0930)] 
daily update

10 years agogas/
Richard Sandiford [Sun, 18 May 2014 19:28:04 +0000 (20:28 +0100)] 
gas/
* config/tc-mips.c (md_obj_begin): Delete.
(md_obj_end): Fold into...
(md_mips_end): ...here.  Move to end of file.

10 years agodaily update
Alan Modra [Sun, 18 May 2014 00:00:41 +0000 (09:30 +0930)] 
daily update

10 years ago * progspace.c (remove_program_space): Delete, unused.
Doug Evans [Sat, 17 May 2014 19:18:26 +0000 (12:18 -0700)] 
* progspace.c (remove_program_space): Delete, unused.
* progspace.h (remove_program_space): Ditto.

10 years ago * inferior.c (prune_inferiors): Fix comment.
Doug Evans [Sat, 17 May 2014 18:59:34 +0000 (11:59 -0700)] 
* inferior.c (prune_inferiors): Fix comment.
(remove_inferior_command): Call prune_program_spaces.

10 years agoPrevent the V850 assembler from generating an internal error if it is asked to
Nick Clifton [Sat, 17 May 2014 16:45:18 +0000 (17:45 +0100)] 
Prevent the V850 assembler from generating an internal error if it is asked to
handle a ctoff() pseudo-op when running in RH850 ABI mode.

PR gas/16946
* config/tc-v850.c (handle_ctoff): Generate an error if called
when using the RH850 ABI.

10 years ago * config.bfd: Move QNX target_cflags from arm-*-netbsd* to arm-*-nto*.
Ryan Mansfield [Fri, 16 May 2014 14:49:46 +0000 (15:49 +0100)] 
   * config.bfd: Move QNX target_cflags from arm-*-netbsd* to arm-*-nto*.

10 years agoCopy over changes from guile.texi.
Doug Evans [Sat, 17 May 2014 16:13:00 +0000 (09:13 -0700)] 
Copy over changes from guile.texi.

* python.texi (Basic Python) <gdb.execute>: Add text.
(Basic Python) <gdb.post_event>: Remove "main" from "main GDB thread".
(Values From Inferior) <Python string>: Add text.
(Values From Inferior) <Value.string>: Clarify string length handling.
(Pretty Printing API): Add cindex.
(Types In Python) <TYPE_CODE_*>: Use vtable instead of table.
Remove unnecessary index of gdb.TYPE_CODE_*.  Replace @findex with
@vindex.
(Commands In Python) <COMPLETE_*>: Similarly.
(Symbols In Python) <SYMBOL_*>: Similarly.
(Breakpoints In Python) <WP_*>: Similarly.
(Breakpoints In Python) <BP_*>: Similarly.

10 years agoImprove docs of qfThreadInfo packet.
David Taylor [Sat, 17 May 2014 07:29:57 +0000 (10:29 +0300)] 
Improve docs of qfThreadInfo packet.

gdb/doc/gdb.texinfo (General Query Packets): Add a note about thread IDs
mentioned in the qfThreadInfo reply.

10 years agodaily update
Alan Modra [Sat, 17 May 2014 00:00:39 +0000 (09:30 +0930)] 
daily update

10 years ago * gdb.base/completion.exp: Check that all expected files exist
Doug Evans [Fri, 16 May 2014 19:46:24 +0000 (12:46 -0700)] 
* gdb.base/completion.exp: Check that all expected files exist
before doing file completion.

10 years ago* gdb.base/Makefile.in (EXECUTABLES): Add completion.
Doug Evans [Fri, 16 May 2014 19:34:05 +0000 (12:34 -0700)] 
* gdb.base/Makefile.in (EXECUTABLES): Add completion.

10 years agoNew command line option -D.
Doug Evans [Fri, 16 May 2014 19:15:10 +0000 (12:15 -0700)] 
New command line option -D.

* NEWS: Mention it.
* main.c (set_gdb_data_directory): New function.
(captured_main): Recognize -D.  Flag error for --data-directory "".
Call set_gdb_data_directory.
(print_gdb_help): Print --data-directory, -D.
* main.h (set_gdb_data_directory): Declare.
* top.c (staged_gdb_datadir): New static global.
(set_gdb_datadir): Call set_gdb_data_directory
(show_gdb_datadir): New function.
(init_main): Update init of data-directory parameter.

testsuite/
* gdb.base/catch-syscall.exp (test_catch_syscall_fail_nodatadir):
Update.
(do_syscall_tests_without_xml): Update.

doc/
* gdb.texinfo (Mode Options): Add -D.

10 years agoImport the "dirfd" gnulib module.
Gregory Fong [Fri, 16 May 2014 18:26:33 +0000 (12:26 -0600)] 
Import the "dirfd" gnulib module.

2014-05-16  Gregory Fong  <gregory.0xf0@gmail.com>

Import the "dirfd" gnulib module.
* gnulib/update-gnulib.sh (IMPORTED_GNULIB_MODULES): Add dirfd.
* gnulib/aclocal.m4: Update.
* gnulib/config.in: Update.
* gnulib/configure: Update.
* gnulib/import/Makefile.am: Update.
* gnulib/import/Makefile.in: Update.
* gnulib/import/dirfd.c: New.
* gnulib/import/m4/dirfd.m4: New.
* gnulib/import/m4/gnulib-cache.m4: Update.
* gnulib/import/m4/gnulib-comp.m4: Update.

10 years ago * configure.tgt: Add /lib to dragonfly NATIVE_LIB_DIRS.
John Marino [Fri, 16 May 2014 14:39:47 +0000 (15:39 +0100)] 
* configure.tgt: Add /lib to dragonfly NATIVE_LIB_DIRS.

10 years agoThis fixes a few issues with pe/coff build-ids that were discovered since the
Jon Turney [Fri, 16 May 2014 14:34:13 +0000 (15:34 +0100)] 
This fixes a few issues with pe/coff build-ids that were discovered since the
original patches were posted:

  pe/coff: Display GUID build-id in the conventional way
  pe/coff: Don't interpret debug directory in section with no contents
  pe/coff: Keep .build-id with --only-keep-debug
  pe/coff: Don't break .build-id with objcopy/strip

* peXXigen.c (pe_print_debugdata): Don't interpret debug directory
in a section with no contents.
(is_vma_in_section, find_section_by_vma): New functions.
(_bfd_XX_bfd_copy_private_bfd_data_common): Recalculate file
offsets in the debug directory.
(_bfd_XXi_slurp_codeview_record, _bfd_XXi_write_codeview_record):
Byte-swap GUID from little-endian to big-endian order for
consistent and conventional display.

* objcopy.c (is_nondebug_keep_contents_section): New function.
(setup_section): Use it.

10 years agoThis adds support for marking RL78 binaries as either supporting 32-bit
Kaushik Phata [Fri, 16 May 2014 13:57:10 +0000 (14:57 +0100)] 
This adds support for marking RL78 binaries as either supporting 32-bit
or 64-bit doubles.  It also makes the linker complain if the user attempts
to link together binaries with different sized doubles.

* elf32-rl78.c (rl78_elf_merge_private_bfd_data): Complain if
64-bit doubles objects mix with 32-bit doubles objects.
(rl78_elf_print_private_bfd_data): Describe 64-bit doubles flag.

* readelf.c (get_machine_flags): Handle RL78 64-bit doubles flag.

* config/tc-rl78.c (enum options): Add OPTION_32BIT_DOUBLES
and OPTION_64BIT_DOUBLES.
(md_longopts): Add -m32bit-doubles and -m64bit-doubles.
(md_parse_option): Parse -m32bit-doubles and -m64bit-doubles.
(md_show_usage): Show all of the RL78 options.
(rl78_float_cons): New static functions.
(md_pseudo_table): Update handler for "double".

10 years agomi-support.exp: Fix some pastos.
Pedro Alves [Fri, 16 May 2014 13:43:47 +0000 (14:43 +0100)] 
mi-support.exp: Fix some pastos.

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

* lib/mi-support.exp (mi_expect_stop): On timeout, say "timeout"
instead of "unknown output after running".

10 years agoCopy file1.txt to remote host in dw2-filename.exp and dw2-anonymous-func.exp
Yao Qi [Tue, 13 May 2014 03:41:03 +0000 (11:41 +0800)] 
Copy file1.txt to remote host in dw2-filename.exp and dw2-anonymous-func.exp

Some gdb.dwarf2/*.exp tests copy file1.txt to host via gdb_remote_download
but dw2-filename.exp and dw2-anonymous-func.exp don't do that.  Looks like
an oversight in this patch
https://sourceware.org/ml/gdb-patches/2013-08/msg00365.html

There are some fails in remote host testing.
FAIL: gdb.dwarf2/dw2-anonymous-func.exp: list file1.txt
FAIL: gdb.dwarf2/dw2-filename.exp: interpreter-exec mi -file-list-exec-source-files
FAIL: gdb.dwarf2/dw2-filename.exp: info sources

This patch is to invoke gdb_remote_download to copy file1.txt to host
and remote it at the end.  This patch fixes these fails above.

gdb/testsuite:

2014-05-16  Yao Qi  <yao@codesourcery.com>

* gdb.dwarf2/dw2-filename.exp: Copy file1.txt to host.  Remove
file1.txt from host at the end.
* gdb.dwarf2/dw2-anonymous-func.exp: Likewise.

10 years agoFix display of tabulation character for mingw hosts.
Yao Qi [Tue, 22 Apr 2014 04:56:08 +0000 (12:56 +0800)] 
Fix display of tabulation character for mingw hosts.

Pierre proposed this patch
https://sourceware.org/ml/gdb-patches/2013-10/msg00011.html and
Tom gave a suggestion that it's better to do check \t in print_wchar
<https://sourceware.org/ml/gdb-patches/2013-11/msg00148.html>
However, I don't see the follow-up to this discussion.

We encounter two fails in printcmds.exp on mingw host, and Pierre's
patch fixes them.  I pick it up, update a little per Tom's
comments, and post it here for review.  This patch fixes these fails
below on mingw32 host.

FAIL: gdb.base/charset.exp: print string in ASCII
FAIL: gdb.base/charset.exp: try printing '\t' in ASCII
FAIL: gdb.base/charset.exp: print string in ISO-8859-1
FAIL: gdb.base/charset.exp: try printing '\t' in ISO-8859-1
FAIL: gdb.base/charset.exp: print string in UTF-32
FAIL: gdb.base/charset.exp: try printing '\t' in UTF-32
FAIL: gdb.base/printcmds.exp: p ctable1[9]
FAIL: gdb.base/printcmds.exp: p &ctable1[1*8]

Also regression tested on x86_64-linux.  Is it OK?

gdb:

2014-05-16  Pierre Muller  <muller@sourceware.org>
    Yao Qi  <yao@codesourcery.com>

* valprint.c (print_wchar): Move the code on checking whether
W is a printable wide char to the default branch of switch
statement below.  Call wchar_printable instead of gdb_iswprint.

10 years agoFix changelong entry.
Yao Qi [Fri, 16 May 2014 12:10:38 +0000 (20:10 +0800)] 
Fix changelong entry.

  Each changelog entry should be tab-prefixed.

10 years agoFix prologue analysis for ldr.w and ldrd instruction
Taimoor Mirza [Fri, 16 May 2014 06:39:05 +0000 (11:39 +0500)] 
Fix prologue analysis for ldr.w and ldrd instruction

Prologue analysis for ldr.w and ldrd instruction obtains offset from
first two bytes that contains opcode of instruction. It should obtain
offset from next two bytes that actually contain operands.

       * arm-tdep.c (thumb_analyze_prologue): Fix offset calculation for
ldr.w and ldrd instructions.

Signed-off-by: Taimoor Mirza <tmirza@codesourcery.com>
10 years agodaily update
Alan Modra [Fri, 16 May 2014 00:00:36 +0000 (09:30 +0930)] 
daily update

10 years agoMake more robust when run in parallel mode.
Doug Evans [Thu, 15 May 2014 22:50:34 +0000 (15:50 -0700)] 
Make more robust when run in parallel mode.

Since we're not compiling with gcc, we don't know where the
DWO file will ultimately be built.  It could be built in
testsuite/gdb.dwarf2/foo (non-parallel mode) or
testsuite/outputs/gdb.dwarf2/foo (parallel mode).

* gdb.dwarf2/fission-reread.S: Remove directory from .dwo file path.
* gdb.dwarf2/fission-reread.exp: Set debug-file-directory before
loading file.  Add test for TU lookup.

10 years ago* dwarf2read.c (read_structure_type): Delete outdated comments.
Doug Evans [Thu, 15 May 2014 22:45:05 +0000 (15:45 -0700)] 
* dwarf2read.c (read_structure_type): Delete outdated comments.

10 years agoFix argument passing in mi_run_cmd_full
Simon Marchi [Tue, 13 May 2014 21:37:44 +0000 (17:37 -0400)] 
Fix argument passing in mi_run_cmd_full

Passing arguments did not work when use_mi_command was set.

gdb/testsuite/ChangeLog:
2014-05-13  Simon Marchi  <simon.marchi@ericsson.com>

* lib/mi-support.exp (mi_run_cmd_full): Set arguments by calling
"-exec-arguments" or "set args" before running the inferior.

10 years agoFix mi_expect_stop for non-zero exit codes
Simon Marchi [Tue, 13 May 2014 21:07:33 +0000 (17:07 -0400)] 
Fix mi_expect_stop for non-zero exit codes

The message displayed by gdb is different when the inferior exits with
zero and non-zero values, this fix takes that into account.

gdb/testsuite/ChangeLog:
2014-05-13  Simon Marchi  <simon.marchi@ericsson.com>

* lib/mi-support.exp (mi_expect_stop): Expect message for
inferiors that exit with non-zero exit code.

10 years agoFix "overflow in PLT unwind data" warning
Alan Modra [Thu, 15 May 2014 09:07:43 +0000 (18:37 +0930)] 
Fix "overflow in PLT unwind data" warning

When linking statically, it's possible to hit this warning with IFUNC
or very large executables, due to .glink being unused.

* powerpc.cc (do_plt_fde_location): Handle zero length .glink.
Compare FDE contents with DW_CFA_nop rather than 0.

10 years agodaily update
Alan Modra [Thu, 15 May 2014 00:00:45 +0000 (09:30 +0930)] 
daily update

10 years agoSync nios2 configure changes from GCC mainline.
Sandra Loosemore [Wed, 14 May 2014 23:27:14 +0000 (16:27 -0700)] 
Sync nios2 configure changes from GCC mainline.

2014-05-14  Sandra Loosemore  <sandra@codesourcery.com>

* configure.ac (target_makefile_frag): Set for nios2-*-elf*.
* configure: Regenerated.

config/
* mt-nios2-elf: New file.

10 years agoreindent print_macro_definition
Tom Tromey [Wed, 14 May 2014 19:31:10 +0000 (13:31 -0600)] 
reindent print_macro_definition

I happened to notice that print_macro_definition is indented
improperly.  All the lines were a few extra spaces to the right.

This patch fixes the indentation.
Tested by rebuilding, committed.

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

* macrocmd.c (print_macro_definition): Reindent.

10 years agoFix mi-file.exp fails on remote host
Yao Qi [Tue, 13 May 2014 06:40:22 +0000 (14:40 +0800)] 
Fix mi-file.exp fails on remote host

This patch fixes mi-file.exp fails on remote host.  First, we can't
assume ${srcdir}/${subdir}/${srcfile} directory exists on remote host,
so this patch changes it to match ${srcfile} only on remote host.
Second, regexp pattern ".*/${srcfile}" isn't friendly to Windows path.
The file name is "basics.c" in my test env and can't match the pattern
due to "/" in it.  Remove "/" from the pattern.

gdb/testsuite:

2014-05-14  Yao Qi  <yao@codesourcery.com>

* gdb.mi/mi-file.exp (test_file_list_exec_source_file): Don't
match absolute path on remote host.
(test_file_list_exec_source_files): Remove "/" from the
pattern.

10 years agoOverwrite ${board}_file in local-remote-host
Yao Qi [Tue, 13 May 2014 01:37:54 +0000 (09:37 +0800)] 
Overwrite ${board}_file in local-remote-host

After I run test like this,

 $ make check RUNTESTFLAGS='--host_board=local-remote-host dw2-basic.exp'

gdb.dwarf2/file1.txt in source tree was removed.  In some gdb.dwarf2/*.exp,
file1.txt is copied to host and then removed at the end.  However, in
local-remote-host-notty.exp, ${board}_download doesn't copy the file but
return the absolute path of the src file.  'remote_file host delete' at
the end will remove the file in source tree.

This patch is to overwrite ${board}_file, and specially make "delete"
option do nothing.  This approach is used in gdbserver-base.exp and
remote-stdio-gdbserver.exp too.

gdb/testsuite:

2014-05-14  Yao Qi  <yao@codesourcery.com>

* boards/local-remote-host-notty.exp (${board}_file): New
proc.

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