Commit Graph

1070 Commits

Author SHA1 Message Date
Dimitar Dimitrov ddd44b7053 sim: Add PRU simulator port
A simulator port for the TI PRU I/O processor.

v1: https://sourceware.org/ml/gdb-patches/2016-12/msg00143.html
v2: https://sourceware.org/ml/gdb-patches/2017-02/msg00397.html
v3: https://sourceware.org/ml/gdb-patches/2017-02/msg00516.html
v4: https://sourceware.org/ml/gdb-patches/2018-06/msg00484.html
v5: https://sourceware.org/ml/gdb-patches/2019-08/msg00584.html
v6: https://sourceware.org/ml/gdb-patches/2019-09/msg00036.html

gdb/ChangeLog:

	* NEWS: Mention new simulator port for PRU.

sim/ChangeLog:

	* MAINTAINERS: Add myself as PRU maintainer.
	* configure: Regenerated.
	* configure.tgt: Add PRU.

sim/common/ChangeLog:

	* gennltvals.sh: Add PRU libgloss target.
	* nltvals.def: Regenerate from the latest libgloss sources.

sim/pru/ChangeLog:

	* Makefile.in: New file.
	* aclocal.m4: Regenerated.
	* config.in: Regenerated.
	* configure: Regenerated.
	* configure.ac: New file.
	* interp.c: New file.
	* pru.h: New file.
	* pru.isa: New file.
	* sim-main.h: New file.
2019-09-23 22:11:02 +01:00
Joel Brobecker 5a3a0d6304 gdb/NEWS: Move entries about MI v3 and multi-loc breakpoints after GDB 8.3
This is a followup on the following commit...

    commit b4be1b0648
    Date:   Wed Mar 13 15:13:03 2019 -0400
    Subject: Fix MI output for multi-location breakpoints

... which mistakenly added NEWS entries in the "in gdb-8.3" section,
rather than in the "since gdb-8.3" one.

gdb/ChangeLog:

	* NEWS: Move entries about default MI version now being
        version 3, and about the GDB/MI fix for multi-location
        breakpoints to the "since GDB 8.3" section.
2019-09-20 16:23:15 -07:00
Ulrich Weigand abf516c693 Remove Cell Broadband Engine debugging support
This patch implements removal of Cell/B.E. support, including
- Support for the spu-*-* target
- Support for native stand-alone SPU debugging
- Support for integrated debugging of combined PPU/SPU applications
- Remote debugging (gdbserver) support for all the above.

The patch also removes the TARGET_OBJECT_SPU target object type,
as this is available only on Cell/B.E. targets, including
- Native Linux support
- Core file support (including core file generation)
- Remote target support, including removal of the qXfer:spu:read
  and qXfer:spu:write remote protocal packets and associated
  support in gdbserver.

gdb/ChangeLog
2019-09-20  Ulrich Weigand  <uweigand@de.ibm.com>

	* NEWS: Mention that Cell/B.E. debugging support was removed.
	* MAINTAINERS: Remove spu target.

	* config/djgpp/fnchange.lst: Remove entries for removed files.

	* Makefile.in (ALL_TARGET_OBS): Remove solib-spu.o,
	spu-multiarch.o, and spu-tdep.o.
	(HFILES_NO_SRCDIR): Remove solib-spu.h and spu-tdep.h.
	(ALLDEPFILES): Remove solib-spu.c, spu-linux-nat.c,
	spu-multiarch.c, and spu-tdep.c.
	* spu-linux-nat.c: Remove file.
	* spu-multiarch.c: Remove file.
	* spu-tdep.c: Remove file.
	* spu-tdep.h: Remove file.
	* solib-spu.c: Remove file.
	* solib-spu.h: Remove file.

	* configure.host (powerpc64*-*-linux*): Remove Cell/B.E. support.
	* configure.nat (spu-linux): Remove.
	* configure.tgt (powerpc*-*-linux*): Remove solib-spu.o and
	solib-multiarch.o from gdb_target_obs.
	(spu*-*-*): Remove.

	* arch/ppc-linux-common.h (struct ppc_linux_features): Remove "cell"
	feature flag.
	(ppc_linux_no_features): Update.
	* arch/ppc-linux-common.c (ppc_linux_match_description): Remove
	Cell/B.E. support.
	* arch/ppc-linux-tdesc.h (tdesc_powerpc_cell32l): Remove declaration.
	(tdesc_powerpc_cell64l): Likewise.
	* nat/ppc-linux.h (PPC_FEATURE_CELL): Remove.
	* ppc-linux-nat.c (ppc_linux_nat_target::read_description): Remove
	Cell/B.E. support.
	* ppc-linux-tdep.h: Do not include "solib-spu.h" or "spu-tdep.h".
	Do not include "features/rs6000/powerpc-cell32l.c" or
	"features/rs6000/powerpc-cell64l.c".
	(ppc_linux_spu_section): Remove.
	(ppc_linux_core_read_description): Remove Cell/B.E. support.
	(spe_context_objfile, spe_context_lm_addr, spe_context_offset,
	spe_context_cache_ptid, spe_context_cache_ptid): Remove.
	(ppc_linux_spe_context_lookup): Remove.
	(ppc_linux_spe_context_inferior_created): Remove.
	(ppc_linux_spe_context_solib_loaded): Remove.
	(ppc_linux_spe_context_solib_unloaded): Remove.
	(ppc_linux_spe_context): Remove.
	(struct ppu2spu_cache): Remove.
	(ppu2spu_prev_arch, ppu2spu_this_id, ppu2spu_prev_register): Remove.
	(struct ppu2spu_data): Remove.
	(ppu2spu_unwind_register, ppu2spu_sniffer, ppu2spu_dealloc_cache,
	ppu2spu_unwind): Remove.
	(ppc_linux_init_abi): Remove Cell/B.E. support.
	* rs6000-tdep.h (rs6000_gdbarch_init): Remove Cell/B.E. support.

	* features/Makefile (rs6000/powerpc-cell32l-expedite): Remove.
	(rs6000/powerpc-cell64l-expedite): Likewise
	(WHICH): Remove rs6000/powerpc-cell32l and rs6000/powerpc-cell64l.
	(XMLTOC): Remove rs6000/powerpc-cell32l.xml and
	rs6000/powerpc-cell64l.xml.
	* features/rs6000/powerpc-cell32l.xml: Remove.
	* features/rs6000/powerpc-cell64l.xml: Likewise.
	* features/rs6000/powerpc-cell32l.c: Remove generated file.
	* features/rs6000/powerpc-cell64l.c: Likewise.
	* regformats/rs6000/powerpc-cell32l.dat: Remove generated file.
	* regformats/rs6000/powerpc-cell64l.dat: Likewise.
	* regformats/reg-spu.dat: Remove.

	* target.h (enum target_object): Remove TARGET_OBJECT_SPU.
	* corelow.c (struct spuid_list): Remove.
	(add_to_spuid_list): Remove.
	(core_target::xfer_partial): Remove support for TARGET_OBJECT_SPU.
	* remote.c (PACKET_qXfer_spu_read, PACKET_qXfer_spu_write): Remove.
	(remote_protocol_features): Remove associated entries.
	(_initialize_remote): No longer initialize them.
	(remote_target::xfer_partial): Remove support for TARGET_OBJECT_SPU.
	* linux-nat.c (SPUFS_MAGIC): Remove.
	(linux_proc_xfer_spu): Remove.
	(spu_enumerate_spu_ids): Remove.
	(linux_nat_target::xfer_partial): Remove support for TARGET_OBJECT_SPU.
	* linux-tdep.c (-linux_spu_make_corefile_notes): Remove.
	(linux_make_corefile_notes): No longer call it.

	* regcache.c (cooked_read_test): Remove bfd_arch_spu special case.
	(cooked_write_test): Likewise.

gdb/doc/ChangeLog
2019-09-20  Ulrich Weigand  <uweigand@de.ibm.com>

	* doc/gdb.texinfo (Remote Configuration): Remove documentation for
	qXfer:spu:read and qXfer:spu:write.
	(General Query Packets): Likewise.
	(Cell Broadband Engine SPU architecture): Remove subsection.

