deliverable/binutils-gdb.git
10 years agogdb/source.c: Fix matching path substitute rule listing
Brad Mouring [Mon, 2 Jun 2014 20:55:10 +0000 (15:55 -0500)] 
gdb/source.c: Fix matching path substitute rule listing

The check for the source (or "from") directory snippet in listing
matching path substitution rules currently will not match anything
other than a direct match of the "from" field in a substitution rule,
resulting in the incorrect behavior below:

...
(gdb) set substitute-path /a/path /another/path
(gdb) show substitute-path
List of all source path substitution rules:
  `/a/path' -> `/another/path'.
(gdb) show substitute-path /a/path/to/a/file.ext
Source path substitution rule matching `/a/path/to/a/file.ext':
(gdb) show substitute-path /a/path
Source path substitution rule matching `/a/path':
  `/a/path' -> `/another/path'.
...

This change effects the following behavior by (sanely) checking
with the length of the "from" portion of a rule and ensuring that
the next character of the path considered for substitution is a path
delimiter (or NULL). With this change, the following behavior is
garnered:
...
(gdb) set substitute-path /a/path /another/path
(gdb) show substitute-path
List of all source path substitution rules:
  `/a/path' -> `/another/path'.
(gdb) show substitute-path /a/path/to/a/file.ext
Source path substitution rule matching `/a/path/to/a/file.ext':
  `/a/path' -> `/another/path'.
