Commit Graph

41761 Commits

Author SHA1 Message Date
Tom Tromey 7806cea723 Deprecate and replace the "tabset" command
The "tabset" command sets the tab width as used by the TUI for source
and disassembly display.

This command has long seemed to be misnamed to me.  It is more in
keeping with gdb design to call it "set tui tab-width".  Also, making
this change allows for the corresponding "show" command to work.

gdb/ChangeLog
2018-10-19  Tom Tromey  <tom@tromey.com>

	PR tui/18388:
	* NEWS: Mention tabset deprecation.
	* tui/tui-win.c (tui_tab_width, internal_tab_width): New globals.
	(update_tab_width): New function.
	(tui_set_tab_width, tui_show_tab_width): New functions.
	(tui_set_tab_width_command): Use update_tab_width.
	(_initialize_tui_win): Move to end of file.  Deprecate "tabset".
	Add new "set tui tab-width" command.
	* tui/tui-source.c (tui_set_source_content): Update.
	* tui/tui-disasm.c (tui_set_disassem_content): Update.
	* tui/tui-data.h (tui_default_tab_len, tui_set_default_tab_len):
	Don't declare.
	(tui_tab_width): Declare.
	* tui/tui-data.c (default_tab_len, tui_default_tab_len)
	(tui_set_default_tab_len): Remove.

gdb/doc/ChangeLog
2018-10-19  Tom Tromey  <tom@tromey.com>

	PR tui/18388:
	* gdb.texinfo (TUI Commands): Remove tabset documentation.
	(TUI Configuration): Document "set tui tab-width".
2018-10-19 17:22:27 -06:00
Tom Tromey 84371624ad Minor cleanups in tui-io.c
I noticed that a couple of functions in tui-io.c could be static, and
that a couple more were unused and could be removed.

gdb/ChangeLog
2018-10-19  Tom Tromey  <tom@tromey.com>

	* tui/tui-io.h (key_is_start_sequence, key_is_end_sequence)
	(key_is_backspace, tui_getc): Don't declare.
	* tui/tui-io.c (key_is_start_sequence): Now static.
	(key_is_end_sequence, key_is_backspace): Remove.
	(tui_getc): Now static.
2018-10-19 17:22:27 -06:00
Tom Tromey 22ad8107d3 Clear static_links in reread_symbols
-fsanitize=address pointed out a use-after free in
objfile_register_static_link.  The bug turned out to be that
reread_symbols does not clear the static_links field; this leaves a
hash table that is filled with freed pointers.

Jan's (now quite old) idea of replacing reread_symbols with a simple
delete/new still seems good to me, and it's worth noting that it would
have avoided this bug.

Tested by the buildbot and by observing the change with
-fsanitize=address.

gdb/ChangeLog
2018-10-19  Tom Tromey  <tom@tromey.com>

	* symfile.c (reread_symbols): Clear "static_links".
2018-10-19 10:28:33 -06:00
Alan Hayward 74b3c71318 Aarch64: Better termination checks for sigcontext reading
When reading the reserved section in the sigcontext ensure the
address is updated on an unknown section. Also add additional
checks to prevent reading past the end of the array.

Fixes gdb.base/savedregs.exp

	* aarch64-linux-tdep.c (AARCH64_SIGCONTEXT_RESERVED_SIZE): New
	define.
	(aarch64_linux_sigframe_init): Extra boundary checks.
2018-10-19 13:51:00 +01:00
Andreas Arnez 0667c50682 S390: Fix crash when remote tdesc doesn't define vec128
I've encountered a GDB crash when trying to read registers from a remote
stub that provided a target.xml with vector registers, but without the
'vec128' data type.  The crash is caused by NULL register type entries for
the "concatenated" pseudo-registers v0-v15.  These NULL entries are
introduced by the logic in s390_pseudo_register_type(), where the tdesc
type 'vec128' is returned unconditionally -- even if it doesn't exist (is
NULL).

The fixed logic for determining a "concatenated" vector register's type
now returns the type of the raw register v16 instead.  This also makes
sure that all vector register have the same type.

gdb/ChangeLog:

	* s390-tdep.c (s390_pseudo_register_type): For v0-v15 don't yield
	the possibly non-existent tdesc type 'vec128', but the type of raw
	register v16 instead.
2018-10-19 14:05:08 +02:00
Gary Benson ba543ca5af Fix cli_interp::cli_uiout resource leak found by Coverity
This commit fixes a resource leak found by Coverity, where cli_interp's
constructor creates a new cli_ui_out, but there was no corresponding
destructor to free it.

gdb/ChangeLog:

	* cli/cli-interp.c (cli_interp::~cli_interp): New function.
2018-10-19 11:52:33 +01:00
Alan Hayward b04480b119 Testsuite: Fix racy conditions in py-cmd.exp
The test loop in test_python_inline_or_multiline was not checking for the
gdb prompt. readline_is_used then reads in the prompt causing it to fail
and the final chunk of tests to be skipped.