gdb/gdbserver/ChangeLog
2019-09-20  Ulrich Weigand  <uweigand@de.ibm.com>

	* configure.srv (ipa_ppc_linux_regobj): Remove powerpc-cell32l-ipa.o
	and powerpc-cell64l-ipa.o.
	(powerpc*-*-linux*): Remove powerpc-cell32l.o and powerpc-cell64l.o
	from srv_regobj.  Remove rs6000/powerpc-cell32l.xml and
	rs6000/powerpc-cell64l.xml from srv_xmlfiles.
	(spu*-*-*): Remove.

	* spu-low.c: Remove file.

	* linux-ppc-low.c (INSTR_SC, NR_spu_run): Remove.
	(parse_spufs_run): Remove.
	(ppc_get_pc): Remove Cell/B.E. support.
	(ppc_set_pc): Likewise.
	(ppc_breakpoint_at): Likewise.
	(ppc_arch_setup): Likewise.
	(ppc_get_ipa_tdesc_idx): Do not handle tdesc_powerpc_cell64l or
	tdesc_powerpc_cell32l.
	(initialize_low_arch): Do not call init_registers_powerpc_cell64l
	or init_registers_powerpc_cell32l.
	* linux-ppc-ipa.c (get_ipa_tdesc): Do not handle PPC_TDESC_CELL.
	(initialize_low_tracepoint): Do not call init_registers_powerpc_cell64l
	or init_registers_powerpc_cell32l.
	* linux-ppc-tdesc-init.h (PPC_TDESC_CELL): Mark as unused.
	(init_registers_powerpc_cell32l): Remove prototype.
	(init_registers_powerpc_cell64l): Likewise.

	* target.h (struct target_ops): Remove qxfer_spu member.
	* server.c (handle_qxfer_spu): Remove.
	(qxfer_packets): Remove entry for "spu".
	(handle_query): No longer support qXfer:spu:read or qXfer:spu:write.
	* linux-low.c (SPUFS_MAGIC): Remove.
	(spu_enumerate_spu_ids): Remove.
	(linux_qxfer_spu): Remove.
	(linux_target_ops): Remove qxfer_spu member.
	* lynx-low.c (lynx_target_ops): Remove qxfer_spu member.
	* nto-low.c (nto_target_ops): Remove qxfer_spu member.
	* win32-low.c (win32_target_ops): Remove qxfer_spu member.

gdb/testsuite/ChangeLog
2019-09-20  Ulrich Weigand  <uweigand@de.ibm.com>

	* gdb.arch/spu-info.exp: Remove file.
	* gdb.arch/spu-info.c: Remove file.
	* gdb.arch/spu-ls.exp: Remove file.
	* gdb.arch/spu-ls.c: Remove file.

	* gdb.asm/asm-source.exp: Remove support for spu*-*-*.
	* gdb.asm/spu.inc: Remove file.

	* gdb.base/dump.exp: Remove support for spu*-*-*.
	* gdb.base/stack-checking.exp: Likewise.
	* gdb.base/overlays.exp: Likewise.
	* gdb.base/ovlymgr.c: Likewise.
	* gdb.base/spu.ld: Remove file.

	* gdb.cp/bs15503.exp: Remove support for spu*-*-*.
	* gdb.cp/cpexprs.exp: Likewise.
	* gdb.cp/exception.exp: Likewise.
	* gdb.cp/gdb2495.exp: Likewise.
	* gdb.cp/mb-templates.exp: Likewise.
	* gdb.cp/pr9167.exp: Likewise.
	* gdb.cp/userdef.exp: Likewise.

	* gdb.xml/tdesc-regs.exp: Remove support for spu*-*-*.

	* gdb.cell: Remove directory.
	* lib/cell.exp: Remove file.
2019-09-20 23:06:57 +02:00
Tom Tromey 78e8cb91cd Change TUI window commands to be case-sensitive
The TUI window-related commands like "focus" are case insensitive.
This is not the norm in gdb, and I don't see a good reason to have it
here.  This patch changes the TUI to be case sensitive, like the rest
of gdb.

gdb/ChangeLog
2019-09-20  Tom Tromey  <tom@tromey.com>

	* NEWS: Mention case-sensitivity of TUI commands.
	* tui/tui-win.c (tui_set_focus_command): Now case-sensitive.
	(tui_set_win_height_command, parse_scrolling_args): Likewise.
	* tui/tui-layout.c (tui_layout_command): Now case-sensitive.
2019-09-20 13:49:12 -06:00
Tom Tromey 11061048d1 Give a name to the TUI SingleKey keymap
Readline 8.0 has a feature that lets an application name a keymap.
This in turn makes it simpler for users to bind keys in keymaps in
their .inputrc.

This patch gives a name to the TUI SingleKey keymap, so that
additional bindings can be made there.  For example:

    $if gdb
    set keymap SingleKey
    "X": "echo hello\\n\n"
    $endif

The call to rl_initialize, in tui_initialize_readline, had to be
removed so that .inputrc was not read too early.  Note that Readline
explicitly documents that this call is not needed.

gdb/ChangeLog
2019-09-18  Tom Tromey  <tom@tromey.com>

	* NEWS: Add entry.
	* tui/tui.c (tui_initialize_readline): Set name of keymap.  Do not
	call rl_initialize.
	(tui_enable): Do not call rl_initialize.

gdb/doc/ChangeLog
2019-09-18  Tom Tromey  <tom@tromey.com>

	* gdb.texinfo (Editing): Document readline application name.
	(TUI Single Key Mode): Document TUI SingleKey keymap name.
2019-09-18 15:03:29 -06:00
Christian Biesinger 6a062a93d7 Add a NEWS entry that gdb can be compiled with py3 on Windows.
This was fixed in commit 272044897e.

2019-09-14  Christian Biesinger  <cbiesinger@google.com>

	* NEWS: Mention that gdb can now be compiled with Python 3
	on Windows.
2019-09-14 22:36:47 -04:00
Philippe Waroquiers 4993045d18 Output the Ada task name in more messages.
With this patch, we e.g. get:
      [Switching to task 2 "task_list(1)"]
      [Current task is 2 "task_list(1)"]
    instead of
      [Switching to task 2]
      [Current task is 2]

The logic to produce the taskno optionally followed
by the task name has been factorized in the task_to_str function.

Task names are output between double quotes in the new messages,
similarly to what GDB does for thread names.
However, no quotes are put around task names in 'info tasks' Name column.
This was discussed with Tom, that preferred no quotes there, while I
was more in favour of visual consistency.
I discussed with a few more users, which led to (exactly) 50% preferring
quotes and 50% preferring no quotes :).
To arrive to the decision to remove the quotes, the following "killing args"
were used:
 * To have quotes or to not have quotes, that is the question; yes
   but not *THE* question :).
 * If there is not a clear majority that prefers quotes, better to
   not disturb the existing user basis for a (somewhat) irrelevant
   aspect.
 * The opinion of the reviewer has more weight.

So, compared to the previous version, this version remotes the quotes
in 'info tasks'.

It improves the alignement of 'info tasks' output.
With this patch, we get:
      (gdb) info task
         ID           TID P-ID Pri State                  Name
      *   1  555555759030       48 Runnable               main_task
          2  555555759e30    1  48 Selective Wait         mit
      (gdb)
   instead of
      (gdb) info task
         ID       TID P-ID Pri State                  Name
      *   1 555555759030       48 Runnable               main_task
          2 555555759e30    1  48 Selective Wait         mit
      (gdb)
(e.g. the first one properly shows parent and priority under the
correct header).

This is version 4 of the 'task name' patch.
Compared to version 3, the changes are:
   output task names between quotes but not in 'info tasks'

gdb/ChangeLog
2019-09-12  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

	* NEWS: Announce that Ada task names are now shown at more places,
	and between quotes (except in info task output).
	* gdb/ada-tasks.c (task_to_str): New function.
	(display_current_task_id): Call task_to_str.
	(task_command_1): Likewise.
	(print_ada_task_info): In non-mi mode, Properly align headers and data
	when task-id length is > 9 (9 is the default for a 32 bits CORE_ADDR).

gdb/doc/ChangeLog
2019-09-12  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

	* gdb.texinfo (Ada Tasks): Tell the task name is printed, update
	examples.

gdb/testsuite/ChangeLog
2019-09-12  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

	* gdb.ada/rdv_wait.exp: Update to new task names.
	* gdb.base/task_switch_in_core.exp: Likewise.
	* gdb.base/info_sources_base.c: Likewise.
2019-09-12 21:57:10 +02:00
Andrew Burgess 4acfdd20c9 gdb: Add new -n flag to some info commands
The 'info variables', its alias 'whereis', and 'info functions' all
include non-debug symbols in the output by default.  The list of
non-debug symbols can sometimes be quite long, resulting in the
debug symbol based results being scrolled off the screen.

This commit adds a '-n' flag to all of the commands listed above that
excludes the non-debug symbols from the results, leaving just the
debug symbol based results.

gdb/ChangeLog:

	* cli/cli-utils.c (info_print_options_defs): Delete.
	(make_info_print_options_def_group): Delete.
	(extract_info_print_options): Delete.
	(info_print_command_completer): Delete.
	(info_print_args_help): Add extra parameter, and optionally
	include text about -n flag.
	* cli/cli-utils.h (struct info_print_options): Delete.
	(extract_info_print_options): Delete declaration.
	(info_print_command_completer): Delete declaration.
	(info_print_args_help): Add extra parameter, extend header
	comment.
	* python/python.c (gdbpy_rbreak): Pass additional parameter to
	search_symbols.
	* stack.c (struct info_print_options): New type.
	(info_print_options_defs): New file scoped variable.
	(make_info_print_options_def_group): New static function.
	(info_print_command_completer): New static function.
	(info_locals_command): Update to use new local functions.
	(info_args_command): Likewise.
	(_initialize_stack): Add extra parameter to calls to
	info_print_args_help.
	* symtab.c (search_symbols): Add extra parameter, use this to
	possibly excluse non-debug symbols.
	(symtab_symbol_info): Add extra parameter, which is passed on to
	search_symbols.
	(struct info_print_options): New type.
	(info_print_options_defs): New file scoped variable.
	(make_info_print_options_def_group): New static function.
	(info_print_command_completer): New static function.
	(info_variables_command): Update to use local functions, and pass
	extra parameter through to symtab_symbol_info.
	(info_functions_command): Likewise.
	(info_types_command): Pass additional argument through to
	symtab_symbol_info.
	(rbreak_command): Pass extra argument to search_symbols.
	(_initialize_symtab): Add extra arguments for calls to
	info_print_args_help, and update help text for 'info variables',
	'whereis', and 'info functions' commands.
	* symtab.h (search_symbols): Add extra argument to declaration.
	* NEWS: Mention new flags.