(gdb) show substitute-path /a/pathological/case/that/should/fail.err
Source path substitution rule matching `/a/pathological/case/that/should/fail.err':
(gdb)

Also included is a couple of tests added to subst.exp to verify
this behavior in the test suite.

gdb/ChangeLog:

        * source.c (show_substitute_path_command): Fix display of matching
        substitution rules.

gdb/testsuite/ChangeLog:

        * gdb.ada/subst.exp: Add tests to verify partial path matching
        output.

This was tested on x86_64 Linux.

10 years agoSkip sss-bp-on-user-bp-2.exp on remote hardware step targets.
Pedro Alves [Tue, 3 Jun 2014 13:04:48 +0000 (14:04 +0100)] 
Skip sss-bp-on-user-bp-2.exp on remote hardware step targets.

gdb/testsuite/
2014-06-03  Pedro Alves  <palves@redhat.com>

* gdb.base/sss-bp-on-user-bp-2.exp: Skip if testing with a remote
target that doesn't use software single-stepping.

10 years agoThis patch replaces a call to cplus_demangle with a call to
Gary Benson [Tue, 3 Jun 2014 12:49:20 +0000 (13:49 +0100)] 
This patch replaces a call to cplus_demangle with a call to
gdb_demangle.  This change was included in an RFC from last
March [1] but omitted from the eventual commit.

[1] https://sourceware.org/ml/gdb-patches/2013-03/msg00235.html

2014-06-03  Gary Benson  <gbenson@redhat.com>

* gnu-v2-abi.c (gnuv2_value_rtti_type): Use gdb_demangle.

10 years agoPR breakpoints/17000: user breakpoint not inserted if software-single-step at same...
Pedro Alves [Tue, 3 Jun 2014 11:46:46 +0000 (12:46 +0100)] 
PR breakpoints/17000: user breakpoint not inserted if software-single-step at same location - test

GDB gets confused when removing a software single-step breakpoint that
is at the same address as another breakpoint.  Add another kfailed
test.

gdb/testsuite/
2014-06-03  Pedro Alves  <palves@redhat.com>

PR breakpoints/17000
* gdb.base/sss-bp-on-user-bp-2.c: New file.
* gdb.base/sss-bp-on-user-bp-2.exp: New file.

10 years agoAdd parameter support for Guile.
Doug Evans [Tue, 3 Jun 2014 08:58:15 +0000 (01:58 -0700)] 
Add parameter support for Guile.

* Makefile.in (SUBDIR_GUILE_OBS): Add scm-param.o.
(SUBDIR_GUILE_SRCS): Add scm-param.c.
(scm-param.o): New rule.
* guile/guile-internal.h (gdbscm_gc_dup_argv): Declare.
(gdbscm_misc_error): Declare.
(gdbscm_canonicalize_command_name): Declare.
(gdbscm_scm_to_host_string): Declare.
(gdbscm_scm_from_host_string): Declare.
(gdbscm_initialize_parameters): Declare.
* guile/guile.c (initialize_gdb_module): Call
gdbscm_initialize_parameters.
* guile/lib/gdb.scm: Export parameter symbols.
* guile/scm-cmd.c (gdbscm_canonicalize_command_name): Renamed from
cmdscm_canonicalize_name and made public.  All callers updated.
* guile/scm-exception.c (gdbscm_misc_error): New function.
* guile/scm-param.c: New file.
* guile/scm-string.c (gdbscm_scm_to_string): Add comments.
(gdbscm_scm_to_host_string): New function.
(gdbscm_scm_from_host_string): New function.
* scm-utils.c (gdbscm_gc_dup_argv): New function.

testsuite/
* gdb.guile/scm-parameter.exp: New file.

doc/
* guile.texi (Guile API): Add entry for Parameters In Guile.
(GDB Scheme Data Types): Mention <gdb:parameter> object.
(Parameters In Guile): New node.

10 years agoFix a small but in the emulation of the MSP430 hardware multiply.
Nick Clifton [Tue, 3 Jun 2014 08:00:57 +0000 (09:00 +0100)] 
Fix a small but in the emulation of the MSP430 hardware multiply.

* msp430-sim.c (get_op): Handle reads of low result register when
in MAC mode.
(put_op): Copy MAC result into result words.
Handle writes to the low result register.

10 years agoFix the disassembly of MSP430 extended index addressing mode.
Nick Clifton [Tue, 3 Jun 2014 07:54:04 +0000 (08:54 +0100)] 
Fix the disassembly of MSP430 extended index addressing mode.

* msp430-dis.c (msp430_doubleoperand): Use extension_word to
decide when extended addressing is being used.

10 years agoChange -mz command line option to -my for the MSP430 port of GAS.
Nick Clifton [Tue, 3 Jun 2014 07:49:02 +0000 (08:49 +0100)] 
Change -mz command line option to -my for the MSP430 port of GAS.

* config/tc-msp430.c (OPTION_WARN_INTR_NOPS): Use y instead of z.
(OPTION_NO_WARN_INTR_NOPS): Use Y instead of Z.
* doc/c-msp430.texi: Update command line option description.

* gas/msp430/bad.d: Use -my not -mz.

10 years ago If the binutils testsuite is run on an installed toolchain the tests involving
Nick Clifton [Tue, 3 Jun 2014 07:37:29 +0000 (08:37 +0100)] 
 If the binutils testsuite is run on an installed toolchain the tests involving
the bfdtest1 and bfdtest2 executables will fail because they are not installed.
 Since the programs only exist to be used by the testsuite it does not make sense
to install them, so instead I have chosen to create a patch which skips the tests
when they are not present.

* binutils-all/ar.exp: Skip tests involving bfdtest1 and bfdtest2
if these executables are not present.

10 years agoAdd command support for Guile.
Doug Evans [Tue, 3 Jun 2014 07:29:49 +0000 (00:29 -0700)] 
Add command support for Guile.

* Makefile.in (SUBDIR_GUILE_OBS): Add scm-cmd.o.
(SUBDIR_GUILE_SRCS): Add scm-cmd.c.
(scm-cmd.o): New rule.
* guile/guile-internal.h (gdbscm_gc_xstrdup): Declare.
(gdbscm_user_error_p): Declare.
(gdbscm_parse_command_name): Declare.
(gdbscm_valid_command_class_p): Declare.
(gdbscm_initialize_commands): Declare.
* guile/guile.c (initialize_gdb_module): Call
gdbscm_initialize_commands.
* guile/lib/gdb.scm: Export command symbols.
* guile/lib/gdb/init.scm (%exception-keys): Add gdb:user-error.
(throw-user-error): New function.
* guile/scm-cmd.c: New file.
* guile/scm-exception.c (user_error_symbol): New static global.
(gdbscm_user_error_p): New function.
(gdbscm_initialize_exceptions): Set user_error_symbol.
* scm-utils.c (gdbscm_gc_xstrdup): New function.

testsuite/
* gdb.guile/scm-cmd.c: New file.
* gdb.guile/scm-cmd.exp: New file.

doc/
* guile.texi (Guile API): Add entry for Commands In Guile.
(Basic Guile) <parse-and-eval>: Add reference.
(Basic Guile) <string->argv>: Move definition to Commands In Guile.
(GDB Scheme Data Types): Mention <gdb:command> object.
(Commands In Guile): New node.

10 years agoDon't remove #-comments.
Phil Muldoon [Tue, 3 Jun 2014 07:01:39 +0000 (00:01 -0700)] 
Don't remove #-comments.

When using the multi-line feature, we don't want the gdb CLI to remove
comments from the command list, as this will remove things like
"#define".

* top.c (command_loop): Handle comments here...
(command_line_input): ... not here.

10 years agoAdd progspace support for Guile.
Doug Evans [Tue, 3 Jun 2014 06:46:27 +0000 (23:46 -0700)] 
Add progspace support for Guile.

* Makefile.in (SUBDIR_GUILE_OBS): Add scm-progspace.o.
(SUBDIR_GUILE_SRCS): Add scm-progspace.c.
(scm-progspace.o): New rule.
* guile/guile-internal.h (pspace_smob): New typedef.
(psscm_pspace_smob_pretty_printers): Declare.
(psscm_pspace_smob_from_pspace): Declare.
(psscm_scm_from_pspace): Declare.
* guile/guile.c (initialize_gdb_module): Call
gdbscm_initialize_pspaces.
* guile/lib/gdb.scm: Export progspace symbols.
* guile/lib/gdb/printing.scm (prepend-pretty-printer!): Add progspace
support.
(append-pretty-printer!): Ditto.
* guile/scm-pretty-print.c (ppscm_find_pretty_printer_from_progspace):
Implement.
* guile/scm-progspace.c: New file.

doc/
* guile.texi (Guile API): Add entry for Progspaces In Guile.
(GDB Scheme Data Types): Mention <gdb:progspace> object.
(Progspaces In Guile): New node.

testsuite/
* gdb.guile/scm-pretty-print.exp: Add tests for objfile and progspace
pretty-printer lookup.
* gdb.guile/scm-pretty-print.scm (pp_s-printer): New function.
(make-pp_s-printer): Call it.
(make-pretty-printer-from-dict): New function.
(lookup-pretty-printer-maker-from-dict): New function.
(*pretty-printer*): Simplify.
(make-objfile-pp_s-printer): New function.
(install-objfile-pretty-printers!): New function.
(make-progspace-pp_s-printer): New function.
(install-progspace-pretty-printers!): New function.
* gdb.guile/scm-progspace.c: New file.
* gdb.guile/scm-progspace.exp: New file.

10 years agoSupport fusion for ELFv2 stubs
Alan Modra [Tue, 3 Jun 2014 01:25:29 +0000 (10:55 +0930)] 
Support fusion for ELFv2 stubs

Power8 fuses addis,addi and addis,ld sequences when the target of the
addis is the same as the addi/ld.  Thus
    addis r12,r2,xxx@ha
    addi r12,r12,xxx@l / ld r12,xxx@l(r12)
is faster than
    addis r11,r2,xxx@ha
    addi r12,r11,xxx@l / ld r12,xxx@l(r11)
So use the form that allows fusion in plt call and branch stubs.

bfd/
* elf64-ppc.c (ADDIS_R12_R2): Define.
(build_plt_stub): Support fusion on ELFv2 stub.
(ppc_build_one_stub): Likewise for plt branch stubs.
gold/
* powerpc.cc (addis_12_2): Define.
(Stub_table::do_write): Support fusion on ELFv2 stubs.
ld/testsuite/
* ld-powerpc/elfv2exe.d: Update for changed plt call stubs.
gdb/
* ppc64-tdep.c (ppc64_standard_linkage8): New.
(ppc64_skip_trampoline_code): Recognise ELFv2 stub supporting fusion.

10 years agoFix gold plugin_test failures on PowerPC64 ELFv2
Alan Modra [Tue, 3 Jun 2014 01:17:55 +0000 (10:47 +0930)] 
Fix gold plugin_test failures on PowerPC64 ELFv2

readelf output for ELFv2 includes st_other bits specifying a
function's local entry offset.

* testsuite/plugin_test.c (parse_readelf_line): Skip non-visibility
st_other output.

10 years agoAdd support for skeletonless type units.
Doug Evans [Tue, 3 Jun 2014 00:16:07 +0000 (17:16 -0700)] 
Add support for skeletonless type units.

* dwarf2read.c (struct dwarf2_per_objfile): New member
n_allocated_type_units.
(struct dwarf2_per_objfile) <tu_stats>: New member
nr_all_type_units_reallocs.
(create_signatured_type_table_from_index): Initialize
n_allocated_type_units
(create_all_type_units): Ditto.
(add_type_unit): Move up in file.  New arg slot.
All callers updated.  Increase space for all_type_units more
efficiently.
(fill_in_sig_entry_from_dwo_entry): Handle psymtabs.
(lookup_dwo_signatured_type): Handle skeletonless TUs.
(lookup_dwp_signatured_type): Ditto.
(init_tu_and_read_dwo_dies): New arg use_existing_cu.
All callers updated.
(build_type_psymtabs_1): Leave type_unit_groups as
NULL if no TUs present.
(print_tu_stats): New function.
(process_skeletonless_type_unit): New function.
(process_dwo_file_for_skeletonless_type_units): New
function.
(process_skeletonless_type_units): New function.
(dwarf2_build_psymtabs_hard): Handle skeletonless TUs.
Call print tu_stats if debugging enabled.

10 years agodaily update
Alan Modra [Tue, 3 Jun 2014 00:01:13 +0000 (09:31 +0930)] 
daily update

10 years agoInstalling a breakpoint on top of a dprintf makes GDB lose control.
Pedro Alves [Mon, 2 Jun 2014 21:27:33 +0000 (22:27 +0100)] 
Installing a breakpoint on top of a dprintf makes GDB lose control.

While the full fix for PR 15180 isn't in, it's best if we at least
make sure that GDB doesn't lose control when a breakpoint is set at
the same address as a dprintf.

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

* breakpoint.c (build_target_command_list): Don't build a command
list if we have any duplicate location that isn't a dprintf.

gdb/testsuite/
2014-06-02  Pedro Alves  <palves@redhat.com>

* gdb.base/dprintf-bp-same-addr.c: New file.
* gdb.base/dprintf-bp-same-addr.exp: New file.

10 years agodprintf-style agent can't explain a trap.
Pedro Alves [Mon, 2 Jun 2014 21:27:32 +0000 (22:27 +0100)] 
dprintf-style agent can't explain a trap.

If some event happens to trigger at the same address as a dprintf-style
agent dprintf is installed, GDB will complain, like:

 (gdb) continue
 Continuing.
 May only run agent-printf on the target
 (gdb)

Such dprintfs are completely handled on the target side, so they can't
explain a stop, but GDB is currently putting then on the bpstat chain
anyway, because they currently unconditionally use bkpt_breakpoint_hit
as breakpoint_hit method.

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

* breakpoint.c (dprintf_breakpoint_hit): New function.
(initialize_breakpoint_ops): Install it as dprintf's
breakpoint_hit method.

10 years agogdbserver: on GDB breakpoint reinsertion, also delete the breakpoint's commands.
Pedro Alves [Mon, 2 Jun 2014 21:27:32 +0000 (22:27 +0100)] 
gdbserver: on GDB breakpoint reinsertion, also delete the breakpoint's commands.

If GDB decides to change the breakpoint's conditions or commands,
it'll reinsert the same breakpoint again, with the new options
attached, without deleting the previous breakpoint.  E.g.,

 (gdb) set breakpoint always-inserted on
 (gdb) b main if 0
 Breakpoint 1 at 0x400594: file foo.c, line 21.
 Sending packet: $Z0,400594,1;X3,220027#68...Packet received: OK
 (gdb) b main
 Breakpoint 15 at 0x400594: file foo.c, line 21.
 Sending packet: $Z0,400594,1#49...Packet received: OK

GDBserver understands this and deletes the breakpoint's previous
conditions.  But, it forgets to delete the previous commands.

gdb/gdbserver/
2014-06-02  Pedro Alves  <palves@redhat.com>

* ax.c (gdb_free_agent_expr): New function.
* ax.h (gdb_free_agent_expr): New declaration.
* mem-break.c (delete_gdb_breakpoint_1): Also clear the commands
list.
(clear_breakpoint_conditions, clear_breakpoint_commands): Make
static.
(clear_breakpoint_conditions_and_commands): New function.
* mem-break.h (clear_breakpoint_conditions): Delete declaration.
(clear_breakpoint_conditions_and_commands): New declaration.

10 years agogdb/testsuite/
Edjunior Barbosa Machado [Mon, 2 Jun 2014 16:57:27 +0000 (13:57 -0300)] 
gdb/testsuite/
2014-06-02  Edjunior Barbosa Machado  <emachado@linux.vnet.ibm.com>

* gdb.arch/powerpc-power.exp: Add power8 instructions to the testcase.
* gdb.arch/powerpc-power.s: Likewise.

10 years agoUnnecessary restore of timeout global at end of gdb.base/completion.exp
Joel Brobecker [Tue, 27 May 2014 21:03:11 +0000 (14:03 -0700)] 
Unnecessary restore of timeout global at end of gdb.base/completion.exp

This patch removes some code in gdb.base/compilation.exp which
is aimed at restoring the original timeout global value after having
changed it for this testcase. Restoring the timeout global is not
necessary as this is taken care of by gdb_init, which is called
at the start of each testing.

gdb/testsuite/ChangeLog:

        * gdb.base/completion.exp: Remove code aimed at restoring TIMEOUT.

10 years agosimplify substitute_path_rule_matches using filename_ncmp
Joel Brobecker [Mon, 2 Jun 2014 15:34:25 +0000 (08:34 -0700)] 
simplify substitute_path_rule_matches using filename_ncmp

At the time this function was written, there was no filename_ncmp,
only FILENAME_CMP. So, in order to do an n-cmp, we had to make a local
copy of the first n characters of our string and use that to perform
the comparison. This patch simplifies the function's implementation,
now that we have filename_ncmp.

gdb/ChangeLog:

        * source.c (substitute_path_rule_matches): Simplify using
        filename_ncmp instead of FILENAME_CMP.

Tested on x86_64-linux.

10 years agoRemove some trailing spaces in source.c
Joel Brobecker [Mon, 2 Jun 2014 15:23:50 +0000 (08:23 -0700)] 
Remove some trailing spaces in source.c

gdb/ChangeLog:

        * source.c (substitute_path_rule_matches): Remove trailing spaces.

10 years agoThis fixes a thinko in the LEON support recently added to the assembler.
Eric Botcazou [Mon, 2 Jun 2014 11:11:17 +0000 (13:11 +0200)] 
This fixes a thinko in the LEON support recently added to the assembler.

opcodes/
* sparc-opc.c (cas): Disable for LEON.
(casl): Likewise.

10 years agofix typos in ChangeLog
Alan Modra [Mon, 2 Jun 2014 06:28:49 +0000 (15:58 +0930)] 
fix typos in ChangeLog

10 years agofix 2014-05-28 ld Makefile.am changes
Alan Modra [Mon, 2 Jun 2014 04:24:54 +0000 (13:54 +0930)] 
fix 2014-05-28 ld Makefile.am changes

bfin, msp, and score all used an extra parameter to genscripts.sh
to select a "customizer_script" different from the standard one
named from the emulation.  This patch renames the scripts to avoid
the need, tidying them in the process.

* emulparams/elf32bfin.sh: Rename from bfin.sh.
* emulparams/elf32bfinfd.sh: Update to suit.
* emulparams/: Delete.
* emulparams/msp430.sh: Rename from msp430all.sh.  Remove
MSP430_NAME and msp430X vars.
* emulparams/msp430X.sh: New.
* emulparams/: Delete.
* emulparams/score3_elf.sh: Rename from scoreelf.sh.  Remove
SCORE_NAME and score7_elf ARCH setting.
* emulparams/score7_elf.sh: New.
* Makefile.am (eelf32bfin.c, eelf32bfinfd.c): Update dependencies.
(emsp430.c, emsp430X.c, escore3_elf.c, escore7_elf.c): Likewise.
* Makefile.in: Regenerate.
* genscripts.sh: Delete customizer_script param.

10 years agodaily update
Alan Modra [Mon, 2 Jun 2014 00:00:41 +0000 (09:30 +0930)] 
daily update

10 years agoFix PowerPC64 ELFv2 icf_safe failures
Alan Modra [Sun, 1 Jun 2014 12:31:44 +0000 (22:01 +0930)] 
Fix PowerPC64 ELFv2 icf_safe failures

ELFv2 doesn't use .opd, so folding function code can't be allowed
in safe mode if a function's address might be taken.

* powerpc.cc (Target_powerpc::local_reloc_may_be_function_pointer):
Only ignore relocs on ELFv1.
(Target_powerpc::global_reloc_may_be_function_pointer): Likewise.

10 years agoguile: Allow compilation with Guile <= 2.0.5.
Ludovic Courtès [Tue, 27 May 2014 12:02:21 +0000 (14:02 +0200)] 
guile: Allow compilation with Guile <= 2.0.5.

gdb/
2014-06-01  Ludovic Courtès  <ludo@gnu.org>

* configure.ac: When Guile is available, check for the
availability of 'scm_new_smob'.
* configure, config.h.in: Regenerate.
* guile/guile-internal.h (scm_new_smob) [!HAVE_SCM_NEW_SMOB]: New
function.

10 years ago2014-06-01 Ray Donnelly <mingw.android@gmail.com>
Kai Tietz [Sun, 1 Jun 2014 20:11:56 +0000 (22:11 +0200)] 
2014-06-01  Ray Donnelly  <mingw.android@gmail.com>

* pex-win32.c (argv_to_cmdline): Don't quote
args unnecessarily.

10 years agoSkip test 'watch -location nullptr->p->x' if null pointer can be dereferenced
Yao Qi [Wed, 28 May 2014 04:38:52 +0000 (12:38 +0800)] 
Skip test 'watch -location nullptr->p->x' if null pointer can be dereferenced

gdb.base/watchpoint.exp has a test below which expects to see "Cannot
access memory at address 0x0" when a null pointer is dereferenced.

    gdb_test "watch -location nullptr->p->x" \
"Cannot access memory at address 0x0"

This assumption is not true when the target is no-mmu, so we get

watch -location nullptr->p->x
Hardware watchpoint 28: -location nullptr->p->x
(gdb) FAIL: gdb.base/watchpoint.exp: watch -location nullptr->p->x

This patch is to check whether null pointer can be dereferenced first
and then do the test.

gdb/testsuite:

2014-06-01  Yao Qi  <yao@codesourcery.com>

* gdb.base/watchpoint.exp (test_watch_location): Check null
pointer can be dereferenced.  If not, do the test, otherwise
skip it.

10 years agodaily update
Alan Modra [Sun, 1 Jun 2014 00:00:39 +0000 (09:30 +0930)] 
daily update

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

10 years agoAdd a TRY_CATCH to get_prev_frame_always to better manage errors during unwind.
Andrew Burgess [Wed, 28 May 2014 22:34:43 +0000 (23:34 +0100)] 
Add a TRY_CATCH to get_prev_frame_always to better manage errors during unwind.

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

Currently a MEMORY_ERROR raised during unwinding a frame will cause the
unwind to stop with an error message, for example:

  (gdb) bt
  #0  breakpt () at amd64-invalid-stack-middle.c:27
  #1  0x00000000004008f0 in func5 () at amd64-invalid-stack-middle.c:32
  #2  0x0000000000400900 in func4 () at amd64-invalid-stack-middle.c:38
  #3  0x0000000000400910 in func3 () at amd64-invalid-stack-middle.c:44
  #4  0x0000000000400928 in func2 () at amd64-invalid-stack-middle.c:50
  Cannot access memory at address 0x2aaaaaab0000

However, frame #4 is marked as being the end of the stack unwind, so a
subsequent request for the backtrace looses the error message, such as:

  (gdb) bt
  #0  breakpt () at amd64-invalid-stack-middle.c:27
  #1  0x00000000004008f0 in func5 () at amd64-invalid-stack-middle.c:32
  #2  0x0000000000400900 in func4 () at amd64-invalid-stack-middle.c:38
  #3  0x0000000000400910 in func3 () at amd64-invalid-stack-middle.c:44
  #4  0x0000000000400928 in func2 () at amd64-invalid-stack-middle.c:50

When fetching the backtrace, or requesting the stack depth using the MI
interface the situation is even worse, the first time a request is made
we encounter the memory error and so the MI returns an error instead of
the correct result, for example:

  (gdb) -stack-info-depth
  ^error,msg="Cannot access memory at address 0x2aaaaaab0000"

Or,

  (gdb) -stack-list-frames
  ^error,msg="Cannot access memory at address 0x2aaaaaab0000"

However, once one of these commands has been used gdb has, internally,
walked the stack and figured that out that frame #4 is the bottom of the
stack, so the second time an MI command is tried you'll get the "expected"
result:

  (gdb) -stack-info-depth
  ^done,depth="5"

Or,

  (gdb) -stack-list-frames
  ^done,stack=[frame={level="0", .. snip lots .. }]

After this patch the MEMORY_ERROR encountered during the frame unwind is
attached to frame #4 as the stop reason, and is displayed in the CLI each
time the backtrace is requested.  In the MI, catching the error means that
the "expected" result is returned the first time the MI command is issued.
So, from the CLI the results of the backtrace will be:

  (gdb) bt
  #0  breakpt () at amd64-invalid-stack-middle.c:27
  #1  0x00000000004008f0 in func5 () at amd64-invalid-stack-middle.c:32
  #2  0x0000000000400900 in func4 () at amd64-invalid-stack-middle.c:38
  #3  0x0000000000400910 in func3 () at amd64-invalid-stack-middle.c:44
  #4  0x0000000000400928 in func2 () at amd64-invalid-stack-middle.c:50
  Backtrace stopped: Cannot access memory at address 0x2aaaaaab0000

Each and every time that the backtrace is requested, while the MI output
will similarly be consistently:

  (gdb) -stack-info-depth
  ^done,depth="5"

Or,

  (gdb) -stack-list-frames
  ^done,stack=[frame={level="0", .. snip lots .. }]

gdb/ChangeLog:

* frame.c (struct frame_info): Add stop_string field.
(get_prev_frame_always_1): Renamed from get_prev_frame_always.
(get_prev_frame_always): Old content moved into
get_prev_frame_always_1.  Call get_prev_frame_always_1 inside
TRY_CATCH, handle MEMORY_ERROR exceptions.
(frame_stop_reason_string): New function definition.
* frame.h (unwind_stop_reason_to_string): Extend comment to
mention frame_stop_reason_string.
(frame_stop_reason_string): New function declaration.
* stack.c (frame_info): Switch to frame_stop_reason_string.
(backtrace_command_1): Switch to frame_stop_reason_string.
* unwind_stop_reason.def: Add UNWIND_MEMORY_ERROR.
(LAST_ENTRY): Changed to UNWIND_MEMORY_ERROR.
* guile/lib/gdb.scm: Add FRAME_UNWIND_MEMORY_ERROR to export list.

gdb/doc/ChangeLog:

* guile.texi (Frames In Guile): Mention FRAME_UNWIND_MEMORY_ERROR.
* python.texi (Frames In Python): Mention
gdb.FRAME_UNWIND_MEMORY_ERROR.

gdb/testsuite/ChangeLog:

* gdb.arch/amd64-invalid-stack-middle.exp: Update expected results.
* gdb.arch/amd64-invalid-stack-top.exp: Likewise.

10 years agoRename frame_stop_reason_string to unwind_stop_reason_to_string.
Andrew Burgess [Wed, 28 May 2014 21:46:33 +0000 (22:46 +0100)] 
Rename frame_stop_reason_string to unwind_stop_reason_to_string.

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

This function is confusingly named, the "frame_" in the name implies it
somehow is frame dependent, when in reality the function just converts an
'enum unwind_stop_reason' value to a string.

gdb/ChangeLog:

* frame.c (frame_stop_reason_string): Rename to ...
(unwind_stop_reason_to_string): this.
* frame.h (frame_stop_reason_string): Rename to ...
(unwind_stop_reason_to_string): this.
* stack.c (frame_info): Update call to frame_stop_reason_string.
(backtrace_command_1): Likewise.
* guile/scm-frame.c (gdbscm_unwind_stop_reason_string): Likewise.
* python/py-frame.c (gdbpy_frame_stop_reason_string): Likewise.

10 years agoRemove previous frame if an error occurs when computing frame id during unwind.
Andrew Burgess [Wed, 2 Apr 2014 16:02:51 +0000 (17:02 +0100)] 
Remove previous frame if an error occurs when computing frame id during unwind.

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

If an error is thrown during computing a frame id then the frame is left
in existence but without a valid frame id, this will trigger internal
errors if/when the frame is later visited (for example in a backtrace).

This patch catches errors raised while computing the frame id, and
arranges for the new frame, the one without a frame id, to be removed
from the linked list of frames.

gdb/ChangeLog:

* frame.c (remove_prev_frame): New function.
(get_prev_frame_if_no_cycle): Create / discard cleanup using
remove_prev_frame.

gdb/testsuite/ChangeLog:

* gdb.arch/amd64-invalid-stack-middle.S: New file.
* gdb.arch/amd64-invalid-stack-middle.c: New file.
* gdb.arch/amd64-invalid-stack-middle.exp: New file.
* gdb.arch/amd64-invalid-stack-top.c: New file.
* gdb.arch/amd64-invalid-stack-top.exp: New file.

10 years agoFix testsuite to use newly-built linker for ehdr_start_test_4, and fix
Cary Coutant [Fri, 30 May 2014 17:21:27 +0000 (10:21 -0700)] 
Fix testsuite to use newly-built linker for ehdr_start_test_4, and fix
check script to look for the right binding.

gold/
* testsuite/Makefile.am (ehdr_start_test_4): Fix typo in -B option.
* testsuite/Makefile.in: Regenerate.
* testsuite/ehdr_start_test_4.sh: Look for "U" instead of "w".

10 years agoPR breakpoints/17000: user breakpoint not inserted if software-single-step at same...
Pedro Alves [Fri, 30 May 2014 16:21:02 +0000 (17:21 +0100)] 
PR breakpoints/17000: user breakpoint not inserted if software-single-step at same location - test

GDB gets confused when removing a software single-step breakpoint that
is at the same address as another breakpoint.  Add a kfailed test.

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

PR breakpoints/17000
* gdb.base/sss-bp-on-user-bp.c: New file.
* gdb.base/sss-bp-on-user-bp.exp: New file.

10 years agoUse attribute to specify the required inlining semantics
David Blaikie [Fri, 30 May 2014 11:20:50 +0000 (12:20 +0100)] 
Use attribute to specify the required inlining semantics

As suggested by Andrew Pinski.

gdb/testsuite/
* gdb.opt/inline-break.c: Fix clang compatibility by specifying
gnu_inline semantics via attribute.
* gdb.opt/inline-break.exp: Remove -std=c89 now that the test
source explicitly specifies the required semantics.

10 years agogdb.reverse/sigall-reverse.exp: Typo fix
Maciej W. Rozycki [Fri, 30 May 2014 03:14:17 +0000 (04:14 +0100)] 
gdb.reverse/sigall-reverse.exp: Typo fix

* gdb.reverse/sigall-reverse.exp: Fix a typo.

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

10 years agoRunning the current tree against my software-single-step-on-x86_64
Pedro Alves [Thu, 29 May 2014 21:17:20 +0000 (22:17 +0100)] 
Running the current tree against my software-single-step-on-x86_64
branch showed some extra assertions I have in place triggering.  Turns
out my previous change to 'resume' was incomplete, and we mishandle
the 'hw_step' / 'step' variable pair.  (I swear I had fixed this, but
I guess I lost that in some local branch...)

Tested on x86_64 Fedora 20.

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

* infrun.c (resume): Rename local 'hw_step' to 'entry_step'
and make it const.  When a single-step decays to a continue,
clear 'step', not 'hw_step'.  Pass whether the caller wanted
to step to user_visible_resume_ptid, not what we ask the
target to do.

10 years agoinfrun.c: simplify "end stepping range" code a bit.
Pedro Alves [Thu, 27 Mar 2014 18:43:59 +0000 (18:43 +0000)] 
infrun.c: simplify "end stepping range" code a bit.

 - all end_stepping_range callers also set stop_step.

 - all places that set stop_step call end_stepping_range and
   stop_waiting too.

IOW, all places where we handle "end stepping range" do:

      ecs->event_thread->control.stop_step = 1;
      end_stepping_range ();
      stop_waiting (ecs);

Factor that out into end_stepping_range itself.

Tested on x86_64 Fedora 20.

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

* infrun.c (process_event_stop_test, handle_step_into_function)
(handle_step_into_function_backward): Adjust.
Don't set the even thread's stop_step and call stop_waiting before
calling end_stepping_range.  Instead do that ...
(end_stepping_range): ... here.  Take an ecs pointer parameter.

10 years agoinfrun.c: stop_stepping -> stop_waiting.
Pedro Alves [Thu, 27 Mar 2014 18:42:53 +0000 (18:42 +0000)] 
infrun.c: stop_stepping -> stop_waiting.

stop_stepping is called even when we weren't stepping.  It's job really is:

  static void
  stop_waiting (struct execution_control_state *ecs)
  {
  ...
    /* Let callers know we don't want to wait for the inferior anymore.  */
    ecs->wait_some_more = 0;
  }

So rename it for clarity.

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

* infrun.c (stop_stepping): Rename to ...
(stop_waiting): ... this.
(proceed): Update comment.
(process_event_stop_test, handle_inferior_event)
(handle_signal_stop, handle_step_into_function)
(handle_step_into_function_backward): Update.

10 years agounbreak infcalls
Pedro Alves [Thu, 29 May 2014 16:17:30 +0000 (17:17 +0100)] 
unbreak infcalls

I managed to miss an interaction between the recent *running patch,
and target-async, which resulted in infcalls being completely broken
on GNU/Linux and remote targets (that is, the async-capable targets).

 Temporary breakpoint 1, main () at threads.c:35
 35          long i = 0;
 (gdb) p malloc (0)
 The program being debugged stopped while in a function called from GDB.
 Evaluation of the expression containing the function
 (malloc) will be abandoned.
 When the function is done executing, GDB will silently stop.
 (gdb) p malloc (0)

 Program received signal SIGSEGV, Segmentation fault.
 0x000000000058d7e8 in get_regcache_aspace (regcache=0x0) at ../../src/gdb/regcache.c:281
 281       return regcache->aspace;
 (top-gdb)

The issue is that when running an infcall, the thread is no longer
marked as running, so run_inferior_call is not calling
wait_for_inferior anymore.

Fix this by doing what the comment actually says we do:

  "Do here what `proceed' itself does in sync mode."