Spotted this error because sometimes the gdb prompt does get processed
correctly and the final tests are run, causing it to show up in the
racy tests script output.

Fix by ensuring the prompt is always checked for. To do this the list
style needs reformatting so that variables get expanded.

2018-10-19  Alan Hayward  <alan.hayward@arm.com>

	* gdb.python/py-cmd.exp: Check for gdb_prompt.
2018-10-19 11:29:42 +01:00
Alan Hayward 2c6ac8d7ce Testsuite: vla-optimized-out.exp is too pessimistic
On aarch64 (and possibly other ports), for O3 the sizeof "a" can still be shown.

2018-10-19  Alan Hayward  <alan.hayward@arm.com>

	* gdb.base/vla-optimized-out.exp: Allow either optimized out or 6.
2018-10-19 11:21:12 +01:00
Alan Hayward 2bc69f2588 testsuite: ovldbreak.exp: fix regexp
Fix the layout used in the regexp for breakpoints.

Gets rid of two FAILS.

2018-10-18  Alan Hayward  <alan.hayward@arm.com>

	* gdb.cp/ovldbreak.exp: Fix regexps.
2018-10-19 11:13:40 +01:00
Alan Hayward 1f1ae3a34f Testsuite: compile-cplus-print.exp: Start inferior before compiling
skip_compile_feature_tests is only valid if the inferior has already
been started (see proc comments). Move the runto_main earlier.

2018-10-18  Alan Hayward  <alan.hayward@arm.com>

	* gdb.compile/compile-cplus-print.exp: Start inferior earlier.
2018-10-19 11:03:38 +01:00
Sergio Durigan Junior 94c18618a8 Fix PR cli/23785: Check if file exists when invoking "restore FILE binary"
This simple patch fixes the segfault reported on PR cli/23785, which
happens when using the "restore FILE binary" command with a
non-existent file.  We just have to check if the file handler returned
by "gdb_fopen_cloexec" is not NULL, and error out if it is.

A test has also been added to gdb.base/restore.exp in order to
exercise this scenario.

No regressions introduced.

gdb/ChangeLog:
2018-10-18  Sergio Durigan Junior  <sergiodj@redhat.com>

	PR cli/23785
	* cli/cli-dump.c (restore_binary_file): Check if "file" is
	NULL.

gdb/testsuite/ChangeLog:
2018-10-18  Sergio Durigan Junior  <sergiodj@redhat.com>

	PR cli/23785
	* gdb.base/restore.exp: New test to check if "restore" with an
	invalid file doesn't segfault.
2018-10-18 17:39:09 -04:00
Tom de Vries 812cd6eb05 [gdb/testsuite] Fix capitalized test names
At https://sourceware.org/gdb/wiki/GDBTestcaseCookbook\
  #Follow_the_test_name_convention we find:
..
Test names should start with a lower case and don't need to end with a period
(they are not sentences).
...

Fix some capitalized test names.

Tested on x86_64-linux.

2018-10-18  Tom de Vries  <tdevries@suse.de>

	* gdb.ada/bp_inlined_func.exp: Fix capitalized test name.
	* gdb.ada/excep_handle.exp: Same.
	* gdb.ada/mi_string_access.exp: Same.
	* gdb.ada/mi_var_union.exp: Same.
	* gdb.arch/arc-analyze-prologue.exp: Same.
	* gdb.arch/arc-decode-insn.exp: Same.
	* gdb.base/readnever.exp: Same.
	* gdb.fortran/printing-types.exp: Same.
	* gdb.guile/scm-lazy-string.exp: Same.
2018-10-18 15:06:38 +02:00
Paul Koning 89eb3c5470 gdb/ChangeLog:
* charset.c (convert_between_encodings): Fix unsigned overflow.

    gdb/charset.c (convert_between_encodings): Fix unsigned overflow.
2018-10-17 19:26:55 -04:00
John Baldwin 6f3b1098e8 Share the code to format "info proc mappings" entries for FreeBSD.
gdb/ChangeLog:

	* fbsd-nat.c (fbsd_nat_target::info_proc) Use
	fbsd_info_proc_mappings_header and fbsd_info_proc_mappings_entry.
	* fbsd-tdep.c (fbsd_vm_map_entry_flags): Mark static.
	(fbsd_info_proc_mappings_header, fbsd_info_proc_mappings_entry):
	New functions.
	(fbsd_core_info_proc_mappings): Use fbsd_info_proc_mappings_header
	and fbsd_info_proc_mappings_header.
	* fbsd-tdep.h (fbsd_vm_map_entry_flags): Remove.
	(fbsd_info_proc_mappings_header, fbsd_info_proc_mappings_entry):
	New.
2018-10-17 11:42:00 -07:00
Joel Brobecker d500b4f23f gdb/MAINTAINERS: Add Rainer Orth as Solaris maintainer for GDB
gdb/ChangeLog:

	* MAINTAINERS (Responsible Maintainers): Add Rainer Orth as
	Solaris Maintainer.