gdb/doc/ChangeLog:

	* gdb.texinfo (Symbols): Add information about the -n flag to
	"info variables" and "info functions".

gdb/testsuite/ChangeLog:

	* gdb.base/info-fun.exp: Extend to test the -n flag for 'info
	functions'.  Reindent as needed.
	* gdb.base/info-var-f1.c: New file.
	* gdb.base/info-var-f2.c: New file.
	* gdb.base/info-var.exp: New file.
	* gdb.base/info-var.h: New file.
2019-08-27 16:21:42 +01:00
Yoshinori Sato e3ec872f80 Convert the RX target to make use of target descriptions.
gdb/ChangeLog

2019-08-25  Yoshinori Sato <ysato@users.sourceforge.jp>

	* gdb/rx-tdep.c (rx_register_names): New.
	(rx_register_name): Delete.
	(rx_psw_type): Delete.
	(rx_fpsw_type): Delete.
	(rx_register_type): Delete.
	(rx_gdbarch_init): Convert target-descriptions.
	(_initialize_rx_tdep): Add initialize_tdesc_rx.
	* gdb/features/Makefile: Add rx.xml.
	* gdb/features/rx.xml: New.
	* gdb/features/rx.c: Generated.
	* gdb/NEWS: Mention target description support.

gdb/doc/ChangeLog:

2019-08-25  Yoshinori Sato <ysato@users.sourceforge.jp>

	* gdb.texinfo (Standard Target Features): Add RX Features sub-section.
2019-08-25 17:00:08 +09:00
Alan Hayward aa7ca1bb44 Move [PAC] into a new MI field addr_flags
Add a new print_pc which prints both the PC and a new field addr_flags.
Call this wherever the PC is printed in stack.c.

Add a new gdbarch method get_pc_address_flags to obtain the addr_flag
contents. By default returns an empty string, on AArch64 this returns
PAC if the address has been masked in the frame.

Document this in the manual and NEWS file.

gdb/ChangeLog:

	* NEWS (Other MI changes): New subsection.
	* aarch64-tdep.c (aarch64_get_pc_address_flags): New function.
	(aarch64_gdbarch_init): Add aarch64_get_pc_address_flags.
	* arch-utils.c (default_get_pc_address_flags): New function.
	* arch-utils.h (default_get_pc_address_flags): New declaration.
	* gdbarch.sh: Add get_pc_address_flags.
	* gdbarch.c: Regenerate.
	* gdbarch.h: Likewise.
	* stack.c (print_pc): New function.
	(print_frame_info) (print_frame): Call print_pc.

gdb/doc/ChangeLog:

	* gdb.texinfo (AArch64 Pointer Authentication)
	(GDB/MI Breakpoint Information) (Frame Information): Document
	addr_field.
2019-08-16 10:19:18 +01:00
Tom Tromey 86c6b807f5 Require readline 7 or newer
This changes gdb to require readline 7 or newer at build time.

gdb/ChangeLog
2019-08-12  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.
	* configure.ac: Check for readline 7.
	* NEWS: Mention readline 7 requirement.
	* README: Update.

gdb/doc/ChangeLog
2019-08-12  Tom Tromey  <tom@tromey.com>

	* gdb.texinfo (Configure Options): Document minimum version of
	readline.
2019-08-12 10:57:56 -06:00
Alan Hayward 3d31bc39e6 AArch64 pauth: Indicate unmasked addresses in backtrace
Armv8.3-a Pointer Authentication causes the function return address to be
obfuscated on entry to some functions. GDB must unmask the link register in
order to produce a backtrace.

The following patch adds markers of [PAC] to the bracktrace, to indicate
which addresses needed unmasking.  This includes the backtrace when using MI.

For example, consider the following backtrace:

(gdb) bt
0  0x0000000000400490 in puts@plt ()
1  0x00000000004005dc in foo ("hello") at cbreak-lib.c:6
2  0x0000000000400604 [PAC] in bar () at cbreak-lib.c:12
3  0x0000000000400620 [PAC] in main2 () at cbreak.c:17
4  0x00000000004005b4 in main () at cbreak-3.c:10

The functions in cbreak-lib use pointer auth, which masks the return address
to the previous function, causing the addresses of bar (in the library) and main2
(in the main binary) to require unmasking in order to unwind the backtrace.

An extra bool is added alongside the prev_pc in the frame structure.  At the
point at which the link register is unmasked, the AArch64 port calls into frame
to sets the bool.  This is the most efficient way of doing it.

The marker is also added to the python frame printer, which is always printed if
set.  The marker is not explicitly exposed to the python code.

I expect this will potentially cause issues with some tests in the testsuite
when Armv8.3 pointer authentication is used.  This should be fixed up in the
the future once real hardware is available for full testsuite testing.

gdb/ChangeLog:

        * NEWS: Expand the Pointer Authentication entry.
        * aarch64-tdep.c (aarch64_frame_unmask_address): Rename from this.
        (aarch64_frame_unmask_lr): ... to this.
        (aarch64_prologue_prev_register, aarch64_dwarf2_prev_register):
        Call aarch64_frame_unmask_lr.
        * frame.c (struct frame_info): Add "masked" variable.
        (frame_set_previous_pc_masked) (frame_get_pc_masked): New functions.
        (fprint_frame): Check for masked pc.
        * frame.h (frame_set_previous_pc_masked) (frame_get_pc_masked): New
        declarations.
	* python/py-framefilter.c (py_print_frame): Check for masked pc.
        * stack.c (print_frame): Check for masked pc.

gdb/doc/ChangeLog:

        * gdb.texinfo (AArch64 Pointer Authentication): New subsection.
2019-08-07 13:34:12 +01:00
Christian Biesinger 0b27c27d0d Add block['var'] accessor
Currently we support iteration on blocks; this patch extends that to make
subscript access work as well.

gdb/ChangeLog:

2019-08-05  Christian Biesinger  <cbiesinger@google.com>

	* NEWS: Mention dictionary access on blocks.
	* python/py-block.c (blpy_getitem): New function.
	(block_object_as_mapping): New struct.
	(block_object_type): Use new struct for tp_as_mapping field.

gdb/doc/ChangeLog:

2019-08-05  Christian Biesinger  <cbiesinger@google.com>

	* python.texi (Blocks In Python): Document dictionary access on blocks.

gdb/testsuite/ChangeLog:

2019-08-05  Christian Biesinger  <cbiesinger@google.com>

	* gdb.python/py-block.exp: Test dictionary access on blocks.
2019-08-05 13:06:18 -05:00
Philippe Waroquiers ae60f04e08 NEWS and documentation for info sources [-dirname | -basename] [--] [REGEXP].
gdb/ChangeLog
2019-08-03  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

        * NEWS: Mention changes to "info sources" command.

gdb/doc/ChangeLog
2019-08-03  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

        * gdb.texinfo (Symbols): Document new args -dirname and -basename
        of "info sources" command.
2019-08-03 21:27:51 +02:00
Alan Hayward c6bdbeb7c4 Require GNU make 3.82
Gdbserver has failed to build with GNU make 3.81 since commit 08f10e02be.

Update the NEWS file to state that versions earlier than 3.82 are not
supported.

3.82 was released in 2010, 3.81 was released 2006. A quick investigation
of the default GNU make version provided across various distros found the
earliest provided version to be 3.82:
*RHEL 7, Centos 6 - make 3.82
*Fedora 27 - make 4.2.1
*OpenSuse 42.2, SLES11 - make 4.2.1
*Ubuntu 16.04/18.04 - make 4.1
*Debian Jessie - make 4.0

Note that Glibc requires at least 4.0, whereas GCC still allows 3.81.

gdb/ChangeLog:

	* NEWS: Require GNU make 3.82.
2019-08-01 17:07:43 +01:00
Christian Biesinger 2906593ffe [PR/24474] Add gdb.lookup_static_symbol to the python API
Similar to lookup_global_symbol, except that it checks the
STATIC_SCOPE.

gdb/ChangeLog:

2019-07-30  Christian Biesinger  <cbiesinger@google.com>

	PR/24474: Add a function to lookup static variables.
	* NEWS: Mention this new function.
	* python/py-symbol.c (gdbpy_lookup_static_symbol): New function.
	* python/python-internal.h (gdbpy_lookup_static_symbol): New function.
	* python/python.c (python_GdbMethods): Add new function.

gdb/doc/ChangeLog:

2019-07-30  Christian Biesinger  <cbiesinger@google.com>

	* python.texi (Symbols In Python): Document new function
	gdb.lookup_static_symbol.