And proceed doesn't check whether the target is running.

I notice this is broken in case of the early return in proceed, but we
were broken before in that case anyway, because run_inferior_call will
think the call actually ran.  Seems like we should make proceed have a
boolean return, and go through all callers making use of it, if
necessary.

But for now, just fix the regression.

Tested on x86_64 Fedora 20.

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

* infcall.c (run_inferior_call): Don't check whether the current
thread is running after the proceed call.

10 years agoenable target async by default; separate MI and target notions of async
Pedro Alves [Thu, 29 May 2014 18:58:57 +0000 (19:58 +0100)] 
enable target async by default; separate MI and target notions of async

This finally makes background execution commands possible by default.

However, in order to do that, there's one last thing we need to do --
we need to separate the MI and target notions of "async".  Unlike the
CLI, where the user explicitly requests foreground vs background
execution in the execution command itself (c vs c&), MI chose to treat
"set target-async" specially -- setting it changes the default
behavior of execution commands.

So, we can't simply "set target-async" default to on, as that would
affect MI frontends.  Instead we have to make the setting MI-specific,
and teach MI about sync commands on top of an async target.

Because the "target" word in "set target-async" ends up as a potential
source of confusion, the patch adds a "set mi-async" option, and makes
"set target-async" a deprecated alias.