2018-10-17 11:04:14 -07:00
Tom de Vries c4b9078851 [gdb/testsuite] Rewrite catch-follow-exec.exp
There are two problems with the current catch-follow-exec.exp:
- INTERNAL_GDBFLAGS (containing the datadir setting) is not used
- remote host testing doesn't work

Fix the former by using gdb_spawn_with_cmdline_opts.  Fix the latter by
requiring gdb-native.

Build on x86_64-linux with and without ubsan, and tested.

2018-10-16  Tom de Vries  <tdevries@suse.de>

	PR gdb/23730
	* gdb.base/catch-follow-exec.c: Add copyright notice.
	* gdb.base/catch-follow-exec.exp: Rewrite to use
	gdb_spawn_with_cmdline_opts.  Require gdb-native.
2018-10-16 22:40:41 +02:00
Tom Tromey 63a33118e0 Remove unnecessary casts from TUI
This removes a number of unnecessary casts from the TUI.  Some were
found with -Wuseless-cast (which, I think, can't easily be enabled for
gdb); and some were found by inspection.

Tested by rebuilding on x86-64 Fedora 28.
I'm checking this in.

gdb/ChangeLog
2018-10-15  Tom Tromey  <tom@tromey.com>

	* tui/tui.c (strcat_to_buf): Remove casts.
	* tui/tui-winsource.c (tui_show_source_line)
	(tui_set_is_exec_point_at, tui_line_is_displayed): Remove casts.
	* tui/tui-wingeneral.c (tui_refresh_win, box_win): Remove casts.
	* tui/tui-windata.c (tui_first_data_item_displayed)
	(tui_delete_data_content_windows, tui_erase_data_content)
	(tui_display_all_data, tui_display_data_from)
	(tui_refresh_data_win, tui_vertical_data_scroll): Remove casts.
	* tui/tui-win.c (tui_set_win_height)
	(make_invisible_and_set_new_height, parse_scrolling_args): Remove
	casts.
	* tui/tui-win.c (tui_resize_all): Remove casts.
	(tui_scroll_backward_command, tui_set_focus)
	(tui_set_tab_width_command): Likewise.
	* tui/tui-source.c (tui_vertical_source_scroll): Remove cast.
	* tui/tui-regs.c (tui_show_register_group): Remove cast.
	* tui/tui-layout.c (tui_set_layout_by_name): Remove cast.
	* tui/tui-disasm.c (tui_vertical_disassem_scroll): Remove cast.
	* tui/tui-data.c (tui_partial_win_by_name, tui_free_win_content):
	Remove casts.
2018-10-15 23:01:32 -06:00
Simon Marchi 933e62b1c1 Add Alan Hayward as AArch64/ARM GDB maintainer
gdb/ChangeLog:

	* MAINTAINERS (Responsible Maintainers): Add Alan Hayward as
	AArch64/ARM maintainer.
2018-10-15 15:52:03 -04:00
Sandra Loosemore 8bca297856 Clean up gdb.trace test results on targets not supporting this feature.
2018-10-12  Sandra Loosemore  <sandra@codesourcery.com>

	gdb/testsuite/
	* gdb.trace/actions-changed.exp: Check for arch support.
	* gdb.trace/actions.exp: Likewise.
	* gdb.trace/ax.exp: Likewise.
	* gdb.trace/backtrace.exp: Likewise.
	* gdb.trace/change-loc.exp: Likewise.
	* gdb.trace/deltrace.exp: Likewise.
	* gdb.trace/ftrace-lock.exp: Check for shlib and arch support.
	* gdb.trace/ftrace.exp: Likewise.
	* gdb.trace/infotrace.exp: Check for arch support.
	* gdb.trace/mi-trace-frame-collected.exp: Likewise.
	* gdb.trace/mi-tracepoint-changed.exp: Likewise.
	* gdb.trace/mi-tsv-changed.exp: Likewise.
	* gdb.trace/packetlen.exp: Likewise.
	* gdb.trace/passc-dyn.exp: Likewise.
	* gdb.trace/passcount.exp: Likewise.
	* gdb.trace/pending.exp: Likewise.
	* gdb.trace/range-stepping.exp: Check for shlib support.
	* gdb.trace/report.exp: Check for arch support.
	* gdb.trace/save-trace.exp: Likewise.
	* gdb.trace/signal.exp: Check for signal support.
	* gdb.trace/tfind.exp: Check for arch support.
	* gdb.trace/trace-break.exp: Check for arch and shlib support.
	* gdb.trace/trace-common.h: Add comment.
	* gdb.trace/trace-condition.exp: Check for shlib and arch support.
	* gdb.trace/trace-enable-disable.exp: Likewise.
	* gdb.trace/trace-mt.exp: Likewise.  Remove redundant untested call.
	* gdb.trace/tracecmd.exp: Check for arch support.
	* gdb.trace/tspeed.exp: Check for shlib and target support.
	* gdb.trace/tstatus.exp: Check for arch support.
	* gdb.trace/tsv.exp: Likewise.
	* gdb.trace/while-dyn.exp: Likewise.
	* gdb.trace/while-stepping.exp: Likewise.
	* lib/trace-support.exp (gdb_trace_common_supports_arch): New.