gdb/testsuite/ChangeLog:

2019-07-30  Christian Biesinger  <cbiesinger@google.com>

	* gdb.python/py-symbol.c: Add a static variable and one in an anonymous
	namespace.
	* gdb.python/py-symbol.exp: Test gdb.lookup_static_symbol.
2019-07-30 11:04:37 -05:00
Christian Biesinger c620ed8866 Add Objfile.lookup_{global,static}_symbol functions
This is essentially the inverse of Symbol.objfile. This allows
handling different symbols with the same name (but from different
objfiles) and can also be faster if the objfile is known.

gdb/ChangeLog:

2019-07-29  Christian Biesinger  <cbiesinger@google.com>

	* NEWS: Mention new functions Objfile.lookup_{global,static}_symbol.
	* python/py-objfile.c (objfpy_lookup_global_symbol): New function.
	(objfpy_lookup_static_symbol): New function.
	(objfile_object_methods): Add new functions.

gdb/doc/ChangeLog:

2019-07-29  Christian Biesinger  <cbiesinger@google.com>

	* python.texi (Objfiles In Python): Document new functions
	  Objfile.lookup_{global,static}_symbol.

gdb/testsuite/ChangeLog:

2019-07-29  Christian Biesinger  <cbiesinger@google.com>

	* gdb.python/py-objfile.c: Add global and static vars.
	* gdb.python/py-objfile.exp: Test new functions Objfile.
	  lookup_global_symbol and lookup_static_symbol.
2019-07-29 20:44:08 -05:00
Philippe Waroquiers bc4268a5d9 Document 'set print frame-info|frame-arguments presence'.
gdb/ChangeLog
2019-06-19  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

	* NEWS: Mention 'set|show print frame-info'.  Mention new
	'presence' value for 'frame-arguments'.  Mention new '-frame-info'
	backtrace argument.  Mention that python frame filtering code
	is now consistent with what 'backtrace' command prints.

gdb/doc/ChangeLog
2019-07-29  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

	* gdb.texinfo (Backtrace): Document the new '-frame-info'
	backtrace option.  Reference 'set print frame-info'.
	(Print Settings): Document 'set|show print frame-info'.
	Document new 'presence' value for 'set print frame-arguments.
2019-07-29 21:43:08 +02:00
Andrew Burgess a8eab7c6d5 gdb: Switch "info types" over to use the gdb::options framework
Adds a new -q flag to "info types" using the gdb::option framework.
This -q flag is similar to the -q flag already present for "info
variables" and "info functions".

gdb/ChangeLog:

	* NEWS: Mention adding -q option to "info types".
	* symtab.c (struct info_types_options): New struct.
	(info_types_options_defs): New variable.
	(make_info_types_options_def_group): New function.
	(info_types_command): Use gdb::option framework to parse options.
	(info_types_command_completer): New function.
	(_initialize_symtab): Extend the help text on "info types" and
	register command completer.

gdb/doc/ChangeLog:

	* gdb.texinfo (Symbols): Add information about -q flag to "info
	types".
2019-07-22 10:43:00 +01:00
Andrew Burgess 60cfcb20ce gdb: Add command completers for some info commands
Add command completion for info variables, functions, args, and
locals.  This completer only completes the command line options as
these commands all take a regexp which GDB can't really offer
completions for.

gdb/ChangeLog:

	* cli/cli-utils.c (info_print_command_completer): New function.
	* cli/cli-utils.h: Add 'completer.h' include, and forward
	declaration for 'struct cmd_list_element'.
	(info_print_command_completer): Declare.
	* stack.c (_initialize_stack): Add completer for 'info locals' and
	'info args'.
	* symtab.c (_initialize_symtab): Add completer for 'info
	variables' and 'info functions'.
	* NEWS: Mention completion for additional info commands.
2019-07-11 20:19:24 +01:00
Philippe Waroquiers 1f6f6e21fa Ensure GDB printf command can print convenience var strings without a target.
Without this patch, GDB printf command calls malloc on the target,
writes the convenience var content to the target,
re-reads the content from the target, and then locally printf the string.

This implies inferior calls, and does not work when there is no running
inferior, or when the inferior is a core dump.

With this patch, printf command can printf string convenience variables
without inferior function calls.
Ada string convenience variables can also be printed.

gdb/ChangeLog
2019-07-08  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

	* NEWS: Mention that GDB printf and eval commands can now print
	C-style and Ada-style convenience var strings without
	calling the inferior.
	* printcmd.c (printf_c_string): Locally print GDB internal var
	instead of transiting via the inferior.
	(printf_wide_c_string): Likewise.

gdb/testsuite/ChangeLog
2019-07-08  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

	* gdb.base/printcmds.exp: Test printing C string and
	C wide string convenience vars without transiting via the inferior.
	Also make test names unique.