Rather than make the targets always async, this patch introduces a new
"maint set target-async" option so that the GDB developer can control
whether the target is async.  This makes it simpler to debug issues
arising only in the synchronous mode; important because sync mode
seems unlikely to go away.

Unlike in previous revisions, "set target-async" does not affect this
new maint parameter.  The rationale for this is that then one can
easily run the test suite in the "maint set target-async off" mode and
have tests that enable mi-async fail just like they fail on
non-async-capable targets.  This emulation is exactly the point of the
maint option.

I had asked Tom in a previous iteration to split the actual change of
the target async default to a separate patch, but it turns out that
that is quite awkward in this version of the patch, because with MI
async and target async decoupled (unlike in previous versions), if we
don't flip the default at the same time, then just "set target-async
on" alone never actually manages to do anything.  It's best to not
have that transitory state in the tree.

Given "set target-async on" now only has effect for MI, the patch goes
through the testsuite removing it from non-MI tests.  MI tests are
adjusted to use the new and less confusing "mi-async" spelling.

2014-05-29  Pedro Alves  <palves@redhat.com>
    Tom Tromey  <tromey@redhat.com>

* NEWS: Mention "maint set target-async", "set mi-async", and that
background execution commands are now always available.
* target.h (target_async_permitted): Update comment.
* target.c (target_async_permitted, target_async_permitted_1):
Default to 1.
(set_target_async_command): Rename to ...
(maint_set_target_async_command): ... this.
(show_target_async_command): Rename to ...
(maint_show_target_async_command): ... this.
(_initialize_target): Adjust.
* infcmd.c (prepare_execution_command): Make extern.
* inferior.h (prepare_execution_command): Declare.
* infrun.c (set_observer_mode): Leave target async alone.
* mi/mi-interp.c (mi_interpreter_init): Install
mi_on_sync_execution_done as sync_execution_done observer.
(mi_on_sync_execution_done): New function.
(mi_execute_command_input_handler): Don't print the prompt if we
just started a synchronous command with an async target.
(mi_on_resume): Check sync_execution before printing prompt.
* mi/mi-main.h (mi_async_p): Declare.
* mi/mi-main.c: Include gdbcmd.h.
(mi_async_p): New function.
(mi_async, mi_async_1): New globals.
(set_mi_async_command, show_mi_async_command, mi_async): New
functions.
(exec_continue): Call prepare_execution_command.
(run_one_inferior, mi_cmd_exec_run, mi_cmd_list_target_features)
(mi_execute_async_cli_command): Use mi_async_p.
(_initialize_mi_main): Install "set mi-async".  Make
"target-async" a deprecated alias.