2018-10-12 17:56:13 -07:00
Simon Marchi f9c49bffe6 Fix buglets in gdb.trace/tspeed.{exp,c}
When trying to run gdb.trace/tspeed.exp, I get:

ERROR: can't read "ipalib": no such variable
    while executing
"gdb_load_shlib $ipalib"
    (procedure "prepare_for_trace_test" line 5)

This problem seems to come from commit

    c708f4d256 ("gdb: Don't call gdb_load_shlib unless GDB is running")

which moved the gdb_load_shlib call in prepare_for_trace_test.  In order
to access the ipalib variable, we need to declare "global ipalib" first.

Then, this test uses nowarnings, for no good reason I could find.  We
can remove that and fix the two trivial warnings that appear:

/home/emaisin/src/binutils-gdb/gdb/testsuite/gdb.trace/tspeed.c: In function 'main':
/home/emaisin/src/binutils-gdb/gdb/testsuite/gdb.trace/tspeed.c:87:16: warning: too many arguments for format [-Wformat-extra-args]
        printf ("Negative times, giving up\n", max_iters);
                ^
/home/emaisin/src/binutils-gdb/gdb/testsuite/gdb.trace/tspeed.c:99:7: warning: implicit declaration of function 'sleep' [-Wimplicit-function-declaration]
       sleep (1);  /* set post-run breakpoint here */
       ^

gdb/testsuite/ChangeLog:

	* gdb.trace/tspeed.exp: Remove nowarnings.
	(prepare_for_trace_test): Declare "global ipalib".
	* gdb.trace/tspeed.c: Include unistd.h.
	(main): Remove superfluous printf argument.
2018-10-12 16:27:29 -04:00
Sandra Loosemore d4330bde68 Fix pathname regexp in gdb.base/solib-vanish.exp.
2018-10-11  Sandra Loosemore  <sandra@codesourcery.com>

	gdb/testsuite/
	* gdb.base/solib-vanish.exp: Fix regexp not to require a POSIX
	directory prefix on the filename.
2018-10-11 16:51:26 -07:00
Gary Benson fbe61a3661 Fix interp::m_name resource leak found by Coverity
This commit fixes a resource leak found by Coverity, where interp's
constructor allocated memory for m_name that interp's destructor did
not free.

gdb/ChangeLog:

	* interps.h (interp::m_name): Make private and mutable.
	* interps.c (interp::~interp): Free m_name.
2018-10-11 10:19:26 +01:00
Sergio Durigan Junior 8ecfd7bd4a Add parameter to allow enabling/disabling selftests via configure
This is a follow-up of:

  https://sourceware.org/ml/gdb-patches/2018-08/msg00347.html

Instead of going throttle and always enabling our selftests (even in
non-development builds), this patch is a bit more conservative and
introduces a configure option ("--enable-unit-tests") that allows the
user to choose whether she wants unit tests in the build or not.  Note
that the current behaviour is retained: if no option is provided, GDB
will have selftests included in a development build, and will *not*
have selftests included in a non-development build.

The rationale for having this option is still the same: due to the
many racy testcases and random failures we see when running the GDB
testsuite, it is unfortunately not possible to perform a full test
when one is building a downstream package.  As the Fedora GDB
maintainer and one of the Debian GDB uploaders, I feel like this
situation could be improved by, at least, executing our selftests
after the package has been built.

This patch introduces no regressions to our build.

OK?