2019-07-08 23:31:54 +02:00
Pedro Alves fdbc98707b Introduce the "with" command
( See original discussion and prototype here:
   https://sourceware.org/ml/gdb-patches/2019-05/msg00570.html )

 (gdb) help with
 Temporarily set SETTING to VALUE, run COMMAND, and restore SETTING.
 Usage: with SETTING [VALUE] [-- COMMAND]
 Usage: w SETTING [VALUE] [-- COMMAND]
 With no COMMAND, repeats the last executed command.
 SETTING is any setting you can change with the "set" subcommands.
 E.g.:
   with language pascal -- print obj
   with print elements unlimited -- print obj

As can be seen above, the "with" command is just like "set", but
instead of setting the setting permanently, it sets the setting, runs
a command and then restores the setting.

 (gdb) p g_s
 $1 = {a = 1, b = 2, c = 3}
 (gdb) with language ada -- print g_s
 $2 = (a => 1, b => 2, c => 3)
 Warning: the current language does not match this frame.
 (gdb) show language
 The current source language is "auto; currently c".
 (gdb) with print elements 100 -- with print object on -- print 1
 $3 = 1

You can shorten things a bit though, as long as unambiguous.  So this:

 (gdb) with print elements 100 -- with print object off -- print 1

is the same as:

 (gdb) w p el 100 -- w p o 0 -- p 1

Note that the patch adds a "w" alias for "with", as "w" is not
currently taken:

 (gdb) w
 Ambiguous command "w": watch, wh, whatis, where, while, while-stepping, winheight, ws.

Let me know if you'd prefer to reserve "w" for one of the other
commands above.  IMHO, this command will end up being used frequently
enough that it deserves the "w" shorthand.

A nice feature is that this is fully integrated with TAB-completion:

 (gdb) with p[TAB]
 pagination  print       prompt      python
 (gdb) with print [TAB]
 address                max-depth              static-members
 array                  max-symbolic-offset    symbol
 array-indexes          null-stop              symbol-filename
 asm-demangle           object                 symbol-loading
 demangle               pascal_static-members  thread-events
 elements               pretty                 type
 entry-values           raw                    union
 frame-arguments        repeats                vtbl
 inferior-events        sevenbit-strings
 (gdb) with print [TAB]

 (gdb) with print elements unlimited -- thread apply all -[TAB]
 -ascending  -c          -q          -s

 (gdb) with print elements unlimited -- print -[TAB]
 -address         -max-depth       -repeats         -vtbl
 -array           -null-stop       -static-members
 -array-indexes   -object          -symbol
 -elements        -pretty          -union

The main advantage of this new command compared to command options,
like the new "print -OPT", is that this command works with any
setting, and, it works nicely when you want to override a setting
while running a user-defined command, like:

 (gdb) with print pretty -- usercmd

The disadvantage is that it isn't as compact or easy to type.  I think
of command options and this command as complementary.  I think that
even with this new command, it makes sense to continue developing the
command options in the direction of exposing most-oft-used settings as
command options.

Inspired by Philippe's "/" command proposal, if no command is
specified, then the last command is re-invoked, under the overridden
setting:

 (gdb) p g_s
 $1 = {a = 1, b = 2, c = 3}
 (gdb) with language ada
 $2 = (a => 1, b => 2, c => 3)
 Warning: the current language does not match this frame.

Note: "with" requires "--" to separate the setting from the command.
It might be possible to do without that, but, I haven't tried it yet,
and I think that this can go in without it.  We can always downgrade
to making "--" optional if we manage to make it work.

On to the patch itself, the implementation of the command is simpler
than one might expect.  A few details:

- I factored out a bit from pipe_command into repeat_previous
  directly, because otherwise I'd need to copy&paste the same code and
  same error message in the with command.

- The parse_cli_var_uinteger / parse_cli_var_zuinteger_unlimited /
  do_set_command changes are necessary since we can now pass an empty
  string as argument.

- do_show_command was split in two, as a FIXME comment suggests, but
  for a different reason: we need to get a string version of a "set"
  command's value, and we already had code for that in
  do_show_command.  That code is now factored out to the new
  get_setshow_command_value_string function.

- There's a new "maint with" command added too:

   (gdb) help maint with
   Like "with", but works with "maintenance set" variables.
   Usage: maintenance with SETTING [VALUE] [-- COMMAND]
   With no COMMAND, repeats the last executed command.
   SETTING is any setting you can change with the "maintenance set"
   subcommands.

  "with" and "maint with" share 99% of the implementation.

  This might be useful on its own, but it's also useful for testing,
  since with this, we can use the "maint set/show test-settings"
  settings for exercising the "with" machinery with all the command
  type variants (all enum var_types).  This is done in the new
  gdb/base/with.exp testcase.

The documentation bits are originally based on Philippe's docs for the
"/" command, hence the attribution in the ChangeLog.

gdb/ChangeLog:
2019-07-03  Pedro Alves  <palves@redhat.com>

	* NEWS (New commands): Mention "with" and "maint with".
	* cli/cli-cmds.c (with_command_1, with_command_completer_1)
	(with_command, with_command_completer): New.
	(pipe_command): Adjust to new repeat_previous
	interface.
	(_initialize_cli_cmds): Install the "with" command and its "w"
	alias.
	* cli/cli-cmds.h (with_command_1, with_command_completer_1): New
	declarations.
	* cli/cli-setshow.c (parse_cli_var_uinteger)
	(parse_cli_var_zuinteger_unlimited, do_set_command): Handle empty
	argument strings for all var_types.
	(get_setshow_command_value_string): New, factored out from ...
	(do_show_command): ... this.
	* cli/cli-setshow.h: Include <string>.
	(get_setshow_command_value_string): Declare.
	* command.h (repeat_previous): Now returns const char *.  Adjust
	comment.
	* maint.c: Include "cli/cli-cmds.h".
	(maintenance_with_cmd, maintenance_with_cmd_completer): New.
	(_initialize_maint_cmds): Register the "maintenance with" command.
	* top.c (repeat_previous): Move bits from pipe_command here:
	Return the saved command line, if any; error out if there's no
	command to relaunch.

gdb/doc/ChangeLog:
2019-07-03  Pedro Alves  <palves@redhat.com>
	    Philippe Waroquiers  <philippe.waroquiers@skynet.be>

	* gdb.texinfo (Command Settings): New node documenting the general
	concept of settings, how to change them, and the new "with"
	command.
	(Maintenance Commands): Document "maint with".

gdb/testsuite/ChangeLog:
2019-07-03  Pedro Alves  <palves@redhat.com>

	* gdb.base/with.c: New file.
	* gdb.base/with.exp: New file.
2019-07-03 13:35:45 +01:00
Pedro Alves c6ac893109 "maint test-settings set/show" -> "maint set/show test-settings"
This commit renames "maint test-settings set/show" to "maint set/show
test-settings".

This helps the following patch, which introduce a "maint with" command
what works with all "maint set" settings.

gdb/ChangeLog:
2019-07-03  Pedro Alves  <palves@redhat.com>

	* NEWS (New commands): Mention "maint set/show test-settings"
	instead of "maint test-settings".
	* maint-test-settings.c (maintenance_test_settings_list): Delete.
	(maintenance_test_settings_set_list): Rename to ...
	(maintenance_set_test_settings_list): ... this.
	(maintenance_test_settings_show_list): Rename to  ...
	(maintenance_show_test_settings_list): ... this.
	(maintenance_test_settings_cmd): Delete.
	(maintenance_test_settings_set_cmd): ...
	(maintenance_set_test_settings_cmd): ... this.
	(maintenance_test_settings_show_cmd): ...
	(maintenance_show_test_settings_cmd): ... this.
	(maintenance_test_settings_show_value_cmd):
	(maintenance_show_test_settings_value_cmd): ... this.
	(_initialize_maint_test_settings): No longer install the "maint
	test-settings" prefix command.  Rename "maint test-settings set"
	to "maint set test-settings", and "maint test-settings show" to
	"maint show test-settings".  Adjust all subcommands.

gdb/doc/ChangeLog:
2019-07-03  Pedro Alves  <palves@redhat.com>

	* gdb.texinfo (Maintenance Commands): Document "maint set/show
	test-settings" instead of "maint test-settings set/show".

gdb/testsuite/ChangeLog:
2019-07-03  Pedro Alves  <palves@redhat.com>

	* gdb.base/settings.exp: Replace all references to "maint
	test-settings set" with references to "maint set test-settings",
	and all references to "maint test-settings show" with references
	to "maint show test-settings".
2019-07-03 13:35:03 +01:00
Pedro Alves 54d6600669 Make "info threads" use the gdb::option framework
This makes "info threads" use the gdb::option framework to process
options.  There's only one option today (-gid), and it isn't used much
frequently unless you're looking at matching MI output.  Still, this
was in the neighborhood of "thread apply" so I had converted it.

The main advantage is that TAB completion now shows you the available
options, and gives you a hint to what the command accepts as operand
argument, including showing a metasyntactic variable:

  (gdb) info threads [TAB]
  -gid  ID

  (gdb) help info threads
  Display currently known threads.
  Usage: info threads [OPTION]... [ID]...

  Options:
    -gid
      Show global thread IDs.

  If ID is given, it is a space-separated list of IDs of threads to display.
  Otherwise, all threads are displayed.
  (gdb)

gdb/ChangeLog:
2019-07-02  Pedro Alves  <palves@redhat.com>

	* NEWS (Completion improvements): Mention "info threads".
	* thread.c (struct info_threads_opts, info_threads_option_defs)
	(make_info_threads_options_def_group): New.
	(info_threads_command): Use gdb::option::process_options.
	(info_threads_command_completer): New.
	(_initialize_thread): Use gdb::option::build_help to build the
	help text for "info threads".

gdb/testsuite/ChangeLog:
2019-07-02  Pedro Alves  <palves@redhat.com>

	* gdb.base/options.exp (test-info-threads): New procedure.
	(top level): Call it.
2019-07-02 16:34:31 +01:00
Andrew Burgess 30056ea04a gdb/mi: New commands to catch C++ exceptions
Adds some MI commands to catch C++ exceptions.  The new commands are
-catch-throw, -catch-rethrow, and -catch-catch, these all correspond
to the CLI commands 'catch throw', 'catch rethrow', and 'catch catch'.

Each MI command takes two optional arguments, '-t' has the effect of
calling 'tcatch' instead of 'catch', for example:

   (gdb)
   -catch-throw -t

Is the same as:

   (gdb) tcatch throw

There is also a '-r REGEXP' argument that can supply a regexp to match
against the exception type, so:

   (gdb)
   -catch-catch -r PATTERN

Is the same as:

   (gdb) catch catch PATTERN

The change in print_mention_exception_catchpoint might seem a little
strange; changing the output from using ui_out::field_int and
ui_out::text to using  ui_out::message.

The print_mention_exception_catchpoint is used as the 'print_mention'
method for the exception catchpoint breakpoint object.  Most of the
other 'print_mention' methods (see breakpoint.c) use either
printf_filtered, of ui_out::message.  Using field_int was causing an
unexpected field to be added to the MI output.  Here's the output
without the change in print_mention_exception_catchpoint:

    (gdb)
    -catch-throw
    ^done,bkptno="1",bkpt={number="1",type="breakpoint",disp="keep",
                           enabled="y",addr="0x00000000004006c0",
                           what="exception throw",catch-type="throw",
                           thread-groups=["i1"],times="0"}

Notice the breakpoint number appears in both the 'bkptno' field, and
the 'number' field within the 'bkpt' tuple.  Here's the output with
the change in print_mention_exception_catchpoint:

    (gdb)
    -catch-throw
    ^done,bkpt={number="1",type="breakpoint",disp="keep",
                enabled="y",addr="0x00000000004006c0",
                what="exception throw",catch-type="throw",
                thread-groups=["i1"],times="0"}

gdb/ChangeLog:

	* NEWS: Mention new MI commands.
	* break-catch-throw.c (enum exception_event_kind): Move to
	breakpoint.h.
	(print_mention_exception_catchpoint): Output text as a single
	message.
	(catch_exception_command_1): Rename to...
	(catch_exception_event): ...this, make non-static, update header
	command, and change some parameter types.
	(catch_catch_command): Update for changes to
	catch_exception_command_1.
	(catch_throw_command): Likewise.
	(catch_rethrow_command): Likewise.
	* breakpoint.c (enum exception_event_kind): Delete.
	* breakpoint.h (enum exception_event_kind): Moved here from
	break-catch-throw.c.
	(catch_exception_event): Declare.
	* mi/mi-cmd-catch.c (mi_cmd_catch_exception_event): New function.
	(mi_cmd_catch_throw): New function.
	(mi_cmd_catch_rethrow): New function.
	(mi_cmd_catch_catch): New function.
	* mi/mi-cmds.c (mi_cmds): Add 'catch-throw', 'catch-rethrow', and
	'catch-catch' entries.
	* mi/mi-cmds.h (mi_cmd_catch_throw): Declare.
	(mi_cmd_catch_rethrow): Declare.
	(mi_cmd_catch_catch): Declare.

gdb/doc/ChangeLog:

	* gdb.texinfo (GDB/MI Catchpoint Commands): Add menu entry to new
	node.
	(C++ Exception GDB/MI Catchpoint Commands): New node to describe
	new MI commands.

gdb/testsuite/ChangeLog:

	* gdb.mi/mi-catch-cpp-exceptions.cc: New file.
	* gdb.mi/mi-catch-cpp-exceptions.exp: New file.
	* lib/mi-support.exp (mi_expect_stop): Handle 'exception-caught'
	as a stop reason.
2019-06-15 23:22:22 +01:00
Tom Tromey 52ce35e289 Minor NEWS rearrangement
I noticed that a NEWS item about Python scripting changes appeared
between an item about a convenience function and an item about a
convenience variable.  I think it's better for the latter to be next
to each other.

gdb/ChangeLog
2019-06-14  Tom Tromey  <tromey@adacore.com>

	* NEWS: Move convenience variable news above Python news.
2019-06-14 13:03:18 -06:00
Pedro Alves 3345721af1 NEWS and manual changes for command options changes
gdb/ChangeLog:
2019-06-13  Pedro Alves  <palves@redhat.com>

	* NEWS (New commands): Mention "maint test-options
	require-delimiter", "maint test-options unknown-is-error", "maint
	test-options unknown-is-operand" and "maint show
	test-options-completion-result".
	(New command options, command completion): New section.
	(Completion improvements): New section.
	Mention that you can abbreviate "unlimited".

gdb/doc/ChangeLog:
2019-06-13  Pedro Alves  <palves@redhat.com>

	* gdb.texinfo (Command Completion): Mention command options too.
	(Command Options): New node.
	(Threads): Add anchors.  Extend descriptions of the "taas" and
	"tfaas" commands.
	(Backtrace): Describe new options of the "backtrace" command.  Add
	anchors.
	(Frame Apply): Describe new options of the "frame apply" and
	"faas" commands.  Add anchors.
	(Data): Describe new options of the "print" command.  Add anchors.
	(Compiling and Injecting Code): Mention options of the "compile
	print" command.
	(Maintenance Commands): Mention "maint test-options" subcommands
	and the "maint show test-options-completion-result" command.
2019-06-13 00:25:06 +01:00
Pedro Alves 2daf894ed0 "set print raw frame-arguments" -> "set print raw-frame-arguments"
A following patch will introduce options for the "backtrace" command,
based on some "set print" and "set backtrace" settings.  There's one
setting in particular that is a bit annoying if we want to describe
the backtrace options and the settings commands using the same data
structures:

  "set print raw frame-arguments"

The problem is that space between "raw" and "frame-arguments".

Calling the option

  "bt -raw frame-arguments"

would be odd.  So I'm calling the option

  "bt -raw-frame-arguments"

instead.

And for consistency, this patch renames the set/show commands to:

 "set print raw-frame-arguments"
 "show print raw-frame-arguments"

I.e., dash instead of space.  The old commands are left in place, but
marked deprecated.

We need to adjust a couple testcases, because the relevant tests use
gdb_test_no_output and the old commands are no longer silent:

  (gdb) set print raw frame-arguments on
  Warning: command 'set print raw frame-arguments' is deprecated.
  Use 'set print raw-frame-arguments'.

gdb/ChangeLog:
2019-06-13  Pedro Alves  <palves@redhat.com>

	* NEWS (Changed commands): Mention set/show print raw-frame-arguments,
	and that "set/show print raw frame-arguments" are now deprecated.

	* cli/cli-decode.c (add_setshow_boolean_cmd): Now returns the
	command.
	* command.h (add_setshow_boolean_cmd): Return cmd_list_element *.
	* stack.c (_initialize_stack): Install "set/show print
	raw-frame-arguments", and deprecate "set/show print raw
	frame-arguments".
	* valprint.c (_initialize_valprint): Deprecate "set/show print
	raw".

gdb/doc/ChangeLog:
2019-06-13  Pedro Alves  <palves@redhat.com>

	* gdb.texinfo (Print Settings): Document "set/show print
	raw-frame-arguments" instead of "set/show print raw
	frame-arguments".

gdb/testsuite/ChangeLog:
2019-06-13  Pedro Alves  <palves@redhat.com>

	* gdb.guile/scm-frame-args.exp: Use "set print
	raw-frame-arguments" instead of "set print raw frame-arguments".
	* gdb.python/py-frame-args.exp: Likewise.
2019-06-13 00:18:41 +01:00
Pedro Alves dca0f6c0a4 New set/show testing framework (gdb.base/settings.exp)
This commit adds new representative commands for all types of settings
commands supported by gdb (enum var_types), and then uses them to
exercise settings parsing and completion.

  (gdb) maint test-settings s[TAB]
  set   show

  (gdb) maint test-settings set [TAB]
  auto-boolean         integer              uinteger
  boolean              optional-filename    zinteger
  enum                 string               zuinteger
  filename             string-noescape      zuinteger-unlimited

  (gdb) maint test-settings set enum [TAB]
  xxx  yyy  zzz

  etc.

This is basically unit testing, except that it goes fully via GDB.  It
must be done this way in order to exercise TAB completion properly,
which must go via readline.

gdb/ChangeLog:
2019-06-13  Pedro Alves  <palves@redhat.com>

	* Makefile.in (COMMON_SFILES): Add maint-test-settings.c.
	* NEWS: Mention maint test-settings KIND.
	* maint-test-settings.c: New file.

gdb/doc/ChangeLog:
2019-06-13  Pedro Alves  <palves@redhat.com>

	* gdb.texinfo (Maintenance Commands): Document "maint
	test-settings" commands.

gdb/testsuite/ChangeLog:
2019-06-13  Pedro Alves  <palves@redhat.com>

	* gdb.base/settings.c: New file.
	* gdb.base/settings.exp: New file.
2019-06-13 00:12:20 +01:00
Amos Bird 1a3da2cd61 Add thread-exit annotation.
gdb/ChangeLog
2019-04-26  Amos Bird  <amosbird@gmail.com>

	* annotate.c (annotate_thread_exited): Add "thread-exited"
	annotation.

gdb/doc/ChangeLog
2019-06-06  Amos Bird  <amosbird@gmail.com>

	* annotate.texinfo (Multi-threaded Apps): Add entry for thread-exited
	annotation.

gdb/testsuite/ChangeLog
2019-06-06  Amos Bird  <amosbird@gmail.com>

	* gdb.base/annota1.exp (thread_switch): Add test for
	thread-exited annotation.
2019-06-06 11:35:15 -06:00
Christian Biesinger via gdb-patches e1f2e1a2da Add an objfile getter to gdb.Type
This allows users of the Python API to find the objfile where a type
was defined.

gdb/ChangeLog:

gdb/ChangeLog
2019-06-04  Christian Biesinger  <cbiesinger@google.com>

	Add objfile property to gdb.Type.
	* gdb/NEWS: Mention Python API addition.
	* gdb/python/py-type.c (typy_get_objfile): New method.

gdb/doc/ChangeLog
2019-06-04  Christian Biesinger  <cbiesinger@google.com>

	* gdb/doc/python.texi: Document new gdb.Type.objfile property.

gdb/testsuite/ChangeLog
2019-06-04  Christian Biesinger  <cbiesinger@google.com>

	* gdb/testsuite/gdb.python/py-type.exp: Test for new
	  gdb.Type.objfile property.
2019-06-04 09:46:06 -06:00
Philippe Waroquiers e664d72803 Document in NEWS and gdb.texinfo the "help", "apropos" and "show style" changes. 2019-06-03 21:59:35 +02:00
Philippe Waroquiers e2c52041c0 NEWS and documentation for | (pipe) command.
gdb/ChangeLog
	* NEWS: Mention new pipe command and new convenience variables.

gdb/doc/ChangeLog
	* gdb.texinfo (Shell Commands): Document pipe command.
	(Logging Output): Add a reference to pipe command.
	(Convenience Variables): Document $_shell_exitcode and
	$_shell_exitstatus.
2019-05-31 17:14:20 +02:00
Tom Tromey 000439d528 Add "set print finish"
A user wanted to be able to disable the display of the value when
using "finish" -- but still have the value entered into the value
history in case it was useful later on.  Part of the rationale here is
that sometimes the value might be quite large, or expensive to display
(in their case this was compounded by a rogue pretty-printer).

This patch implements this idea.

gdb/ChangeLog
2019-05-29  Tom Tromey  <tromey@adacore.com>

	* NEWS: Add entry.
	* infcmd.c (print_return_value_1): Handle finish_print
	option.
	(show_print_finish): New function.
	(_initialize_infcmd): Add "set/show print finish" commands.
	* valprint.c (user_print_options): Initialize new member.
	* valprint.h (struct value_print_options) <finish_print>: New
	member.

gdb/doc/ChangeLog
2019-05-29  Tom Tromey  <tromey@adacore.com>

	* gdb.texinfo (Continuing and Stepping): Document new
	commands.

gdb/testsuite/ChangeLog
2019-05-29  Tom Tromey  <tromey@adacore.com>

	* gdb.base/finish.exp (finish_no_print): New proc.
	(finish_tests): Call it.
2019-05-29 08:25:38 -06:00
Tom Tromey eb41253a15 Fix typo in gdb/NEWS
I noticed a typo in gdb/NEWS.  This fixes it.

gdb/ChangeLog
2019-05-27  Tom Tromey  <tom@tromey.com>

	* NEWS: Fix typo.
2019-05-27 14:53:12 -06:00
Alan Hayward b706061469 Document gdb.in/gdb.cmd files and debugredirect cli command
Add missing documentation for the debugredirect setting.

Add description and uses of gdb.in/gdb.cmd to the testsuite README.

Mention this in the NEWS file.

gdb/ChangeLog:

	* NEWS: Add debugredirect and testsuite sections.

gdb/doc/ChangeLog:

	* gdb.texinfo (Shell Commands): Add debugredirect.

gdb/testsuite/ChangeLog:

	* README (Re-running Tests Outside The Testsuite): New section.
2019-05-22 13:40:20 +01:00
Jan Vrany 2664858829 MI: Add new command -complete
There is a CLI command 'complete' intended to use with emacs. Such a command
would also be useful for MI frontends, when separate CLI and MI channels cannot
be used. For example, on Windows (because of lack of PTYs) or when GDB is used
through SSH session.

This commit adds a new '-complete' MI command.

gdb/Changelog:
2019-01-28  Jan Vrany  <jan.vrany@fit.cvut.cz>

	* mi/mi-cmds.h (mi_cmd_complete): New function.
	* mi/mi-main.c (mi_cmd_complete): Likewise.
	* mi/mi-cmds.c: Define new MI command -complete.
	* NEWS: Mention new -complete command.

gdb/doc/ChangeLog:
2019-01-28  Jan Vrany  <jan.vrany@fit.cvut.cz>

	* gdb.texinfo (Miscellaneous GDB/MI Commands): Document new
	MI command -complete.

gdb/testsuite/ChangeLog:
2019-01-28  Jan Vrany  <jan.vrany@fit.cvut.cz>

	* gdb.mi/mi-complete.exp: New file.
	* gdb.mi/mi-complete.cc: Likewise.
2019-05-17 10:58:23 +01:00
Andrew Burgess 1bd0c6e496 gdb: Merge two 'New commands' sections in NEWS file
Commit 2e62ab400f added a second 'New commands' section to the NEWS
file, this commit merges the two together.

gdb/ChangeLog:

	* NEWS: Merge two 'New commands' sections.
2019-05-08 20:59:50 +01:00
Andrew Burgess 2e62ab400f gdb: Introduce 'print max-depth' feature
Introduce a new print setting max-depth which can be set with 'set
print max-depth DEPTH'.  The default value of DEPTH is 20, but this
can also be set to unlimited.

When GDB is printing a value containing nested structures GDB will
stop descending at depth DEPTH.  Here is a small example:

    typedef struct s1 { int a; } s1;
    typedef struct s2 { s1 b; } s2;
    typedef struct s3 { s2 c; } s3;
    typedef struct s4 { s3 d; } s4;

    s4 var = { { { { 3 } } } };

The following table shows how various depth settings affect printing
of 'var':

    | Depth Setting | Result of 'p var'              |
    |---------------+--------------------------------|
    |     Unlimited | $1 = {d = {c = {b = {a = 3}}}} |
    |             4 | $1 = {d = {c = {b = {a = 3}}}} |
    |             3 | $1 = {d = {c = {b = {...}}}}   |
    |             2 | $1 = {d = {c = {...}}}         |
    |             1 | $1 = {d = {...}}               |
    |             0 | $1 = {...}                     |

Only structures, unions, and arrays are replaced in this way, scalars
and strings are not replaced.

The replacement is counted from the level at which you print, not from
the top level of the structure.  So, consider the above example and
this GDB session:

    (gdb) set print max-depth 2
    (gdb) p var
    $1 = {d = {c = {...}}}
    (gdb) p var.d
    $2 = {c = {b = {...}}}
    (gdb) p var.d.c
    $3 = {b = {a = 3}}

Setting the max-depth to 2 doesn't prevent the user from exploring
deeper into 'var' by asking for specific sub-fields to be printed.

The motivation behind this feature is to try and give the user more
control over how much is printed when examining large, complex data
structures.

The default max-depth of 20 means that there is a change in GDB's
default behaviour.  Someone printing a data structure with 20 levels
of nesting will now see '{...}' instead of their data, they would need
to adjust the max depth, or call print again naming a specific field
in order to dig deeper into their data structure.  If this is
considered a problem then we could increase the default, or even make
the default unlimited.

This commit relies on the previous commit, which added a new field to
the language structure, this new field was a string that contained the
pattern that should be used when a structure/union/array is replaced
in the output, this allows languages to use a syntax that is more
appropriate, mostly this will be selecting the correct types of
bracket '(...)' or '{...}', both of which are currently in use.

This commit should have no impact on MI output, expressions are
printed through the MI using -var-create and then -var-list-children.
As each use of -var-list-children only ever displays a single level of
an expression then the max-depth setting will have no impact.

This commit also adds the max-depth mechanism to the scripting
language pretty printers following basically the same rules as for the
built in value printing.

One quirk is that when printing a value using the display hint 'map',
if the keys of the map are structs then GDB will hide the keys one
depth level after it hides the values, this ensures that GDB produces
output like this:

  $1 = map_object = {[{key1}] = {...}, [{key2}] = {...}}

Instead of this less helpful output:

  $1 = map_object = {[{...}] = {...}, [{...}] = {...}}

This is covered by the new tests in gdb.python/py-nested-maps.exp.

gdb/ChangeLog:

	* cp-valprint.c (cp_print_value_fields): Allow an additional level
	of depth when printing anonymous structs or unions.
	* guile/scm-pretty-print.c (gdbscm_apply_val_pretty_printer):
	Don't print either the top-level value, or the children if the
	max-depth is exceeded.
	(ppscm_print_children): When printing the key of a map, allow one
	extra level of depth.
	* python/py-prettyprint.c (gdbpy_apply_val_pretty_printer): Don't
	print either the top-level value, or the children if the max-depth
	is exceeded.
	(print_children): When printing the key of a map, allow one extra
	level of depth.
	* python/py-value.c (valpy_format_string): Add max_depth keyword.
	* valprint.c: (PRINT_MAX_DEPTH_DEFAULT): Define.
	(user_print_options): Initialise max_depth field.
	(val_print_scalar_or_string_type_p): New function.
	(val_print): Check to see if the max depth has been reached.
	(val_print_check_max_depth): Define new function.
	(show_print_max_depth): New function.
	(_initialize_valprint): Add 'print max-depth' option.
	* valprint.h (struct value_print_options) <max_depth>: New field.
	(val_print_check_max_depth): Declare new function.
	* NEWS: Document new feature.

gdb/doc/ChangeLog:

	* gdb.texinfo (Print Settings): Document 'print max-depth'.
	* guile.texi (Guile Pretty Printing API): Document that 'print
	max-depth' can effect the display of a values children.
	* python.texi (Pretty Printing API): Likewise.
	(Values From Inferior): Document max_depth keyword.

gdb/testsuite/ChangeLog:

	* gdb.base/max-depth.c: New file.
	* gdb.base/max-depth.exp: New file.
	* gdb.python/py-nested-maps.c: New file.
	* gdb.python/py-nested-maps.exp: New file.
	* gdb.python/py-nested-maps.py: New file.
	* gdb.python/py-format-string.exp (test_max_depth): New proc.
	(test_all_common): Call test_max_depth.
	* gdb.fortran/max-depth.exp: New file.
	* gdb.fortran/max-depth.f90: New file.
	* gdb.go/max-depth.exp: New file.
	* gdb.go/max-depth.go: New file.
	* gdb.modula2/max-depth.exp: New file.
	* gdb.modula2/max-depth.c: New file.
	* lib/gdb.exp (get_print_expr_at_depths): New proc.
2019-04-29 22:01:09 +01:00
Philippe Waroquiers 136afab8c7 Implement show | set may-call-functions [on|off]
Inferior function calls are powerful but might lead to undesired
results such as crashes when calling nested functions (frequently
used in particular in Ada).

This implements a GDB setting to disable calling inferior functions.

Note: the idea is that if/when the 'slash command' patch is pushed,
that this setting can be changed e.g. by using the shortcut /c.

This is version 2 of the patch.  It handles all the received comments,
mostly replace 'can-call' by 'may-call', and avoid using
'inferior function call' in factor of 'calling function in the program'.

2019-04-26  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

gdb/ChangeLog
	* NEWS: Mention the new set|show may-call-functions.
	* infcall.c (may_call_functions_p): New variable.
	(show_may_call_functions_p): New function.
	(call_function_by_hand_dummy): Throws an error if not
	may-call-functions.
	(_initialize_infcall): Call add_setshow_boolean_cmd for
	may-call-functions.

gdb/testsuite/ChangeLog
	* gdb.base/callexit.exp: Test may-call-functions off.

gdb/doc/ChangeLog
	* gdb.texinfo (Calling): Document the new
	set|show may-call-functions.
2019-04-27 13:12:42 +02:00
Andrew Burgess 8bdc16587e gdb: Add $_cimag and $_creal internal functions
Add two new internal functions $_cimag and $_creal that extract the
imaginary and real parts of a complex value.

These internal functions can take a complex value of any type 'float
complex', 'double complex', or 'long double complex' and return a
suitable floating point value 'float', 'double', or 'long double'.
So we can now do this:

    (gdb) p z1
    $1 = 1.5 + 4.5 * I
    (gdb) p $_cimag (z1)
    $4 = 4.5
    (gdb) p $_creal (z1)
    $4 = 1.5

The components of a complex value are not strictly named types in
DWARF, as the complex type is itself the base type.  However, once we
are able to extract the components it makes sense to be able to ask
what the type of these components is and get a sensible answer back,
rather than the error we would currently get.  Currently GDB says:

    (gdb) ptype z1
    type = complex double
    (gdb) p $_cimag (z1)
    $4 = 4.5
    (gdb) ptype $
    type = <invalid type code 9>

With the changes in dwarf2read.c, GDB now says:

    (gdb) ptype z1
    type = complex double
    (gdb) p $_cimag (z1)
    $4 = 4.5
    (gdb) ptype $
    type = double

Which seems to make more sense.

gdb/ChangeLog:

	* NEWS: Mention new internal functions.
	* dwarf2read.c (dwarf2_init_complex_target_type): New function.
	(read_base_type): Use dwarf2_init_complex_target_type.
	* value.c (creal_internal_fn): New function.
	(cimag_internal_fn): New function.
	(_initialize_values): Register new internal functions.

gdb/doc/ChangeLog:

	* gdb.texinfo (Convenience Funs): Document '$_creal' and
	'$_cimag'.

gdb/testsuite/ChangeLog:

	* gdb.base/complex-parts.c: New file.
	* gdb.base/complex-parts.exp: New file.
2019-04-01 21:41:49 +01:00
Marco Barisione 52093e1b93 Add gdb.Value.format_string ()
The str () function, called on a gdb.Value instance, produces a string
representation similar to what can be achieved with the print command,
but it doesn't allow to specify additional formatting settings, for
instance disabling pretty printers.

This patch introduces a new format_string () method to gdb.Value which
allows specifying more formatting options, thus giving access to more
features provided by the internal C function common_val_print ().

gdb/ChangeLog:

2019-04-01  Marco Barisione  <mbarisione@undo.io>

	Add gdb.Value.format_string ().
	* python/py-value.c (copy_py_bool_obj):
	(valpy_format_string): Add gdb.Value.format_string ().
	* NEWS: Document the addition of gdb.Value.format_string ().

gdb/doc/ChangeLog:

2019-04-01  Marco Barisione  <mbarisione@undo.io>

	* python.texi (Values From Inferior): Document
	gdb.Value.format_string ().

gdb/testsuite/ChangeLog:

2019-04-01  Marco Barisione  <mbarisione@undo.io>

	Test gdb.Value.format_string ().
	* gdb.python/py-format-string.exp: New test.
	* gdb.python/py-format-string.c: New file.
	* gdb.python/py-format-string.py: New file.
2019-04-01 10:00:04 +02:00
Eli Zaretskii 7734102d6d Introduce new convenience variables $_gdb_major and $_gdb_minor
gdb/ChangeLog:
2019-03-30  Eli Zaretskii  <eliz@gnu.org>

	* NEWS: Announce $_gdb_major and $_gdb_minor.

	* top.c (init_gdb_version_vars): New function.
	(gdb_init): Call init_gdb_version_vars.

gdb/testsuite/ChangeLog:
2019-03-30  Simon Marchi <simark@simark.ca>

	* gdb.base/default.exp: Add values for $_gdb_major and
	$_gdb_minor.

gdb/doc/ChangeLog:
2019-03-30  Eli Zaretskii  <eliz@gnu.org>

	* gdb.texinfo (Convenience Vars): Document $_gdb_major and
	$_gdb_minor.
2019-03-30 12:58:33 +03:00
Alan Hayward d851aa7170 Add AArch64 Pointer Authentication to the NEWS file
gdb/ChangeLog:

        * NEWS: Mention AArch64 Pointer Authentication.
2019-03-26 17:09:00 +00:00
John Baldwin 81a24d04df Note support for TLS variables on FreeBSD.
gdb/ChangeLog:

	* NEWS: Mention TLS support for FreeBSD.
2019-03-25 13:23:42 -07:00
Tom Tromey d085f98901 Add the "set style source" command
This adds "set style source" (and "show style source") commands.  This
gives the user control over whether source code is highlighted.

gdb/ChangeLog
2019-03-14  Tom Tromey  <tromey@adacore.com>

	* NEWS: Add item for "style sources" commands.
	* source-cache.c (source_cache::get_source_lines): Check
	source_styling.
	* cli/cli-style.c (source_styling): New global.
	(_initialize_cli_style): Add "style sources" commands.
	(show_style_sources): New function.
	* cli/cli-style.h (source_styling): Declare.

gdb/doc/ChangeLog
2019-03-14  Tom Tromey  <tromey@adacore.com>

	* gdb.texinfo (Output Styling): Document "set style source" and
	"show style source".

gdb/testsuite/ChangeLog
2019-03-14  Tom Tromey  <tromey@adacore.com>

	* gdb.base/style.exp: Add "set style sources" test.
2019-03-14 05:47:11 -06:00
Simon Marchi b4be1b0648 Fix MI output for multi-location breakpoints
New in v2:

- Addressed comments about doc, updated the MI version table
- New doc for the Breakpoint information format
- New -fix-multi-location-breakpoint-output command, with associated
  doc, test and NEWS updated accordingly
- Fixed the output, the locations list is now actually in the tuple
  representing the breakpoint.

Various MI commands or events related to breakpoints output invalid MI
records when printing information about a multi-location breakpoint.
For example:

    -break-insert allo
    ^done,bkpt={...,addr="<MULTIPLE>",...},{number="1.1",...},{number="1.2",...}

The problem is that according to the syntax [1], the top-level elements
are of type "result" and should be of the form "variable=value".

This patch changes the output to wrap the locations in a list:

    ^done,bkpt={...,addr="<MULTIPLE>",locations=[{number="1.1",...},{number="1.2",...}]}

The events =breakpoint-created, =breakpoint-modified, as well as the
-break-info command also suffer from this (and maybe others I didn't
find).

Since this is a breaking change for MI, we have to deal somehow with
backwards compatibility.  The approach taken by this patch is to bump
the MI version, use the new syntax in MI3 while retaining the old syntax
in MI2.  Frontends are expected to use a precise MI version (-i=mi2), so
if they do that they should be unaffected.

The patch also adds the command -fix-multi-location-breakpoint-output,
which front ends can use to enable this behavior with MI <= 2.

[1] https://sourceware.org/gdb/onlinedocs/gdb/GDB_002fMI-Output-Syntax.html#GDB_002fMI-Output-Syntax

gdb/ChangeLog:

	* NEWS: Mention that the new default MI version is 3.  Mention
	changes to the output of commands and events that deal with
	multi-location breakpoints.
	* breakpoint.c: Include "mi/mi-out.h".
	(print_one_breakpoint): Change output syntax if using MI version
	>= 3.
	* mi/mi-main.h (mi_cmd_fix_multi_location_breakpoint_output):
	New.
	(mi_multi_location_breakpoint_output_fixed): New.
	* mi/mi-main.c (fix_multi_location_breakpoint_output): New.
	(mi_cmd_fix_multi_location_breakpoint_output): New.
	(mi_multi_location_breakpoint_output_fixed): New.
	* mi/mi-cmds.c (mi_cmds): Register command
	-fix-multi-location-breakpoint-output.
	* mi/mi-out.c (mi_out_new): Instantiate version 3 when using
	interpreter "mi".

gdb/testsuite/ChangeLog:

	* mi-breakpoint-location-ena-dis.exp: Rename to ...
	* mi-breakpoint-multiple-locations.exp: ... this.
	(make_breakpoints_pattern): New proc.
	(do_test): Add mi_version parameter, test -break-insert,
	-break-info and	=breakpoint-created.

gdb/doc/ChangeLog:

	* gdb.texinfo (Mode Options): Mention mi3.
	(Interpreters): Likewise.
	(GDB/MI Development and Front Ends): Add entry for MI 3 in
	version table.  Document -fix-multi-location-breakpoint-output.
	(GDB/MI Breakpoint Information): Document format of breakpoint
	location output.
2019-03-13 15:14:36 -04:00
John Baldwin 197df35ec4 The NEWS file had two "New targets" sections for 8.3.
gdb/ChangeLog:

	* NEWS: Combine separate "New targets" sections for 8.3.
2019-03-12 13:56:53 -07:00
Eli Zaretskii 742a7df5f4 GDB no longer supports Windows before XP.
gdb/ChangeLog:
2019-03-02  Eli Zaretskii  <eliz@gnu.org>

	* NEWS: Mention end of support for native debugging on MS-Windows
	before XP.
2019-03-02 15:18:32 +02:00
Kevin Buettner 2c3fc25dd1 Document fact that mininum Python version is now 2.6
gdb/ChangeLog:

	* NEWS: Note minimum Python version.

gdb/doc/ChangeLog:

	* gdb.texinfo (Configure Options): Document minimum python
	version.
2019-02-27 11:13:47 -07:00