2014-05-29  Pedro Alves  <palves@redhat.com>
    Tom Tromey  <tromey@redhat.com>

* gdb.texinfo (Non-Stop Mode): Remove "set target-async 1"
from example.
(Asynchronous and non-stop modes): Document '-gdb-set mi-async'.
Mention that target-async is now deprecated.
(Maintenance Commands): Document maint set/show target-async.

2014-05-29  Pedro Alves  <palves@redhat.com>
    Tom Tromey  <tromey@redhat.com>

* gdb.base/async-shell.exp: Don't enable target-async.
* gdb.base/async.exp
* gdb.base/corefile.exp (corefile_test_attach): Remove 'async'
parameter.  Adjust.
(top level): Don't test with "target-async".
* gdb.base/dprintf-non-stop.exp: Don't enable target-async.
* gdb.base/gdb-sigterm.exp: Don't test with "target-async".
* gdb.base/inferior-died.exp: Don't enable target-async.
* gdb.base/interrupt-noterm.exp: Likewise.
* gdb.mi/mi-async.exp: Use "mi-async" instead of "target-async".
* gdb.mi/mi-nonstop-exit.exp: Likewise.
* gdb.mi/mi-nonstop.exp: Likewise.
* gdb.mi/mi-ns-stale-regcache.exp: Likewise.
* gdb.mi/mi-nsintrall.exp: Likewise.
* gdb.mi/mi-nsmoribund.exp: Likewise.
* gdb.mi/mi-nsthrexec.exp: Likewise.
* gdb.mi/mi-watch-nonstop.exp: Likewise.
* gdb.multi/watchpoint-multi.exp: Adjust comment.
* gdb.python/py-evsignal.exp: Don't enable target-async.
* gdb.python/py-evthreads.exp: Likewise.
* gdb.python/py-prompt.exp: Likewise.
* gdb.reverse/break-precsave.exp: Don't test with "target-async".
* gdb.server/solib-list.exp: Don't enable target-async.
* gdb.threads/thread-specific-bp.exp: Likewise.
* lib/mi-support.exp: Adjust to use mi-async.

10 years agoMake display_gdb_prompt CLI-only.
Pedro Alves [Fri, 23 May 2014 10:37:12 +0000 (11:37 +0100)] 
Make display_gdb_prompt CLI-only.

Enabling target-async by default will require implementing sync
execution on top of an async target, much like foreground command are
implemented on the CLI in async mode.

In order to do that, we will need better control of when to print the
MI prompt.  Currently the interp->display_prompt_p hook is all we
have, and MI just always returns false, meaning, make
display_gdb_prompt a no-op.  We'll need to be able to know to print
the MI prompt in some of the conditions that display_gdb_prompt is
called from the core, but not all.

This is all a litte twisted currently.  As we can see,
display_gdb_prompt is really CLI specific, so make the console
interpreters (console/tui) themselves call it.  To be able to do that,
and add a few different observers that the interpreters can use to
distinguish when or why the the prompt is being printed:

#1 - one called whenever a command is cancelled due to an error.
#2 - another for when a foreground command just finished.

In both cases, CLI wants to print the prompt, while MI doesn't.

MI will want to print the prompt in the second case when in a special
MI mode.

The display_gdb_prompt call in interp_set made me pause.  The comment
there reads:

  /* Finally, put up the new prompt to show that we are indeed here.
     Also, display_gdb_prompt for the console does some readline magic
     which is needed for the console interpreter, at least...  */

But, that looks very much like a no-op to me currently:

 - the MI interpreter always return false in the prompt hook, meaning
   actually display no prompt.

 - the interpreter used at that point is still quiet.  And the
   console/tui interpreters return false in the prompt hook if they're
   quiet, meaning actually display no prompt.

The only remaining possible use would then be the readline magic.  But
whatever that might have been, it's not reacheable today either,
because display_gdb_prompt returns early, before touching readline if
the interpreter returns false in the display_prompt_p hook.

Tested on x86_64 Fedora 20, sync and async modes.

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

* cli/cli-interp.c (cli_interpreter_display_prompt_p): Delete.
(_initialize_cli_interp): Adjust.
* event-loop.c: Include "observer.h".
(start_event_loop): Notify 'command_error' observers instead of
calling display_gdb_prompt.  Remove FIXME comment.
* event-top.c (display_gdb_prompt): Remove call into the
interpreters.
* inf-loop.c: Include "observer.h".
(inferior_event_handler): Notify 'command_error' observers instead
of calling display_gdb_prompt.
* infrun.c (fetch_inferior_event): Notify 'sync_execution_done'
observers instead of calling display_gdb_prompt.
* interps.c (interp_set): Don't call display_gdb_prompt.
(current_interp_display_prompt_p): Delete.
* interps.h (interp_prompt_p): Delete declaration.
(interp_prompt_p_ftype): Delete.
(struct interp_procs) <prompt_proc_p>: Delete field.
(current_interp_display_prompt_p): Delete declaration.
* mi-interp.c (mi_interpreter_prompt_p): Delete.
(_initialize_mi_interp): Adjust.
* tui-interp.c (tui_init): Install 'sync_execution_done' and
'command_error' observers.
(tui_on_sync_execution_done, tui_on_command_error): New
functions.
(tui_display_prompt_p): Delete.
(_initialize_tui_interp): Adjust.

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

* observer.texi (sync_execution_done, command_error): New
subjects.

10 years agoPR gdb/13860 - Make MI sync vs async output (closer to) the same.
Pedro Alves [Thu, 29 May 2014 12:09:45 +0000 (13:09 +0100)] 
PR gdb/13860 - Make MI sync vs async output (closer to) the same.

Ignoring expected and desired differences like whether the prompt is
output after *stoppped records, GDB MI output is still different in
sync and async modes.

In sync mode, when a CLI execution command is entered, the "reason"
field is missing in the *stopped async record.  And in async mode, for
some events, like program exits, the corresponding CLI output is
missing in the CLI channel.

Vis, diff between sync vs async modes:

   run
   ^running
   *running,thread-id="1"
   (gdb)
   ...
 - ~"[Inferior 1 (process 15882) exited normally]\n"
   =thread-exited,id="1",group-id="i1"
   =thread-group-exited,id="i1",exit-code="0"
 - *stopped
 + *stopped,reason="exited-normally"

   si
   ...
   (gdb)
   ~"0x000000000045e033\t29\t  memset (&args, 0, sizeof args);\n"
 - *stopped,frame=...,thread-id="1",stopped-threads="all",core="0"
 + *stopped,reason="end-stepping-range",frame=...,thread-id="1",stopped-threads="all",core="0"
   (gdb)

In addition, in both cases, when a MI execution command is entered,
and a breakpoint triggers, the event is sent to the console too.  But
some events like program exits have the CLI output missing in the CLI
channel:

   -exec-run
   ^running
   *running,thread-id="1"
   (gdb)
   ...
   =thread-exited,id="1",group-id="i1"
   =thread-group-exited,id="i1",exit-code="0"
 - *stopped
 + *stopped,reason="exited-normally"

We'll want to make background commands always possible by default.
IOW, make target-async be the default.  But, in order to do that,
we'll need to emulate MI sync on top of an async target.  That means
we'll have yet another combination to care for in the testsuite.

Rather than making the testsuite cope with all these differences, I
thought it better to just fix GDB to always have the complete output,
no matter whether it's in sync or async mode.

This is all related to interpreter-exec, and the corresponding uiout
switching.  (Typing a CLI command directly in MI is shorthand for
running it through -interpreter-exec console.)

In sync mode, when a CLI command is active, normal_stop is called when
the current interpreter and uiout are CLI's.  So print_XXX_reason
prints the stop reason to CLI uiout (only), and we don't show it in
MI.

In async mode the stop event is processed when we're back in the MI
interpreter, so the stop reason is printed directly to the MI uiout.

Fix this by making run control event printing roughly independent of
whatever is the current interpreter or uiout.  That is, move these
prints to interpreter observers, that know whether to print or be
quiet, and if printing, which uiout to print to.  In the case of the
console/tui interpreters, only print if the top interpreter.  For MI,
always print.

Breakpoint hits / normal stops are already handled similarly -- MI has
a normal_stop observer that prints the event to both MI and the CLI,
though that could be cleaned up further in the direction of this
patch.

This also makes all of:

 (gdb) foo
and
 (gdb) interpreter-exec MI "-exec-foo"
and
 (gdb)
 -exec-foo
and
 (gdb)
 -interpreter-exec console "foo"