gdb/ChangeLog:
2018-10-10  Sergio Durigan Junior  <sergiodj@redhat.com>
	    Simon Marchi <simark@simark.ca>

	* README (`configure' options): Add documentation for new
	"--enable-unit-tests" option.
	* acinclude.m4: Include "selftest.m4".
	* configure: Regenerate.
	* configure.ac: Use "GDB_AC_SELFTEST".
	* maint.c (maintenance_selftest): Update message informing
	that selftests have been disabled.
	(maintenance_info_selftests): Likewise.
	* selftest.m4: New file.

gdb/gdbserver/ChangeLog:
2018-10-10  Sergio Durigan Junior  <sergiodj@redhat.com>
	    Simon Marchi <simark@simark.ca>

	* acinclude.m4: Include "../selftest.m4".
	* configure: Regenerate.
	* configure.ac: Use "GDB_AC_SELFTEST".
	* configure.srv: Use "$enable_unittests" instead of
	"$development" when checking whether unit tests have been
	enabled.
	* server.c (captured_main): Update message informing that
	selftests have been disabled.

gdb/testsuite/ChangeLog:
2018-10-10  Sergio Durigan Junior  <sergiodj@redhat.com>

	* gdb.gdb/unittest.exp: Update expected message informing that
	selftests have been disabled.
	* gdb.server/unittest.exp: Likewise.

squash! Add parameter to allow enabling/disabling selftests via configure
2018-10-10 16:23:56 -04:00
Gary Benson 33b031ce7a Add missing va_end found by Coverity
This commit adds a missing va_end found by Coverity.

gdb/ChangeLog:

	* remote.c (remote_target::remote_send_printf): Add
	missing va_end found by Coverity.
2018-10-10 15:01:50 +01:00
Markus Metzger 2cb2ba9a5b btrace: check for indirect jump return in _Unwind_RaiseException
Some versions of _Unwind_RaiseException, e.g. on Fedora 28, use an
indirect jump to return to the exception handler.

This messes up the output of "record function-call-history /c" since the
return is interpreted as cross-function goto.  It had been detected by
gdb.btrace/exception.exp.

Add a heuristic for "_Unwind_*" functions to interpret an indirect jump
that ends in one of our caller functions as return to the first instance
of that function in our call stack.

gdb/
	* btrace.c (ftrace_update_function): Add indirect jump heuristic.
2018-10-10 12:27:55 +02:00
Tom Tromey 163cffefaf Make @pxref for Inferior.architecture point to gdb.Frame documentation
This fixes he @pxref in Inferior.architecture to point to the "Frames
In Python" node, as originally intended; somewhat reverting an earlier
build fix.  The initial patch had typod the "In".

Tested by "make info".

gdb/doc/ChangeLog
2018-10-09  Tom Tromey  <tom@tromey.com>

	* python.texi (Inferiors In Python): Link to "Frames In Python",
	not "Unwinding Frames in Python".
2018-10-09 13:59:37 -06:00
Tom Tromey eff98030f9 Disable the undefined behavior sanitizer by default
There have been a few undefined behavior failures reported, and Pedro
suggested that the sanitizer be disabled by default.  This patch
implements this.

gdb/ChangeLog
2018-10-09  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.
	* sanitize.m4 (AM_GDB_UBSAN): Default to no.
	* NEWS: Update --enable-ubsan documentation.

gdb/doc/ChangeLog
2018-10-09  Tom Tromey  <tom@tromey.com>

	* gdb.texinfo (Configure Options): Update --enable-ubsan
	documentation.
2018-10-09 11:51:33 -06:00
Tom de Vries 58bbcd02de [gdb/testsuite] Fix target_supports_scheduler_locking raciness
When calling gdb_start_cmd, it's the caller's responsibility to wait for gdb
to return to the prompt.  In target_supports_scheduler_locking, that's not the
case, and consequently, target_supports_scheduler_locking fails spuriously.

Fix by using runto_main instead.

Build and reg-tested on x86_64-linux.

2018-10-09  Tom de Vries  <tdevries@suse.de>

	* lib/gdb.exp (target_supports_scheduler_locking): Replace gdb_start_cmd
	with runto_main.
2018-10-09 15:33:00 +02:00
Gary Benson 04fd5eed91 Fix buffer overrun found by Coverity
This commit fixes a buffer overrun found by Coverity, where
36 bytes are written into a 24 byte buffer.

gdb/ChangeLog:

	* dwarf2read.c (create_dwp_hash_table): Fix buffer overrun
	found by Coverity.
2018-10-09 14:13:12 +01:00
Tom Tromey a0c3048e3f Remove unused variables from riscv-fbsd-tdep.c
This removes a couple of unused variables from riscv-fbsd-tdep.c.
This allows a --enable-targets=all build to complete on
x86-64 Fedora 28.

gdb/ChangeLog
2018-10-08  Tom Tromey  <tom@tromey.com>

	* riscv-fbsd-tdep.c (riscv_fbsd_sigframe_init): Remove unused
	variable.
	(riscv_fbsd_init_abi): Likewise.
2018-10-08 16:39:29 -06:00
Weimin Pan a51bb70c8a Fix the [-Werror=shadow=local] warning
Rename local variable in value_struct_elt_for_reference()
to work around the shadowing a previous local warning.
2018-10-08 22:14:11 +00:00
John Baldwin 74792ff782 Add native target for FreeBSD/riscv.
gdb/ChangeLog:

	* Makefile.in (ALLDEPFILES): Add riscv-fbsd-nat.c.
	* NEWS: Mention new FreeBSD/riscv native configuration.
	* configure.host: Add riscv*-*-freebsd*.
	* configure.nat: Likewise.
	* riscv-fbsd-nat.c: New file.

gdb/doc/ChangeLog:

	* gdb.texinfo (Contributors): Add SRI International and University
	of Cambridge for FreeBSD/riscv.
2018-10-08 14:47:34 -07:00
John Baldwin ed65e20bc7 Add FreeBSD/riscv architecture.
Support for collecting and supplying general purpose and floating
point register sets is provided along with signal frame unwinding.

FreeBSD only supports RV64 currently, so while some provision is made
for RV32 in the general-purpose register set, the changes have only
been tested on RV64.

gdb/ChangeLog:

	* Makefile.in (ALL_TARGET_OBS): Add riscv-fbsd-tdep.o.
	(HFILES_NO_SRCDIR): Add riscv-fbsd-tdep.h.
	(ALLDEPFILES): Add riscv-fbsd-tdep.c.
	* NEWS: Mention new FreeBSD/riscv target.
	* configure.tgt: Add riscv*-*-freebsd*.
	* riscv-fbsd-tdep.c: New file.
	* riscv-fbsd-tdep.h: New file.
2018-10-08 14:47:34 -07:00
John Baldwin 498f740792 Add a helper function to trad_frame to support register cache maps.
Currently, signal frame handlers require explicitly coded calls to
trad_frame_set_reg_addr() to describe the location of saved registers
within a signal frame.  This change permits the regcache_map_entry
arrays used with regcache::supply_regset and regcache::collect_regset
to be used to describe a block of saved registers given an initial
address for the register block.

Some systems use the same layout for registers in core dump notes,
native register sets with ptrace(), and the register contexts saved in
signal frames.  On these systems, a single register map can now be
used to describe the layout of registers in all three places.

If a register map entry's size does not match the native size of a
register, try to match the semantics used by
regcache::transfer_regset.  If a register slot is too large, assume
that the register's value is stored in the first N bytes and ignore
the remaning bytes.  If the register slot is smaller than the
register, assume the slot holds the low N bytes of the register's
value.  Read these low N bytes from the target and zero-extend them to
generate a register value.

While here, document the semantics for both regcache::transfer_regset
and trad_frame with respect to register slot's whose size does not
match the register's size.

gdb/ChangeLog:

	* regcache.h (struct regcache_map_entry): Note that this type can
	be used with traditional frame caches.
	* trad-frame.c (trad_frame_set_reg_regmap): New.
	* trad-frame.h (trad_frame_set_reg_regmap): New.
2018-10-08 14:47:33 -07:00
Weimin Pan 9f6b697b0e Finding data member in virtual base class
This patch fixes the original problem - printing member in a virtual base,
using various expressions, do not yield the same value. Simple test case
below demonstrates the problem:

% cat t.cc
struct base { int i; };
typedef base tbase;
struct derived: virtual tbase { void func() { } };
int main() { derived().func(); }
% g++ -g t.cc
% gdb a.out
(gdb) break derived::func
(gdb) run
(gdb) p i
$1 = 0
(gdb) p base::i
$3 = 0
(gdb) p derived::i
$4 = 4196392

To fix the problem, add function get_baseclass_offset() which searches
recursively for the base class along the class hierarchy. If the base
is virtual, it uses "vptr" in virtual class object, which indexes to
its derived class's vtable, to get and returns the baseclass offset.
If the base is non-virtual, it returns the accumulated offset of its
parent classes. The offset is then added to the address of the class
object to access its member in value_struct_elt_for_reference().
2018-10-08 21:23:50 +00:00
John Darrington c258c396fa GDB: Work around buggy dwarf line information produced by Codewarrior Version 5.0.40 (build 15175).
gdb/ChangeLog:
* dwarf2read.c (dwarf2_cu) <producer_is_codewarrior>: New field.
  (check_producer): Check if the producer is codewarrior.
  (producer_is_codewarrior): New function.
  (lnp_state_machine::record_line): Ignore is_stmt flag for records
   produced by codewarrior.
  (dwarf2_cu::dwarf2_cu): Initialize producer_is_codewarrior.
2018-10-08 10:59:59 +02:00
Andreas Krebbel 9e1698c618 Python doc build fixes
gdb/doc/ChangeLog:

2018-10-08  Andreas Krebbel  <krebbel@linux.ibm.com>

	* python.texi (Inferior.Architecture): Add "@end defun". Rename
	ref target to "Unwinding Frames in Python".
2018-10-08 09:49:48 +02:00
Tom Tromey add5ded5e4 Add Inferior.architecture method
I've written a couple of gdb unwinders in Python, and while doing so,
I wanted to find the architecture of the inferior.  (In an unwinder in
particular, one can't use the frame's architecture, because there is
no frame.)

This patch adds Inferior.architecture to allow this.  Normally I think
I would have chosen an attribute and not a method here, but seeing
that Frame.architecture is a method, I chose a method as well, for
consistency.

gdb/ChangeLog
2018-10-06  Tom Tromey  <tom@tromey.com>

	PR python/19399:
	* python/py-inferior.c: Add "architecture" entry.
	(infpy_architecture): New function.

gdb/doc/ChangeLog
2018-10-06  Tom Tromey  <tom@tromey.com>

	PR python/19399:
	* python.texi (Inferiors In Python): Document
	Inferior.Architecture.

gdb/testsuite/ChangeLog
2018-10-06  Tom Tromey  <tom@tromey.com>

	PR python/19399:
	* gdb.python/py-inferior.exp: Add architecture test.
2018-10-06 23:20:55 -06:00
Tom Tromey 51e78fc5fa Update symbol domain and location values for Python
In the distant past, there was no distinction between domain_enum and
search_domain.  At that point, there were two sets of enumerators in a
single enum -- which is why these were eventually split.  This
confusion leaked out to the Python API as well, as noted in
PR python/21765.

This patch deprecates the constants that aren't useful to the Python
API.  They are left in place for now, but removed from the
documentation.  Also, their values are changed so that, if used, they
might work.  Finally, missing domains and location constants are
added.

gdb/ChangeLog
2018-10-06  Tom Tromey  <tom@tromey.com>

	PR python/21765:
	* python/py-symbol.c (gdbpy_initialize_symbols): Redefine
	SYMBOL_VARIABLES_DOMAIN, SYMBOL_FUNCTIONS_DOMAIN,
	SYMBOL_TYPES_DOMAIN.  Define SYMBOL_MODULE_DOMAIN,
	SYMBOL_COMMON_BLOCK_DOMAIN, SYMBOL_LOC_COMMON_BLOCK.

gdb/doc/ChangeLog
2018-10-06  Tom Tromey  <tom@tromey.com>

	PR python/21765:
	* python.texi (Symbols In Python): Document the module and
	common-block domains.  Remove documentation for incorrect
	domains.
2018-10-06 23:20:55 -06:00
Tom Tromey f9e48344d5 Use standard_output_file in a couple more places
I noticed a few files left over in the testsuite/ directory in the
build tree after running tests.  Normally output files should not wind
up there, but instead should end up in the test's subdirectory.  This
isn't always crucial, but in the past there were problems with tests
clashing, preventing parallel runs, and so it is better to be clean
here.

This patch changes a couple of tests to use standard_output_file to
fix this problem.

Tested by re-running the tests in question and examining the
directory.

gdb/testsuite/ChangeLog
2018-10-06  Tom Tromey  <tom@tromey.com>

	* gdb.base/gnu-ifunc.exp (build): Use standard_output_file.
	* gdb.trace/unavailable-dwarf-piece.exp: Use standard_output_file.
2018-10-06 22:48:17 -06:00
Tom Tromey a8a5dbcab8 Do not accidentally include in-tree readline headers
PR build/17077 points out that when --with-system-readline is given,
gdb will still pick up the in-tree readline headers.  Normally this is
not a big problem, because readline is very stable and so the ABI does
not change much; but it is clearly a bug to do this, and could bite at
some point.

The basic problem is that OPCODES_CFLAGS uses -I$(OPCODES_SRC)/..  so
that #include "opcodes/..." works.  However, this also makes it so the

This patch fixes the problem in a mildly hacky way: remove the
offending -I option, and change gdb to use #include "../opcodes/..."
instead.  This continues to make it clear where the header comes from,
without allowing incorrect behavior.

Tested by rebuilding and then looking at the *.Po files.

gdb/ChangeLog
2018-10-06  Tom Tromey  <tom@tromey.com>

	PR build/17077:
	* Makefile.in (OPCODES_CFLAGS): Remove "-I$(OPCODES_SRC)/..".
	* arc-tdep.c, frv-tdep.c, lm32-tdep.c, mep-tdep.c,
	microblaze-tdep.c, or1k-tdep.h: Use ../opcodes, not opcodes, in
	#include.
2018-10-06 22:46:56 -06:00
Tom Tromey 2a8be20359 Fix Python gdb.Breakpoint.location crash
I noticed today that gdb.Breakpoint.location will crash when applied
to a catchpoint made with "catch throw".

The bug is that "catch throw" makes a breakpoint that is of type
bp_breakpoint, but which does not have a location.

Regression tested on x86-64 Fedora 28.

gdb/ChangeLog
2018-10-06  Tom Tromey  <tom@tromey.com>

	* python/py-breakpoint.c (bppy_get_location): Handle a
	bp_breakpoint without a location.

gdb/testsuite/ChangeLog
2018-10-06  Tom Tromey  <tom@tromey.com>

	* gdb.python/py-breakpoint.exp (check_last_event): Check location
	of a "throw" catchpoint.
2018-10-06 22:17:45 -06:00
Tom Tromey 2fb009bbd1 Update help text for commands implemented in Python
Philippe pointed out that the "enable frame-filter" help text looked
funny.

While fixing this I noticed a few more problems in the help text of
commands written in Python:

* Trailing newlines
* Wrong style for metasyntactic variables
* Indentation of the text
* ... and finally, I thought the function usage lines didn't need
  that extra newline -- someday I'd like to be able to write a
  "usage" command that just greps for the Usage line, so ideally it
  would be tighter than what was done here

This patch fixes all the problems I noticed.

gdb/ChangeLog
2018-10-06  Tom Tromey  <tom@tromey.com>

	* python/lib/gdb/function/strfns.py (_MemEq, _StrLen, _StrEq)
	(_RegEx): Reformat help text.
	* python/lib/gdb/function/caller_is.py (CallerIs, CallerMatches)
	(AnyCallerIs, AnyCallerMatches): Reformat help text.
	* python/lib/gdb/function/as_string.py (_AsString): Reformat help
	text.
	* python/lib/gdb/command/xmethods.py (InfoXMethod)
	(EnableXMethod, DisableXMethod): Remove help indentation.
	Capitalize meta-syntactic variables.
	* python/lib/gdb/command/unwinders.py (InfoUnwinder)
	(EnableUnwinder, DisableUnwinder): Remove help indentation.
	Capitalize meta-syntactic variables.
	* python/lib/gdb/command/explore.py (ExploreCommand)
	(ExploreValueCommand, ExploreTypeCommand): Reformat help text.
	* python/lib/gdb/command/type_printers.py (InfoTypePrinter)
	(EnableTypePrinter, DisableTypePrinter): Remove help indentation.
	* python/lib/gdb/command/pretty_printers.py (InfoPrettyPrinter):
	Remove help indentation.
	(EnablePrettyPrinter, DisablePrettyPrinter): Likewise.
	* python/lib/gdb/command/frame_filters.py (EnableFrameFilter)
	(DisableFrameFilter, SetFrameFilterPriority)
	(ShowFrameFilterPriority, InfoFrameFilter): Reword help text.
2018-10-06 22:10:21 -06:00
Tom Tromey 7a9569281a Call nonl before wgetch in TUI
PR tui/28819 points out that, in the TUI, the C-j and C-m keys cannot
be bound differently in one's ~/.inputrc.  However, this works in
other readline applications.

The bug is that the TUI uses curses' "nl" mode, which causes wgetch to
return the same value for both keys.  There is a "nonl" mode, but it
also affects output.

This patch fixes the bug by arranging to call nonl before reading a
key and then nl afterward.  This avoids any potential problem with
changing the output if gdb was to use nonl globally.

gdb/ChangeLog
2018-10-06  Tom Tromey  <tom@tromey.com>

	PR tui/28819:
	* tui/tui-io.c (gdb_wgetch): New function.
	(tui_mld_getc, tui_getc): Use it.
2018-10-06 15:51:37 -06:00
Sergio Durigan Junior e04caa7090 Update string expected from "help info proc" on gdb.base/info-proc.exp
Commit 73f1bd769a ("Make the "info proc" documentation more
consistent.") updated the output from "help info proc", but forgot to
update the test on gdb.base/info-proc.exp.  This obvious patch does
that.

Checked-in as obvious.

gdb/testsuite/ChangeLog:
2018-10-06  Sergio Durigan Junior  <sergiodj@redhat.com>

	* gdb.base/info-proc.exp: Update string expected from "help info
	proc".
2018-10-06 11:23:02 -04:00
Tom Tromey f8740dc531 Fix -Wshadow=local warning in sol_thread_target::wait
Rainer pointed out that -Wshadow=local broke the Solaris build.
This fixes it.

gdb/ChangeLog
2018-10-05  Tom Tromey  <tom@tromey.com>

	* sol-thread.c (sol_thread_target::wait): Rename inner
	"save_ptid".
2018-10-05 10:38:01 -06:00
Tom Tromey 96643e35c0 Add -Wshadow=local
This adds -Wshadow=local to configure.

gdb/ChangeLog
2018-10-04  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.
	* warning.m4 (AM_GDB_WARNINGS): Add -Wshadow=local.

gdb/gdbserver/ChangeLog
2018-10-04  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.
2018-10-04 22:51:49 -06:00
Tom Tromey d951f98b3c Shadowing fix in gdbscm_frame_read_var
-Wshadow=local pointed out that the shadowing in gdbscm_frame_read_var
means that the ultimate call to read_var_value will always be passed
block==NULL.  The fix is to remove the inner declaration.

gdb/ChangeLog
2018-10-04  Tom Tromey  <tom@tromey.com>

	* guile/scm-frame.c (gdbscm_frame_read_var): Remove inner
	declaration of "block".
2018-10-04 22:51:48 -06:00
Tom Tromey b8c888478d Avoid shadowing in fdwalk
-Wshadow=local caught this buglet.  fdwalk redeclares "result" in the
inner scope, meaning that this function will always return 0, even on
error.

gdb/ChangeLog
2018-10-04  Tom Tromey  <tom@tromey.com>

	* common/filestuff.c (fdwalk): Remove inner declaration of
	"result".
2018-10-04 22:51:48 -06:00
Tom Tromey ef789dc484 Fix latent bug in msp430-tdep.c
-Wshadow=local found this latent bug.  msp430-tdep.c does:

    const gdb_byte *arg_bits;
    {
      /* Aggregates of any size are passed by reference.  */
      gdb_byte struct_addr[4];
[...
      arg_bits = struct_addr;
    }
    ... use arg_bits

Here, arg_bits can point to an object that's gone out of scope.

The fix is to hoist the inner "struct_addr" buffer to an outer scope,
and rename it to avoid shadowing.

gdb/ChangeLog
2018-10-04  Tom Tromey  <tom@tromey.com>

	* msp430-tdep.c (msp430_push_dummy_call): Rename inner
	"structs_addr" and hoist declaration.
2018-10-04 22:51:47 -06:00