print as expected.

Tested on x86_64 Fedora 20, sync and async modes.

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

PR gdb/13860
* cli/cli-interp.c: Include infrun.h and observer.h.
(cli_uiout, cli_interp): New globals.
(cli_on_signal_received, cli_on_end_stepping_range)
(cli_on_signal_exited, cli_on_exited, cli_on_no_history): New
functions.
(cli_interpreter_init): Install them as 'end_stepping_range',
'signal_received' 'signal_exited', 'exited' and 'no_history'
observers.
(_initialize_cli_interp): Remove cli_interp local.
* infrun.c (handle_inferior_event): Call the several stop reason
observers instead of printing the stop reason directly.
(end_stepping_range): New function.
(print_end_stepping_range_reason, print_signal_exited_reason)
(print_exited_reason, print_signal_received_reason)
(print_no_history_reason): Make static, and add an uiout
parameter.  Print to that instead of to CURRENT_UIOUT.
* infrun.h (print_end_stepping_range_reason)
(print_signal_exited_reason, print_exited_reason)
(print_signal_received_reason print_no_history_reason): New
declarations.
* mi/mi-common.h (struct mi_interp): Rename 'uiout' field to
'mi_uiout'.
<cli_uiout>: New field.
* mi/mi-interp.c (mi_interpreter_init): Adjust.  Create the new
uiout for CLI output.  Install 'signal_received',
'end_stepping_range', 'signal_exited', 'exited' and 'no_history'
observers.
(find_mi_interpreter, mi_interp_data, mi_on_signal_received)
(mi_on_end_stepping_range, mi_on_signal_exited, mi_on_exited)
(mi_on_no_history): New functions.
(ui_out_free_cleanup): Delete function.
(mi_on_normal_stop): Don't allocate a new uiout for CLI output,
instead use the one already stored in the MI interpreter data.
(mi_ui_out): Adjust.
* tui/tui-interp.c: Include infrun.h and observer.h.
(tui_interp): New global.
(tui_on_signal_received, tui_on_end_stepping_range)
(tui_on_signal_exited, tui_on_exited)
(tui_on_no_history): New functions.
(tui_init): Install them as 'end_stepping_range',
'signal_received' 'signal_exited', 'exited' and 'no_history'
observers.
(_initialize_tui_interp): Delete tui_interp local.

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

PR gdb/13860
* observer.texi (signal_received, end_stepping_range)
(signal_exited, exited, no_history): New observer subjects.

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

PR gdb/13860
* gdb.mi/mi-cli.exp: Always expect "end-stepping-range" stop
reason, even in sync mode.

10 years agoPR gdb/15713 - errors from i386_linux_resume lead to lock-up
Pedro Alves [Thu, 29 May 2014 11:50:48 +0000 (12:50 +0100)] 
PR gdb/15713 - errors from i386_linux_resume lead to lock-up

linux_nat_resume is not considering that linux_ops->to_resume may throw:

  /* Mark LWP as not stopped to prevent it from being continued by
     linux_nat_resume_callback.  */
  lp->stopped = 0;

  if (resume_many)
    iterate_over_lwps (ptid, linux_nat_resume_callback, NULL);

If something within linux_nat_resume_callback throws, GDB leaves the
lwp_info as if the inferior was resumed, while it actually wasn't.

A couple examples, there are possibly others:

 - i386_linux_resume calls target_read which calls QUIT.
 - if the actual ptrace resumption fails in inf_ptrace_resume,
   perror_with_name is called.

If the user tries to kill the inferior at this point (or quit, which
offers to kill), GDB locks up trying to stop the lwp -- if it is
already stopped no new waitpid event gets generated for it.

Fix this by setting the stopped flag earlier, as soon as we collect a
stop event with waitpid, and clearing it always only after resuming
the lwp successfully.

Tested on x86_64 Fedora 20.  Confirmed the lock-up disappears using a
local hack that forces an error in inf_ptrace_resume.

Also fixes a little "set debug lin-lwp" annoyance.  Currently we always see:

 Continuing.
 LLR: Preparing to resume process 6802, 0, inferior_ptid Thread 0x7ffff7fc7740 (LWP 6802)
                                                                                ^^^^^^^^
 RC: Resuming sibling Thread 0x7ffff77c5700 (LWP 6807), 0, resume
 RC: Resuming sibling Thread 0x7ffff7fc6700 (LWP 6806), 0, resume
 RC: Not resuming sibling Thread 0x7ffff7fc7740 (LWP 6802) (not stopped)
                                                 ^^^^^^^^^^^^^^^^^^^^^^^
 LLR: PTRACE_CONT process 6802, 0 (resume event thread)

This patch gets rid of the "Not resuming sibling" line.

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

PR gdb/15713
* linux-nat.c (linux_nat_resume_callback): Rename the second
parameter to 'except'.  Skip LP if it points to EXCEPT.
(linux_nat_resume): Don't mark the event lwp as not stopped
before resuming sibling lwps.  Instead ask
linux_nat_resume_callback to skip the event lwp.  Mark it as not
stopped after actually resuming it.
(linux_handle_syscall_trap): Mark the lwp as not stopped after
resuming it.
(wait_lwp): Mark the lwp as stopped here.
(stop_wait_callback): Mark the lwp as not stopped right after
resuming it.  Don't mark lwps as stopped here.
(linux_nat_filter_event): Mark the lwp as stopped earlier.
(linux_nat_wait_1): Don't mark dead lwps as stopped here.

10 years agoPR15693 - Fix spurious *running events, thread state, dprintf-style call
Pedro Alves [Thu, 29 May 2014 11:27:01 +0000 (12:27 +0100)] 
PR15693 - Fix spurious *running events, thread state, dprintf-style call

If one sets a breakpoint with a condition that involves calling a
function in the inferior, and then the condition evaluates false, GDB
outputs one *running event for each time the program hits the
breakpoint.  E.g.,

  $ gdb return-false -i=mi

  (gdb)
  start
  ...
  (gdb)
  b 14 if return_false ()
  &"b 14 if return_false ()\n"
  ~"Breakpoint 2 at 0x4004eb: file return-false.c, line 14.\n"
  ...
  ^done
  (gdb)
  c
  &"c\n"
  ~"Continuing.\n"
  ^running
  *running,thread-id=(...)
  (gdb)
  *running,thread-id=(...)
  *running,thread-id=(...)
  *running,thread-id=(...)
  *running,thread-id=(...)
  *running,thread-id=(...)
  ... repeat forever ...

An easy way a user can trip on this is with a dprintf with "set
dprintf-style call".  In that case, a dprintf is just a breakpoint
that when hit GDB calls the printf function in the inferior, and then
resumes it, just like the case above.

If the breakpoint/dprintf is set in a loop, then these spurious events
can potentially slow down a frontend much, if it decides to refresh
its GUI whenever it sees this event (Eclipse is one such case).

When we run an infcall, we pretend we don't actually run the inferior.
This is already handled for the usual case of calling a function
directly from the CLI:

 (gdb)
 p return_false ()
 &"p return_false ()\n"
 ~"$1 = 0"
 ~"\n"
 ^done
 (gdb)

Note no *running, nor *stopped events.  That's handled by:

 static void
 mi_on_resume (ptid_t ptid)
 {
...
   /* Suppress output while calling an inferior function.  */
   if (tp->control.in_infcall)
     return;

and equivalent code on normal_stop.

However, in the cases of the PR, after finishing the infcall there's
one more resume, and mi_on_resume doesn't know that it should suppress
output then too, somehow.

The "running/stopped" state is a high level user/frontend state.
Internal stops are invisible to the frontend.  If follows from that
that we should be setting the thread to running at a higher level
where we still know the set of threads the user _intends_ to resume.

Currently we mark a thread as running from within target_resume, a low
level target operation.  As consequence, today, if we resume a
multi-threaded program while stopped at a breakpoint, we see this:

 -exec-continue
 ^running
 *running,thread-id="1"
 (gdb)
 *running,thread-id="all"

The first *running was GDB stepping over the breakpoint, and the
second is GDB finally resuming everything.

Between those two *running's, threads other than "1" still have their
state set to stopped.  That's bogus -- in async mode, this opens a
tiny window between both resumes where the user might try to run
another execution command to threads other than thread 1, and very
much confuse GDB.

That is, the "step" below should fail the "step", complaining that the
thread is running:

  (gdb) c -a &
  (gdb) thread 2
  (gdb) step

IOW, threads that GDB happens to not resume immediately (say, because
it needs to step over a breakpoint) shall still be marked as running.

Then, if we move marking threads as running to a higher layer,
decoupled from target_resume, plus skip marking threads as running
when running an infcall, the spurious *running events disappear,
because there will be no state transitions at all.

I think we might end up adding a new thread state -- THREAD_INFCALL or
some such, however since infcalls are always synchronous today, I
didn't find a need.  There's no way to execute a CLI/MI command
directly from the prompt if some thread is running an infcall.

Tested on x86_64 Fedora 20.

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

PR PR15693
* infrun.c (resume): Determine how much to resume depending on
whether the caller wanted a step, not whether we can hardware step
the target.  Mark all threads that we intend to run as running,
unless we're calling an inferior function.
(normal_stop): If the thread is running an infcall, don't finish
thread state.
* target.c (target_resume): Don't mark threads as running here.

gdb/testsuite/
2014-05-29  Pedro Alves  <palves@redhat.com>
    Hui Zhu  <hui@codesourcery.com>

PR PR15693
* gdb.mi/mi-condbreak-call-thr-state-mt.c: New file.
* gdb.mi/mi-condbreak-call-thr-state-st.c: New file.
* gdb.mi/mi-condbreak-call-thr-state.c: New file.
* gdb.mi/mi-condbreak-call-thr-state.exp: New file.

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

10 years agoFix demangler testsuite crashes with CP_DEMANGLE_DEBUG defined
Pedro Alves [Wed, 28 May 2014 22:06:44 +0000 (23:06 +0100)] 
Fix demangler testsuite crashes with CP_DEMANGLE_DEBUG defined

Running the demangler's testsuite with CP_DEMANGLE_DEBUG defined
crashes, with:

 Program received signal SIGSEGV, Segmentation fault.
 0x000000000040a8c3 in d_dump (dc=0x1, indent=12) at ../../src/libiberty/cp-demangle.c:567
 567       switch (dc->type)

 (gdb) bt 3
 #0  0x000000000040a8c3 in d_dump (dc=0x1, indent=12) at ../../src/libiberty/cp-demangle.c:567
 #1  0x000000000040ae47 in d_dump (dc=0x7fffffffd098, indent=10) at ../../src/libiberty/cp-demangle.c:787
 #2  0x000000000040ae47 in d_dump (dc=0x7fffffffd0c8, indent=8) at ../../src/libiberty/cp-demangle.c:787

Note dc=0x1, which is obviously a bogus pointer.  This is the end of
d_dump recursing for a component type that that doesn't actually have
subtrees:

 787       d_dump (d_left (dc), indent + 2);
 788       d_dump (d_right (dc), indent + 2);

This fixes the two cases the testsuite currently trips on.

libiberty/
2014-05-28  Pedro Alves  <palves@redhat.com>

* cp-demangle.c (d_dump): Handle DEMANGLE_COMPONENT_FUNCTION_PARAM
and DEMANGLE_COMPONENT_NUMBER.

10 years agoFix test in libiberty/testsuite/demangle-expected.
Thomas Schwinge [Wed, 28 May 2014 22:06:43 +0000 (23:06 +0100)] 
Fix test in libiberty/testsuite/demangle-expected.

libiberty/
* testsuite/demangle-expected: Fix last commit.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@210803 138bc75d-0d04-0410-961f-82ee72b054a4

10 years agocplus-demangler, free resource after a failed call to gnu_special.
Andrew Burgess [Wed, 28 May 2014 22:06:43 +0000 (23:06 +0100)] 
cplus-demangler, free resource after a failed call to gnu_special.

libiberty/
2014-05-14  Andrew Burgess  <aburgess@broadcom.com>

* cplus-dmem.c (internal_cplus_demangle): Free any resources
allocated by possible previous call to gnu_special.
(squangle_mop_up): Reset pointers to NULL after calling free.
* testsuite/demangle-expected: New test case.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@210425 138bc75d-0d04-0410-961f-82ee72b054a4

10 years agoRemove "set/show remotebaud" (deprecated) commands.
Joel Brobecker [Mon, 19 May 2014 18:46:19 +0000 (11:46 -0700)] 
Remove "set/show remotebaud" (deprecated) commands.

This patch removes support for the "set/show remotebaud" command,
which were deprecated in GDB 7.7, and should be now be removed
ahead of cutting the GDB 7.8 branch.

gdb/ChangeLog:

        * serial.c (_initialize_serial): Remove support for
        the "set remotebaud" and "show remotebaud" commands.
        * NEWS: Add entry documenting the removal of that command.

gdb/testsuite/ChangeLog:

        * config/monitor.exp (gdb_target_monitor): Replace use of
        "set remotebaud" by "set serial baud".

10 years agold: Split GENSCRIPTS rule from dependencies to fix tdir_'s.
Hans-Peter Nilsson [Wed, 28 May 2014 16:20:16 +0000 (18:20 +0200)] 
ld: Split GENSCRIPTS rule from dependencies to fix tdir_'s.

* Makefile.am: Change all rules with ${GENSCRIPTS}
invocations to be just dependencies.
($(ALL_EMULATION_SOURCES) $(ALL_64_EMULATION_SOURCES))
(run-genscripts): New rules.
* Makefile.in: Regenerate.

10 years agoAdd objcopy stage between assembly and linking for run_dump_test
mfortune [Tue, 27 May 2014 11:37:50 +0000 (12:37 +0100)] 
Add objcopy stage between assembly and linking for run_dump_test

ld/testsuite/

* lib/ld-lib.exp: Add objcopy_objects command to run_dump_test.
This allows each input object to be optionally run through
objcopy before linking.

10 years agoFix rx "set but not used" warnings
Alan Modra [Wed, 28 May 2014 12:58:53 +0000 (22:28 +0930)] 
Fix rx "set but not used" warnings

* elf32-rx.c (rx_table_map): Delete set but not used variables.

10 years agoaddr2line: fix missing inlined frames.
Tristan Gingold [Wed, 28 May 2014 07:21:11 +0000 (09:21 +0200)] 
addr2line: fix missing inlined frames.

2014-05-28  Tristan Gingold  <gingold@adacore.com>

* dwarf2.c (lookup_address_in_function_table): Add best_fit_len
to keep the length of the best fit range.
(lookup_symbol_in_function_table, info_hash_lookup_funcinfo):
Likewise.

10 years agoFix typo in comments
Yao Qi [Tue, 27 May 2014 12:00:37 +0000 (20:00 +0800)] 
Fix typo in comments

 "unsed" -> "used"

gdb:

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

* charset.c: Fix typo in comments.

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

10 years agoFix typo.
DJ Delorie [Tue, 27 May 2014 23:05:18 +0000 (19:05 -0400)] 
Fix typo.

10 years agoAdd new link-map-text hook and RX auto-vector support.
DJ Delorie [Tue, 27 May 2014 21:14:49 +0000 (17:14 -0400)] 
Add new link-map-text hook and RX auto-vector support.

* bfd/elf32-rx.c (get_symbol_value_maybe): New.
(rx_elf_relocate_section): If we find a reloc against
$tableentry$default$<name>, redirect it to the appropriate
$tableentry$<n>$.
(RX_Table_Info): New.
(rx_table_find): New.  Check all tables and SEC_KEEP all sections
with table parts in them.
(rx_check_directives): New.
(rx_table_map_2): New.
(rx_table_map): New.
(rx_additional_link_map_text): New.  Called to dump tables to the
map file.
* bfd/elf32-rx.h: New.

* ld/ldemul.h (extra_map_file_text): New field.
(ldemul_extra_map_file_text): Declare.
* ld/ldemul.c (ldemul_extra_map_file_text): Define.
* ld/ldlang.c (lang_map): Call it.

* ld/emultempl/rxelf.em: Add extra_map_file_text hook.
* ld/emultempl/aix.em: Add NULL extra_map_file_text hook.
* ld/emultempl/armcoff.em: Likewise.
* ld/emultempl/beos.em: Likewise.
* ld/emultempl/elf32.em: Likewise.
* ld/emultempl/generic.em: Likewise.
* ld/emultempl/gld960.em: Likewise.
* ld/emultempl/gld960c.em: Likewise.
* ld/emultempl/linux.em: Likewise.
* ld/emultempl/lnk960.em: Likewise.
* ld/emultempl/m68kcoff.em: Likewise.
* ld/emultempl/pe.em: Likewise.
* ld/emultempl/pep.em: Likewise.
* ld/emultempl/sunos.em: Likewise.
* ld/emultempl/ticoff.em: Likewise.
* ld/emultempl/vanilla.em: Likewise.

10 years agoProperly handle 64-bit GOT relocations
H.J. Lu [Tue, 27 May 2014 19:19:33 +0000 (12:19 -0700)] 
Properly handle 64-bit GOT relocations

This patch fixes 2 issues:

1. Since the GOT offset is always negative, we need to use signed int
to support 64-bit GOT relocations.
2. R_X86_64_PLTOFF64 uses the address of GLOBAL_OFFSET_TABLE, which is
the address of the .got.plt section, not the .got section.

10 years agoPrompt the user to file bug reports for internal errors and warnings.
Gary Benson [Tue, 27 May 2014 14:30:58 +0000 (15:30 +0100)] 
Prompt the user to file bug reports for internal errors and warnings.

2014-05-27  Gary Benson  <gbenson@redhat.com>

* utils.c (internal_vproblem): Prompt for a bug report.

10 years agoremove unnecessary smob mark/free functions
Andy Wingo [Tue, 27 May 2014 01:11:58 +0000 (18:11 -0700)] 
remove unnecessary smob mark/free functions

* guile/scm-arch.c (arscm_mark_arch_smob):
* guile/scm-block.c (bkscm_mark_block_smob)
(bkscm_mark_block_syms_progress_smob):
* guile/scm-breakpoint.c (bpscm_mark_breakpoint_smob):
* guile/scm-exception.c (exscm_mark_exception_smob):
* guile/scm-frame.c (frscm_mark_frame_smob):
* guile/scm-iterator.c (itscm_mark_iterator_smob):
* guile/scm-lazy-string.c (lsscm_mark_lazy_string_smob):
* guile/scm-objfile.c (ofscm_mark_objfile_smob):
* guile/scm-pretty-print.c (ppscm_mark_pretty_printer_smob)
(ppscm_mark_pretty_printer_worker_smob):
* guile/scm-symbol.c (syscm_mark_symbol_smob):
* guile/scm-symtab.c (stscm_mark_symtab_smob, stscm_mark_sal_smob):
* guile/scm-type.c (tyscm_mark_type_smob, tyscm_mark_field_smob):
* guile/scm-value.c (vlscm_mark_value_smob): Remove unnecessary
mark functions.
* guile/scm-symtab.c (stscm_free_sal_smob): Remove unnecessary free
function.

10 years agogdb smob cleanups
Andy Wingo [Tue, 27 May 2014 00:34:27 +0000 (17:34 -0700)] 
gdb smob cleanups

* guile/guile-internal.h (GDB_SMOB_HEAD): Replace properties with
empty_base_class.  All uses updated.
(gdbscm_mark_gsmob, gdbscm_mark_chained_gsmob)
(gdbscm_mark_eqable_gsmob): Remove these now-unneeded functions.
Adapt all callers.
* guile/scm-gsmob.c (gdbscm_mark_gsmob)
(gdbscm_mark_chained_gsmob, gdbscm_mark_eqable_gsmob): Remove.
(gdbscm_gsmob_property, gdbscm_set_gsmob_property_x)
(gdbscm_gsmob_has_property_p, add_property_name)
(gdbscm_gsmob_properties): Remove, and remove them from gsmob_functions.
* guile/lib/gdb.scm (gdb-object-property, set-gdb-object-property)
(gdb-object-has-property?, gdb-object-properties): Remove.
(gdb-object-kind): Renamed from gsmob-kind.

doc/
* guile.texi (GDB Scheme Data Types): Remove documentation for
removed interfaces.  Update spelling of gdb-object-kind.

testsuite/
* gdb.guile/scm-breakpoint.exp:
* gdb.guile/scm-gsmob.exp: Update to use plain old object
properties instead of gdb-object-properties.

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

10 years agoguile.texi (Basic Guile): Fix some typos.
Andy Wingo [Mon, 26 May 2014 22:34:24 +0000 (15:34 -0700)] 
guile.texi (Basic Guile): Fix some typos.

10 years agoFix excess parentheses in use-modules forms.
Andy Wingo [Mon, 26 May 2014 22:06:29 +0000 (15:06 -0700)] 
Fix excess parentheses in use-modules forms.

10 years agoAdd configure support for building with guile 2.2.
Andy Wingo [Mon, 26 May 2014 19:45:13 +0000 (12:45 -0700)] 
Add configure support for building with guile 2.2.

* configure.ac (try_guile_versions): Allow building with guile 2.2.
* configure: Regenerate.

10 years agofix 80 cols overrun in earlier entry
Doug Evans [Mon, 26 May 2014 19:32:09 +0000 (12:32 -0700)] 
fix 80 cols overrun in earlier entry

10 years agoSpecify source file explicitly when setting a breakpoint
Yao Qi [Tue, 20 May 2014 05:45:54 +0000 (13:45 +0800)] 
Specify source file explicitly when setting a breakpoint

When I run no-thread-db.exp, the breakpoint is set on line 26.
However, the breakpoint is set to line 26 of dl-start.S rather than
no-thread-db.c, which is not intended.

(gdb) monitor set libthread-db-search-path /foo/bar^M
libthread-db-search-path set to `/foo/bar'^M
(gdb) PASS: gdb.server/no-thread-db.exp: libthread-db is now unresolvable
break 26^M
Breakpoint 1 at 0x48018078: file ../sysdeps/powerpc/powerpc32/dl-start.S, line 26.^M
(gdb) continue^M
Continuing.

This patch is to change the breakpoint setting with source file
specified, then it is correct now.

gdb/testsuite:

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

* gdb.server/no-thread-db.exp: Specify source file name
explicitly when setting a breakpoint.

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

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

10 years agoLocalize varible to avoid warning
Alan Modra [Sat, 24 May 2014 13:10:11 +0000 (22:40 +0930)] 
Localize varible to avoid warning

* ldlang.c (base): Move variable to..
* mri.c: ..here, and make static.
* ldlang.h (base): Delete declaration.

10 years agoDon't use @var at the beginning of a sentence in GDB documentation.
Eli Zaretskii [Sat, 24 May 2014 10:02:42 +0000 (13:02 +0300)] 
Don't use @var at the beginning of a sentence in GDB documentation.

gdb/doc/guile.texi (Types In Guile, Basic Guile, Frames In Guile)
(Breakpoints In Guile, Guile Printing Module)
(Guile Exception Handling, Values From Inferior In Guile)
(Objfiles In Guile, Breakpoints In Guile, Memory Ports in Guile):
Don't use @var at the beginning of a sentence.
gdb/doc/gdb.texinfo (Frame Filter Management, Trace Files)
(C Operators, Ada Tasks, Calling, Bootstrapping, ARM)
(PowerPC Embedded, Define, Annotations for Running)
(IPA Protocol Commands, Packets, General Query Packets)
(Tracepoint Packets, Notification Packets, Environment)
(Inferiors and Programs, Set Breaks, Set Catchpoints)
(Continuing and Stepping, Signals, Thread-Specific Breakpoints)
(Frames, Backtrace, Selection, Expressions, Registers)
(Trace State Variables, Built-In Func/Proc, Signaling, Files)
(Numbers, GDB/MI Async Records, GDB/MI Data Manipulation)
(Source Annotations, Using JIT Debug Info Readers, Packets)
(Stop Reply Packets, Host I/O Packets)
(Target Description Format): Don't use @var at the beginning of a
sentence.
gdb/doc/python.texi (Basic Python, Types In Python)
(Commands In Python, Frames In Python, Line Tables In Python)
(Breakpoints In Python, gdb.printing, gdb.types)
(Type Printing API): Don't use @var at the beginning of a
sentence.

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

10 years agoInclude asm/ptrace.h for linux-aarch64-low.c
Ramana Radhakrishnan [Fri, 23 May 2014 08:01:14 +0000 (09:01 +0100)] 
Include asm/ptrace.h for linux-aarch64-low.c

A recent change to glibc removed asm/ptrace.h from user.h for AArch64.
This meant that cross-native builds of gdbserver using trunk glibc broke
because linux-aarch64-low.c because user_hwdebug_state couldn't be found.

This is like commit #036cd38182bde32d8297b630cd5c861d53b8949e

2014-05-23  Ramana Radhakrishnan  <ramana.radhakrishnan@arm.com>

        * linux-aarch64-low.c (asm/ptrace.h): Include.

10 years agobtrace, vdso: add vdso target sections
Markus Metzger [Wed, 2 Apr 2014 07:54:11 +0000 (09:54 +0200)] 
btrace, vdso: add vdso target sections

When loading symbols for the vdso, also add its sections to target_sections.

This fixes an issue with record btrace where vdso instructions could not be
disassembled during replay.

* symfile-mem.c (symbol_file_add_from_memory): Add BFD sections.

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

10 years agotest, gcore: move capture_command_output into lib/gdb.exp
Markus Metzger [Tue, 20 May 2014 07:48:43 +0000 (09:48 +0200)] 
test, gcore: move capture_command_output into lib/gdb.exp

Allow gcore's capture_command_output function to be used by other tests.

testsuite/
* gdb.base/gcore.exp (capture_command_output): Move ...
* lib/gdb.exp (capture_command_output): ... here.

10 years agobtrace: control memory access during replay
Markus Metzger [Wed, 5 Mar 2014 14:38:11 +0000 (15:38 +0100)] 
btrace: control memory access during replay

The btrace record target does not trace data.  We therefore do not allow
accessing read-write memory during replay.

In some cases, this might be useful to advanced users, though, who we assume
to know what they are doing.

Add a set|show command pair to turn this memory access restriction off.

* record-btrace.c (record_btrace_allow_memory_access): Remove.
(replay_memory_access_read_only, replay_memory_access_read_write)
(replay_memory_access_types, replay_memory_access)
(set_record_btrace_cmdlist, show_record_btrace_cmdlist)
(cmd_set_record_btrace, cmd_show_record_btrace)
(cmd_show_replay_memory_access): New.
(record_btrace_xfer_partial, record_btrace_insert_breakpoint)
(record_btrace_remove_breakpoint): Replace
record_btrace_allow_memory_access with replay_memory_access.
(_initialize_record_btrace): Add commands.
* NEWS: Announce it.

testsuite/
* gdb.btrace/data.exp: Test it.

doc/
* gdb.texinfo (Process Record and Replay): Document it.

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

10 years agoAdd comment for mi_run_cmd_full
Simon Marchi [Thu, 22 May 2014 18:01:46 +0000 (14:01 -0400)] 
Add comment for mi_run_cmd_full

It should clear up confusion about the args parameter to mi_run_cmd_full.

Thanks to Joel for clear formulation. I also added a comment about the
impact of use_gdb_stub.

gdb/testsuite/ChangeLog:

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

* lib/mi-support.exp (mi_run_cmd_full): Add comments.

10 years agoInclude asm/ptrace.h in aarch64-linux-nat.c
Ramana Radhakrishnan [Thu, 22 May 2014 15:07:20 +0000 (16:07 +0100)] 
Include asm/ptrace.h in aarch64-linux-nat.c

A recent change to glibc removed asm/ptrace.h from user.h for
AArch64. This meant that cross-native builds of gdb using trunk
glibc broke because aarch64-linux-nat.c because user_hwdebug_state
couldn't be found.

Fixed by including asm/ptrace.h like other ports.

2014-05-22  Ramana Radhakrishnan  <ramana.radhakrishnan@arm.com>

       * aarch64-linux-nat.c (asm/ptrace.h): Include.

10 years agoReinstate self to Write After Approval
Ramana Radhakrishnan [Thu, 22 May 2014 15:06:33 +0000 (16:06 +0100)] 
Reinstate self to Write After Approval

2014-05-22  Ramana Radhakrishnan  <ramana.radhakrishnan@arm.com>

* MAINTAINERS (Write After Approval): Move self back from
paper trail.

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.

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