Commit Graph

43437 Commits

Author SHA1 Message Date
Christian Biesinger 9aa5520697 Factor out the common code in lookup_{static,global}_symbol
The two functions are extremely similar; this factors out their code into
a shared _internal function.

gdb/ChangeLog:

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

	* symtab.c (lookup_static_symbol): Call the new function (and move
	it down to be next to lookup_global_symbol).
	(struct global_sym_lookup_data): Add block_enum member and rename to...
	(struct global_or_static_sym_lookup_data): ...this.
	(lookup_symbol_global_iterator_cb): Pass block_index instead of
	GLOBAL_BLOCK to lookup_symbol_in_objfile and rename to...
	(lookup_symbol_global_or_static_iterator_cb): ...this.
	(lookup_global_or_static_symbol): New function.
	(lookup_global_symbol): Call new function.
2019-08-26 16:24:33 -05:00
Tom de Vries 5c31b35808 [gdb, c++] Improve error message when using libstdcxx without SDT probes
When using catch catch/rethrow/catch, a libstdcxx with SDT probes is required
for both the regexp argument, and the convenience variable $_exception (
https://sourceware.org/gdb/current/onlinedocs/gdb/Set-Catchpoints.html ).

Currently, when using these features with a libstdcxx without SDT probes, we
get the cryptic error message:
...
not stopped at a C++ exception catchpoint
...

Improve this by instead emitting the more helpful:
...
did not find exception probe (does libstdcxx have SDT probes?)
...

Tested on x86_64-linux.

gdb/ChangeLog:

2019-08-26  Tom de Vries  <tdevries@suse.de>

	PR c++/24852
	* break-catch-throw.c (fetch_probe_arguments): Improve error mesage
	when pc_probe.prob == NULL.

gdb/testsuite/ChangeLog:

2019-08-26  Tom de Vries  <tdevries@suse.de>

	PR c++/24852
	* gdb.cp/no-libstdcxx-probe.exp: New test.
2019-08-26 19:24:59 +02:00
Tom de Vries b694989f50 [gdb/testsuite] Make skip_libstdcxx_probe_tests return 1 if true
The tcl proc skip_libstdcxx_probe_tests currently returns 0 if the probe tests
need to be skipped, while tcl interprets 0 as false rather than true, which is
confusing.

Fix this by making skip_libstdcxx_probe_tests return 1 if the probe tests need
to be skipped.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-08-26  Tom de Vries  <tdevries@suse.de>

	* lib/gdb.exp (skip_libstdcxx_probe_tests_prompt): Return 1 if probe
	* tests need to be skipped.
	* gdb.cp/exceptprint.exp: Update call to skip_libstdcxx_probe_tests.
	* gdb.mi/mi-catch-cpp-exceptions.exp: Update call to
	mi_skip_libstdcxx_probe_tests.
2019-08-26 18:48:02 +02:00
Sergio Durigan Junior d9c4ba536c Use raw strings on gdb.python/py-xmethods.exp (and fix Python 3.8's "SyntaxWarning: invalid escape sequence")
The way unrecognized escape sequences are handled has changed in
Python 3.8: users now see a SyntaxWarning message, which will
eventually become a SyntaxError in future versions of Python:

  (gdb) source /blabla/gdb.python/py-xmethods/py-xmethods.py
  /blabla/gdb.python/py-xmethods/py-xmethods.py:204: SyntaxWarning: invalid escape seque
  nce \+
    'operator\+',
  /blabla/gdb.python/py-xmethods/py-xmethods.py:211: SyntaxWarning: invalid escape seque
  nce \+
    'operator\+\+',

One of our testcases, gdb.python/py-xmethods.exp, contains strings in
the form of "operator\+".  This is not recognized by Python, but is
still needed by the testsuite to work properly.  The solution is
simple: we just have to make sure these strings are marked as
raw (i.e, r"").  This is what this patch does.  I took the opportunity
to also convert other strings to raw, which, in two cases, allowed the
removal of an extra backslash.

I tested this using Python 3.7 and Python 3.8, and everything works
fine.

I think I could push this as obvious, but decided to send it to
gdb-patches just in case.

gdb/testsuite/ChangeLog:
2019-08-26  Sergio Durigan Junior  <sergiodj@redhat.com>

	* gdb.python/py-xmethods.exp: Use raw strings when passing
	arguments to SimpleXMethodMatcher.
2019-08-26 09:18:37 -04:00
Simon Marchi 23c13d4299 dwarf2read: fix compilation issue with gcc 4.8
gcc 4.8 (and probably other versions too) doesn't like that the local
variable symbol_linkage has the same name as the enum class defined in
the same context:

      CXX    dwarf2read.o
    /home/smarchi/src/binutils-gdb/gdb/dwarf2read.c: In member function ‘dwarf2_per_cu_data* dw2_debug_names_iterator::next()’:
    /home/smarchi/src/binutils-gdb/gdb/dwarf2read.c:5850:22: error: ‘symbol_linkage’ is not a class, namespace, or enumeration
       } symbol_linkage = symbol_linkage::unknown;
                      ^

Rename the local variable to avoid this.

This problem was originally reported with the Netbsd builder on the
buildbot, which uses gcc 5.5, I believe.  I am not able to test it on
that builder right now, but chances are that the fix will work there
too.

gdb/ChangeLog:

	* dwarf2read.c (dw2_debug_names_iterator::next): Rename local
	variable symbol_linkage to symbol_linkage_.
2019-08-25 21:30:12 -04:00
Simon Marchi beadd3e84e dwarf2read: replace gdb::optional<bool> with enum
gdb::optional<bool> is dangerous, because it's easy to do:

  if (opt_bool)

when you actually meant

  if (*opt_bool)

or vice-versa.  The first checks if the optional is set, the second
checks if the wrapped bool is true.

Replace it with an enum that explicitly defines the three possible
states.

gdb/ChangeLog:

	* dwarf2read.c (dw2_debug_names_iterator::next): Use enum to
	represent whether the symbol is static, dynamic, or we don't
	know.
2019-08-25 18:09:47 -04: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
Christian Biesinger d0509ba443 Fix compile warning in symtab.c
My compiler (g++ 8.2) can't tell that *bsc_ptr and *slot_ptr are
only used in the cases when it does get initialized. Just initialize
the vars earlier to avoid the warning, there does not seem to be a
downside to it.

../../gdb/symtab.c: In function ‘block_symbol lookup_static_symbol(const char*, domain_enum)’:
../../gdb/symtab.c:1366:11: warning: ‘slot’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     xfree (slot->value.not_found.name);
     ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../gdb/symtab.c:2578:29: note: ‘slot’ was declared here
   struct symbol_cache_slot *slot;
                             ^~~~
../../gdb/symtab.c:1405:3: warning: ‘bsc’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   if (bsc == NULL)
   ^~
../../gdb/symtab.c:2577:30: note: ‘bsc’ was declared here
   struct block_symbol_cache *bsc;
                              ^~~
../../gdb/symtab.c: In function ‘block_symbol lookup_global_symbol(const char*, const block*, domain_enum)’:
../../gdb/symtab.c:1366:11: warning: ‘slot’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     xfree (slot->value.not_found.name);
     ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../gdb/symtab.c:2658:29: note: ‘slot’ was declared here
   struct symbol_cache_slot *slot;
                             ^~~~
../../gdb/symtab.c:1409:14: warning: ‘bsc’ may be used uninitialized in this function [-Wmaybe-uninitialized]
       ++bsc->collisions;
         ~~~~~^~~~~~~~~~
../../gdb/symtab.c:2657:30: note: ‘bsc’ was declared here
   struct block_symbol_cache *bsc;
                              ^~~

gdb/ChangeLog:

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

	* symtab.c (symbol_cache_lookup): Always initialize *bsc_ptr and *slot_ptr.
2019-08-24 16:45:59 -05:00
Sergio Durigan Junior 2d41fa1165 Move gdb-dlfcn.[ch] to gdbsupport/
I need to use 'gdb_dlopen' inside 'gdbsupport/', but it's not yet
supported there.  This commit moves 'gdb-dlfcn.[ch]' to 'gdbsupport/',
which makes it available also on gdbserver.

gdb/ChangeLog:
2019-08-23  Sergio Durigan Junior  <sergiodj@redhat.com>

	* configure.ac: Don't check for 'dlfcn.h' (moved to
	gdbsupport/common.m4).
	* Makefile.in (COMMON_SFILES): Move 'gdb-dlfcn.c' to
	'gdbsupport/'.
	(HFILES_NO_SRCDIR): Likewise, for 'gdb-dlfcn.h'.
	* compile/compile-c-support.c: Include
	'gdbsupport/gdb-dlfcn.h'.
	* gdbsupport/common.m4: Check for 'dlfcn.h'.
	* gdb-dlfcn.c: Move to...
	* gdbsupport/gdb-dlfcn.c: ... here.
	* gdb-dlfcn.h: Move to...
	* gdbsupport/gdb-dlfcn.h: ... here.

gdb/gdbserver/ChangeLog:
2019-08-23  Sergio Durigan Junior  <sergiodj@redhat.com>

	* Makefile.in (SFILES): Add 'gdbsupport/gdb-dlfcn.c'.
	(OBS): Add 'gdbsupport/gdb-dlfcn.o'.
	* config.in: Regenerate.
	* configure: Regenerate.
2019-08-23 13:13:18 -04:00
Sandra Loosemore de8af80891 Fix bug in nios2 prologue analysis.
The nios2 prologue analyzer was mistakenly using an unsigned int field
to represent a 32-bit signed value.  This caused problems with an
incorrect conversion being applied to negative values when they were
automatically promoted for addition to a 64-bit CORE_ADDR value.

This patch fixes test failures in gdb.base/large-frame.exp and
gdb.dwarf2/dw2-ref-missing-frame.exp.  Normally the nios2 backend
prefers to use the dwarf2 unwinder so the prologue analyzer is only
invoked if there is no dwarf2 information.

2019-08-23  Sandra Loosemore  <sandra@codesourcery.com>

	gdb/
	* nios2-tdep.c (struct reg_value): Improve comments.  Make
	the offset field signed.
2019-08-23 08:18:54 -07:00
Christian Biesinger 272044897e Make GDB compile with Python 3 on MinGW
PyFile_FromString and PyFile_AsFile have been removed in Python 3.
There is no obvious replacement that works here, and we can't just
pass our FILE* to a DLL in Windows because it may use a different
C runtime.

So we just call a Python function which reads and executes file
contents. Care must be taken to execute it in the context of
__main__.

Tested by inverting the ifdef and running the testsuite on Debian
Linux (even without the patch, I failed at running the testsuite
on Windows). I did test with both Python 2 and 3.

gdb/ChangeLog:

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

	* python/lib/gdb/__init__.py (_execute_file): New function.
	* python/python.c (python_run_simple_file): Call gdb._execute_file
	on Windows.
2019-08-22 17:44:58 -05:00
Tom de Vries 395fad095c [gdb/testsuite] Make gdb_test message more informative in multi-term-settings.exp
This racy fail message, reported in PR24929:
...
FAIL: gdb.multi/multi-term-settings.exp: inf1_how=attach: inf2_how=attach: \
  stop with control-c
...
does not make clear which gdb_test fails here:
...
    if {$expect_ttou} {
       gdb_test "" "Quit" "stop with control-c"
    } else {
       gdb_test "" "received signal SIGINT.*" "stop with control-c"
    }
...

Fix this by making the gdb_test message argument more informative.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-08-22  Tom de Vries  <tdevries@suse.de>

	* gdb.multi/multi-term-settings.exp (coretest): Make gdb_test messages
	more informative.
2019-08-22 16:54:59 +02:00
Andrew Burgess 43771869e5 gdb/fortran: Remove some dead code from the parser
The Fortran parser contains some code that looks like it was probably
inherited from the C/C++ parser as it checks to see if the current
language is C++, which should never be true when we're in the Fortran
parser.

gdb/ChangeLog:

	* f-exp.y (yylex): Remove is_a_field_of_this local variable, and
	all uses as this was never set to anything but a zero value.
2019-08-22 12:34:42 +01:00
Pedro Alves 26c957f127 Fix nullptr in with_command_1
Running 'with' without arguments crashes GDB.  This fixes it.

gdb/ChangeLog:
2019-08-21  Bogdan Harjoc  <harjoc@gmail.com>

	* cli/cli-cmds.c (with_command_1): Error out if no arguments.

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

	* gdb.base/with.exp: Test "with" with no arguments.
2019-08-21 21:11:33 +01:00
Christian Biesinger c07aae6e72 Fix g++ 9.1 build breakage
gdb/ChangeLog:

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

	* tui/tui-data.h (tui_gen_win_info): Add an =default
	move constructor, required by some GCC versions.
2019-08-21 15:09:50 -05:00
Jinke Fan 3960cb7a1b gdb/djgpp: Add Hygon Dhyana processor support
Chengdu Haiguang IC Design Co., Ltd (Hygon) is a Joint Venture between
AMD and Haiguang Information Technology Co.,Ltd., which aims at
providing high performance x86 processors for the China server market.
Its first generation processor codename is Dhyana, which originates
from AMD technology and shares most of the architecture with AMD's
family 17h, but with different CPU Vendor ID("HygonGenuine")/Family
series number(Family 18h).

gdb/ChangeLog:
2019-08-21  Jinke Fan  <fanjinke51@yeah.net>

	* go32-nat.c (go32_sysinfo): Add hygon_p.
2019-08-21 18:07:39 +01:00
Tom de Vries 61f80d5daf [gdb/testsuite] Stabilize gdb-caching-proc.exp test order
The test-case gdb-caching-proc.exp tests each gdb_caching_proc in
gdb/testsuite/lib/*.exp.  However, the order of .exp file being tested can
change from run to run, because of using glob.

Fix this by sorting the glob result.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-08-21  Tom de Vries  <tdevries@suse.de>

	* gdb.base/gdb-caching-proc.exp: Sort files.
2019-08-21 11:49:33 +02:00
Tom Tromey 04c72a68e0 Change some tui_data_window methods to be private
Turning various calls into methods has made it possible to now change
some tui_data_window methods to be private.

2019-08-20  Tom Tromey  <tom@tromey.com>

	* tui/tui-regs.h (struct tui_data_window) <last_regs_line_no,
	line_from_reg_element_no, first_reg_element_no_inline,
	display_all_data, delete_data_content_windows,
	erase_data_content>: Now private.
2019-08-20 16:45:50 -06:00
Tom Tromey 072272ce05 Remove some defines from tui-data.h
This removes the HILITE and NO_HILITE defines from tui-data.h, in
favor of simply passing a bool to box_win.

2019-08-20  Tom Tromey  <tom@tromey.com>

	* tui/tui-wingeneral.c (box_win): Change type of highlight_flag.
	(tui_unhighlight_win, tui_highlight_win)
	(tui_win_info::make_window): Update.
	* tui/tui-data.h (HILITE, NO_HILITE): Remove.
2019-08-20 16:45:50 -06:00
Tom Tromey 973961bda3 Move some defines to tui-stack.c
Some #defines in tui-data.h are only used in tui-stack.c, so move them
there.

2019-08-20  Tom Tromey  <tom@tromey.com>

	* tui/tui-data.h (PROC_PREFIX, LINE_PREFIX, PC_PREFIX)
	(MIN_LINE_WIDTH, MIN_PROC_WIDTH, MAX_TARGET_WIDTH)
	(MAX_PID_WIDTH): Move to tui-stack.c.
	* tui/tui-stack.c (PROC_PREFIX, LINE_PREFIX, PC_PREFIX)
	(MIN_LINE_WIDTH, MIN_PROC_WIDTH, MAX_TARGET_WIDTH)
	(MAX_PID_WIDTH): Move from tui-data.h.
2019-08-20 16:45:50 -06:00
Tom Tromey ab0e1f1a45 Change tui_make_window to be a method
I combined several small changes into one patch here.  I believe I
started by noticing that the "title" is not needed by tui_gen_win_info
and could be self-managing (i.e. std::string).  Moving this revealed
that "can_box" is also a property of tui_win_info and not
tui_gen_win_info; and this in turn caused the changes to
tui_make_window and box_win.

2019-08-20  Tom Tromey  <tom@tromey.com>

	* tui/tui-wingeneral.h (tui_make_window): Don't declare.
	* tui/tui-wingeneral.c (box_win): Change type of win_info.
	(box_win): Update.
	(tui_gen_win_info::make_window): Rename from tui_make_window.
	(tui_win_info::make_window): New method.
	(tui_gen_win_info::make_visible): Update.
	* tui/tui-source.c (tui_source_window::set_contents): Update.
	* tui/tui-regs.c (tui_data_window::show_register_group): Update.
	(tui_data_window::display_registers_from): Update.
	* tui/tui-layout.c (tui_gen_win_info::resize): Update.
	* tui/tui-data.h (struct tui_gen_win_info) <make_window>:
	Declare.
	<can_box>: Remove.
	<title>: Remove.
	(struct tui_win_info) <make_window>: Declare.
	<can_box>: Now virtual.
	<title>: New member.
	* tui/tui-data.c (~tui_gen_win_info): Don't free title.
	* tui/tui-command.c (tui_cmd_window::resize): Update.
2019-08-20 16:45:50 -06:00
Tom Tromey 100c2bf31f Remove tui_data_window::display_regs
There's no need for tui_data_window::display_regs any more (if there
ever was).  All the paths through data window construction will end up
setting this to true.  This patch removes the member.

2019-08-20  Tom Tromey  <tom@tromey.com>

	* tui/tui-regs.h (struct tui_data_window) <display_regs>: Remove.
	* tui/tui-regs.c (tui_data_window::show_registers): Update.
	(tui_data_window::check_register_values): Update.
2019-08-20 16:45:50 -06:00
Tom Tromey fa4dc567ae Remove indirection from tui_data_window::regs_content
tui_data_window::regs_content is currently a vector of unique_ptr.
However, due to the way this is managed now, there is no need to keep
the pointers -- it can simply be a vector of the objects themselves.
This patch removes this extra layer of indirection.

2019-08-20  Tom Tromey  <tom@tromey.com>

	* tui/tui-regs.h (struct tui_data_window): Use
	DISABLE_COPY_AND_ASSIGN.
	<regs_content>: Change type, removing unique_ptr.
	<tui_data_window>: Add move constructor.
	* tui/tui-regs.c (tui_data_window::show_registers)
	(tui_data_window::show_register_group)
	(tui_data_window::display_registers_from)
	(tui_data_window::display_registers_from)
	(tui_data_window::first_data_item_displayed)
	(tui_data_window::delete_data_content_windows)
	(tui_data_window::rerender, tui_data_window::refresh_window)
	(tui_data_window::check_register_values): Update.
2019-08-20 16:45:50 -06:00
Tom Tromey ca02d7c800 Add two methods to tui_data_window
This changes tui_show_registers and tui_show_register_group to be
methods on tui_data_window.

2019-08-20  Tom Tromey  <tom@tromey.com>

	* tui/tui-regs.h (struct tui_data_window) <show_registers,
	show_register_group>: Declare.
	(tui_show_register_group): Don't declare.
	* tui/tui-regs.c (tui_data_window::show_registers): Rename from
	tui_show_registers.
	(tui_data_window::show_register_group): Rename from
	tui_show_register_group.
	(tui_data_window::check_register_values, tui_reg_command):
	Update.
	* tui/tui-layout.c (tui_set_layout): Update.
2019-08-20 16:45:50 -06:00
Tom Tromey 63356bfda1 Change tui_check_register_values to be a method
This changes tui_check_register_values to be a method on
tui_data_window.  An additional check in tui_register_changed is
needed, because TUI_DATA_WIN could be NULL at this point.

2019-08-20  Tom Tromey  <tom@tromey.com>

	* tui/tui-regs.h (struct tui_data_window) <check_register_values>:
	Declare.
	(tui_check_register_values): Don't declare.
	* tui/tui-regs.c (tui_data_window::check_register_values): Rename
	from tui_check_register_values.
	* tui/tui-hooks.c (tui_register_changed): Update.
2019-08-20 16:45:50 -06:00
Tom Tromey 42cc14a753 Rearrange tui-regs.c some more
This moves tui_reg_layout later in tui-regs.c, closer to where it is
used.

It also changes tui_show_registers not to enable the TUI or change the
layout -- this is already done by this point by all the callers.

2019-08-20  Tom Tromey  <tom@tromey.com>

	* tui/tui-regs.c (tui_reg_layout): Move later.
	(tui_show_registers): Don't enable TUI mode or change layout.
2019-08-20 16:45:50 -06:00
Tom Tromey b9ad36868f Change tui_data_item_window::content to be a unique_xmalloc_ptr
This changes tui_data_item_window::content to be a unique_xmalloc_ptr
and fixes up the fallout.  It also removes a parameter from
tui_expand_tabs, as it was only ever given one value.

This also removes some tab-handling code from
tui_data_window::display_registers_from.  Because the content can only
be set by tui_register_format, and because that calls tui_expand_tabs,
it's not possible to see a tab here.

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

	* tui/tui-regs.h (struct tui_data_item_window)
	<~tui_data_item_window>: Remove.
	<content>: Now a unique_xmalloc_ptr.
	* tui/tui-regs.c (tui_register_format): Return a
	unique_xmalloc_ptr.
	(tui_get_register): Update.
	(~tui_data_item_window): Remove.
	(tui_data_window::display_registers_from, tui_display_register):
	Update.
	* tui/tui-io.h (tui_expand_tabs): Update.
	* tui/tui-io.c (tui_expand_tabs): Return a unique_xmalloc_ptr.
	Remove "col" parameter.
2019-08-20 16:45:50 -06:00
Tom Tromey 8e114aab8b Remove tui_data_item_window::value
The field tui_data_item_window::value is not used, so remove it.

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

	* tui/tui-regs.h (struct tui_data_item_window) <value>: Remove
	field.
	* tui/tui-regs.c (~tui_data_item_window): Update.
2019-08-20 16:22:05 -06:00
Tom Tromey 1a4f81dd7e Minor rearrangement in tui-regs.c
This moves a couple of functions earlier in tui-regs.c.  Previously
they were in the "command" section of the file, but really they belong
in the "window implementation" section.

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

	* tui/tui-regs.c (tui_register_format, tui_get_register): Move
	earlier.
2019-08-20 16:22:05 -06:00
Tom Tromey 0f8d8876d9 Remove NULL check from tui_reg_command
tui_reg_command has an unnecessary NULL check.  The preceding call to
tui_reg_layout will ensure the window exists.  This patch removes the
check.

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

	* tui/tui-regs.c (tui_reg_command): Remove NULL check.
2019-08-20 16:22:04 -06:00
Tom Tromey 605dc2c21d Some i18n fixes for the TUI
The TUI has a few #defines that hold user-visible strings.  As these
are only used in a single spot, this patch removes the defines,
preferring direct use of the string where needed.  Furthermore, now
the strings are wrapped in _(), which is friendlier for i18n purposes.

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

	* tui/tui-source.h (struct tui_source_window): Update.
	* tui/tui-regs.c (tui_show_registers): Update.
	* tui/tui-disasm.h (struct tui_disasm_window): Update.
	* tui/tui-data.h (NO_SRC_STRING, NO_DISASSEM_STRING)
	(NO_REGS_STRING): Remove defines.
2019-08-20 16:22:03 -06:00
Tom de Vries d7a11d1383 [gdb/testsuite] Clean up stale exec in gdb_compile_pascal
When running a pascal test with the stabs target board:
...
$ test=gdb.pascal/case-insensitive-symbols.exp
$ cd build/gdb/testsuite
$ make check RUNTESTFLAGS="$test --target_board=stabs"
...
we get:
...
nr of untested testcases         1
nr of unsupported tests          1
...
due to:
...
Error: Illegal parameter: -gstabs+^M
Error: /usr/bin/ppcx64 returned an error exitcode^M
...

OTOH, when running the same pascal test without the stabs target board:
...
$ make check RUNTESTFLAGS="$test"
...
we get:
...
nr of expected passes            20
...

But when subsequently again running with the stabs target board:
...
$ make check RUNTESTFLAGS="$test --target_board=stabs"
...
we now get:
...
nr of expected passes            20
...

The problem is that gdb_compile_pascal determines success based on existence
of the exec after compilation:
...
    if ![file exists $destfile] {
        unsupported "Pascal compilation failed: $result"
        return "Pascal compilation failed."
    }
...
without removing the exec before compilation, which allows a stale exec to
make it seem as if compilation has succeeded.

Fix this by removing the stale exec before compilation.

gdb/testsuite/ChangeLog:

2019-08-20  Tom de Vries  <tdevries@suse.de>

	* lib/pascal.exp (gdb_compile_pascal): Remove $destfile before
	compilation.
2019-08-20 17:18:09 +02:00
Conrad Meyer aedbe3bb9f Improve remote attach round-trips without btrace
For remotes which do not support btrace at all, we can save several
round trips for each thread.  This is especially significant when your
remote is a kernel with 100s or 1000s of threads and latency is
intercontinental.

Previously, with target, remote, and infrun debugging enabled, one
might see:

    Sending packet: $Hg18aee#43...Ack
    Packet received: OK
    Sending packet: $Hg186f7#eb...Ack
    Packet received: OK
    remote:target_xfer_partial (24, , 0x805454000, 0x0, 0x0, 4096) = -1, 0

repeated for all non-exited threads.

Afterwards, if the remote does not specify 'qXfer:btrace-conf:read+'
in qSupported stub features, these unnecessary thread switches are
avoided.

gdb/ChangeLog:

	* remote.c (remote_target::remote_btrace_maybe_reopen): Avoid
	unnecessary thread walk if remote doesn't support the packet.
2019-08-20 15:06:37 +01:00
Tom Tromey 7ce8f214f1 Fix indentation in value_has_field
value_has_field had a mis-indented line.  This fixes it.

gdb/ChangeLog
2019-08-19  Tom Tromey  <tromey@adacore.com>

	* python/py-value.c (value_has_field): Fix indentation.
2019-08-19 12:46:03 -06:00
Tom Tromey f21c2bd7b7 Fix Fortran regression with variables in nested functions
Sergio pointed out that commit commit aa3b6533 ("Allow nested function
displays") regressed a few gdb.fortran tests.  I was able to reproduce
these failures with gcc head.

The bug is that some spots calling contained_in will in fact do the
wrong thing if nested functions are considered as contained.  In the
particular case of the Fortran regression, it was the call in
block_innermost_frame, being called from get_hosting_frame -- in this
case, the caller is specifically trying to avoid the nested case.

This patch fixes the problem by adding an "allow_nested" parameter to
contained_in, essentially reverting the change for most callers.

gdb/ChangeLog
2019-08-19  Tom Tromey  <tromey@adacore.com>

	* printcmd.c (do_one_display, info_display_command): Update.
	* block.h (contained_in): Return bool.  Add allow_nested
	parameter.
	* block.c (contained_in): Return bool.  Add allow_nested
	parameter.
2019-08-19 10:32:03 -06:00
Tom Tromey d806ea2d0e Add Rust support to source highlighting
Currently, no release of GNU Source Highlight supports Rust.  However,
I've checked in a patch to do so there, and I plan to make a new
release sometime this summer.

This patch prepares gdb for that by adding support for Rust to the
source highlighting code.

Because Source Highlight will throw an exception if the language is
unrecognized, this also changes gdb to ignore exceptions here.  This
will cause gdb to fall back to un-highlighted source text.

This updates gdb's configure script to reject the combination of
Source Highlight and -static-libstdc++.  This is done because it's not
possible to use -static-libstdc++ and then catch exceptions from a
shared library.

Tested with the current and development versions of Source Highlight.

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

	* configure: Rebuild.
	* configure.ac: Disallow the combination of -static-libstdc++ and
	source highlight.
	* source-cache.c (get_language_name): Handle rust.
	(source_cache::get_source_lines): Ignore highlighting exceptions.
2019-08-19 10:17:27 -06:00
Tom de Vries 34dafe9f39 [gdb/testsuite] Fix compare-sections.exp with -fPIE/-pie
When running gdb.base/compare-sections.exp with target board -fPIE/-pie, we
get:
...
FAIL: gdb.base/compare-sections.exp: after run to main: compare-sections -r
...

The test expects the read-only sections to have the same contents as in the
file:
...
    # Assume startup code doesn't change read-only sections.
    compare_sections "-r"
...
but that's not the case for PIE executables.

Fix this by allowing mismatched read-only sections for PIE executables.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-08-16  Tom de Vries  <tdevries@suse.de>

	* gdb.base/compare-sections.exp ("after run to main"): Allow
	mismatched read-only sections for PIE executables.
2019-08-16 23:48:28 +02:00
Tom Tromey 398fdd6086 Remove the TUI execution info window
The TUI execution info window is unusual in that it is always linked
to a source or disassembly window.  Even updates of its content are
handled by the source window, so it really has no life of its own.

This patch removes this window entirely and puts its functionality
directly into the source window.  This simplifies the code somewhat.

This is a user-visible change, because now the box around the source
(or disassembly) window encloses the execution info as well.  I
consider this an improvement as well, though.

Note that this patch caused ncurses to start emitting the "CSI Z"
sequence, so I've added this to the test suite terminal
implementation.

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

	* tui/tui.h (enum tui_win_type) <EXEC_INFO_WIN>: Remove.
	* tui/tui-winsource.h (struct tui_exec_info_window): Remove.
	(struct tui_source_window_base) <make_visible, refresh_window,
	resize>: Remove methods.
	<execution_info>: Remove field.
	* tui/tui-winsource.c (tui_source_window_base::do_erase_source_content)
	(tui_show_source_line, tui_source_window_base)
	(~tui_source_window_base): Update.
	(tui_source_window_base::resize)
	(tui_source_window_base::make_visible)
	(tui_source_window_base::refresh_window): Remove.
	(tui_source_window_base::update_exec_info): Update.
	* tui/tui-source.c (tui_source_window::set_contents): Update.
	* tui/tui-disasm.c (tui_disasm_window::set_contents): Update.

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

	* lib/tuiterm.exp (_csi_Z): New proc.
	* gdb.tui/basic.exp: Update window positions.
	* gdb.tui/empty.exp: Update window positions.
2019-08-16 14:17:36 -06:00
Tom Tromey e699d33164 Remove useless assignment from tui_remove_hooks
tui_remove_hooks clears deprecated_query_hook, but nothing in the TUI
ever sets it; so remove the assignment.

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

	* tui/tui-hooks.c (tui_remove_hooks): Don't set
	deprecated_query_hook.
2019-08-16 11:28:34 -06:00
Tom Tromey bb01dbfc04 Change tui_show_symtab_source to be a method
This changes tui_show_symtab_source to be a method on
tui_source_window.

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

	* tui/tui-winsource.c (tui_update_source_windows_with_addr)
	(tui_update_source_windows_with_line): Update.
	* tui/tui-source.h (struct tui_source_window)
	<show_symtab_source>: Declare.
	(tui_show_symtab_source): Don't declare.
	* tui/tui-source.c (tui_show_symtab_source): Rename from
	tui_show_symtab_source.
2019-08-16 11:28:34 -06:00
Tom Tromey 81c82c4b90 Introduce tui_source_window_base::set_contents method
This introduces the tui_source_window_base::set_contents method and
implements it in the subclasses.  This removes a check of the window
type.

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

	* tui/tui-winsource.h (struct tui_source_window_base)
	<set_contents>: Declare.
	* tui/tui-winsource.c
	(tui_source_window_base::update_source_window_as_is): Update.
	* tui/tui-source.h (struct tui_source_window) <set_contents>:
	Declare.
	(tui_set_source_content): Don't declare.
	* tui/tui-source.c (tui_source_window::set_contents): Rename from
	tui_set_source_content.
	* tui/tui-disasm.h (struct tui_disasm_window) <set_contents>:
	Declare.
	(tui_set_disassem_content): Don't declare.
	* tui/tui-disasm.c (tui_disasm_window::set_contents): Rename from
	tui_set_disassem_content.
2019-08-16 11:28:34 -06:00
Tom Tromey 2ddaf61443 Change tui_update_breakpoint_info to be a method
This changes tui_update_breakpoint_info to be a method on
tui_source_window_base.

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

	* tui/tui-winsource.h (struct tui_source_window_base)
	<update_breakpoint_info>: Declare.
	(tui_update_breakpoint_info): Don't declare.
	* tui/tui-winsource.c (tui_source_window_base::update_source_window_as_is)
	(tui_update_all_breakpoint_info): Update.
	(tui_source_window_base::update_breakpoint_info): Rename from
	tui_update_breakpoint_info.
	(tui_source_window_base::update_exec_info): Update.
2019-08-16 11:28:34 -06:00
Tom Tromey 017f982820 Change tui_update_source_window to be a method
This changes tui_update_source_window to be a method on
tui_source_window_base.

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

	* tui/tui-winsource.h (struct tui_source_window_base)
	<update_source_window>: Declare.
	(tui_update_source_window): Don't declare.
	* tui/tui-winsource.c
	(tui_source_window_base::update_source_window): Rename from
	tui_update_source_window.
	(tui_source_window_base::rerender): Update.
	* tui/tui-source.c (tui_source_window::maybe_update): Update.
	* tui/tui-disasm.c (tui_show_disassem)
	(tui_show_disassem_and_update_source)
	(tui_disasm_window::maybe_update): Update.
2019-08-16 11:28:34 -06:00
Tom Tromey ed8358e949 Change tui_update_source_window_as_is to be a method
This changes tui_update_source_window_as_is to be a method on
tui_source_window_base.

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

	* tui/tui-winsource.h (struct tui_source_window_base)
	<update_source_window_as_is>: Declare.
	(tui_update_source_window_as_is): Don't declare.
	* tui/tui-winsource.c (tui_update_source_window): Update
	(tui_source_window_base::update_source_window_as_is): Rename from
	tui_update_source_window_as_is.
	(tui_source_window_base::refill): Update.
	* tui/tui-source.c (tui_show_symtab_source): Update.
	* tui/tui-disasm.c (tui_disasm_window::do_scroll_vertical):
	Update.
2019-08-16 11:28:34 -06:00
Tom Tromey 20149b6b20 Remove "noerror" parameter from some TUI functions
A few TUI functions take a "noerror" parameter.  This is only checked
in one spot: in tui_set_source_content, if noerror is false, and if an
error occurs, then the function will call print_sys_errmsg.

This seems misguided to me, so this patch removes that code and this
parameter.

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

	* tui/tui-winsource.h (tui_update_source_window)
	(tui_update_source_window_as_is): Remove "noerror" parameter.
	* tui/tui-winsource.c (tui_update_source_window)
	(tui_update_source_window_as_is): Remove "noerror" parameter.
	(tui_update_source_windows_with_addr)
	(tui_update_source_windows_with_line)
	(tui_source_window_base::rerender)
	(tui_source_window_base::refill): Update.
	* tui/tui-source.h (tui_set_source_content)
	(tui_show_symtab_source): Remove "noerror" parameter.
	* tui/tui-source.c (tui_set_source_content): Remove "noerror"
	parameter.
	(tui_show_symtab_source): Likewise.
	(tui_source_window::maybe_update): Update.
	* tui/tui-disasm.c (tui_show_disassem)
	(tui_show_disassem_and_update_source)
	(tui_disasm_window::do_scroll_vertical)
	(tui_disasm_window::maybe_update): Update.
2019-08-16 11:28:34 -06:00
Tom Tromey 2d83e710a1 Remove separate visibility flag
TUI windows keep track of their visibility in a boolean field.
However, this is not needed, because a window is visible if and only
if it has an underlying curses handle.  So, we can remove this
separate field.

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

	* tui/tui.c (tui_is_window_visible): Update.
	* tui/tui-wingeneral.c (tui_make_window)
	(tui_gen_win_info::make_visible, tui_refresh_all): Update.
	* tui/tui-win.c (window_name_completer, tui_refresh_all_win)
	(tui_set_focus_command, tui_all_windows_info, update_tab_width)
	(tui_set_win_height_command, parse_scrolling_args): Update.
	* tui/tui-source.c (tui_source_window::style_changed): Update.
	* tui/tui-regs.c (tui_show_registers)
	(tui_data_window::first_data_item_displayed)
	(tui_data_window::delete_data_content_windows)
	(tui_check_register_values, tui_reg_command): Update.
	* tui/tui-disasm.c (tui_show_disassem): Update.
	* tui/tui-data.h (struct tui_gen_win_info) <is_visible>: New
	method.
	<is_visible>: Remove field.
	* tui/tui-data.c (tui_next_win, tui_prev_win)
	(tui_delete_invisible_windows): Update.
2019-08-16 11:28:33 -06:00
Tom Tromey d4ab829a24 Remove m_has_locator
The previous patch removed the only use of m_has_locator, so this
member can now be removed.

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

	* tui/tui-winsource.h (struct tui_source_window_base)
	<m_has_locator>: Remove.
	* tui/tui-layout.c (show_source_disasm_command, show_data)
	(show_source_or_disasm_and_command): Update.
2019-08-16 11:28:33 -06: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
Sandra Loosemore d8f9e51c36 Fix paste-o in examine-backward.exp.
This patch fixes a paste-o that was introduced in commit
c8ad9b9a31.  Previously the regexp for
the "examine 3 bytes backward from ${address_zero}" test correctly
matched 3 "${byte}" patterns, but in that commit the 6-byte regexp
from the previous test was mistakenly repeated here instead.

2019-08-15  Sandra Loosemore  <sandra@codesourcery.com>

	gdb/testsuite/
	* gdb.base/examine-backward.exp: Correct regexp for
	"examine 3 bytes backward from ${address_zero}".
2019-08-15 18:15:16 -07:00
Tom de Vries 6eac171f06 [gdb] Make maint info sections print relocated addresses
When running gdb.base/compare-sections.exp with -fPIE/-pie, we get:
...
print /u *(unsigned char *) 0x00000238^M
Cannot access memory at address 0x238^M
(gdb) FAIL: gdb.base/compare-sections.exp: read-only: get value of read-only section
...

The problem is that that "maint info sections" prints an unrelocated address:
...
 [0]     0x00000238->0x00000254 at 0x00000238: .interp ALLOC LOAD READONLY \
                                                       DATA HAS_CONTENTS
...
while the test expects a relocated address.

Given that the documentation states that the command displays "the section
information displayed by info files", and that info files shows relocated
addresses:
...
        0x0000555555554238 - 0x0000555555554254 is .interp
...
fix this by showing relocated addresses for maint info sections as
well.

Build and tested on x86_64-linux.

gdb/ChangeLog:

2019-08-16  Tom de Vries  <tdevries@suse.de>

	* maint.c (maintenance_info_sections): Also handle !ALLOBJ case using
	print_objfile_section_info.
2019-08-16 00:25:14 +02:00
Tom Tromey 3df505f60e TUI resize unification
The TUI currently has two different ways to resize a window: the
resize method, and the methods make_invisible_and_set_new_height and
make_visible_with_new_height.

There's no deep reason to have two different ways to resize a window,
so this patch unifies them, leaving just the "resize" method.

This also changes the locator to be handled more like an ordinary
window and less like an adjunct of the associated source window.

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

	* tui/tui-io.c (tui_puts_internal): Check TUI_CMD_WIN before
	calling update_cmdwin_start_line.
	* tui/tui-winsource.h (struct tui_source_window_base)
	<do_make_visible_with_new_height, set_new_height>: Don't declare.
	<rerender>: Declare.
	* tui/tui-winsource.c (tui_source_window_base::update_tab_width):
	Call rerender.
	(tui_source_window_base::set_new_height): Remove.
	(tui_source_window_base::rerender): Rename from
	do_make_visible_with_new_height.
	* tui/tui-win.c (tui_resize_all, tui_adjust_win_heights): Use
	resize method.
	(tui_win_info::make_invisible_and_set_new_height)
	(tui_win_info::make_visible_with_new_height): Remove.
	* tui/tui-stack.h (struct tui_locator_window) <rerender>:
	Declare.
	* tui/tui-stack.c (tui_locator_window::rerender): New method.
	* tui/tui-regs.h (struct tui_data_window) <set_new_height,
	do_make_visible_with_new_height>: Don't declare.
	<rerender>: Declare.
	* tui/tui-regs.c (tui_data_window::rerender): Rename from
	set_new_height.
	(tui_data_window::do_make_visible_with_new_height): Remove.
	* tui/tui-layout.c (show_source_disasm_command, show_data): Don't
	call tui_show_locator_content.
	(tui_gen_win_info::resize): Call rerender.
	(show_source_or_disasm_and_command): Don't call
	tui_show_locator_content.
	* tui/tui-data.h (struct tui_gen_win_info) <rerender>: New
	method.
	(struct tui_win_info) <rerender>: Declare.
	<set_new_height, make_invisible_and_set_new_height,
	make_visible_with_new_height>: Don't declare.
	* tui/tui-data.c (tui_win_list::rerender): New method.
	* tui/tui-command.h (struct tui_cmd_window)
	<do_make_visible_with_new_height>: Don't declare.
	* tui/tui-command.c
	(tui_cmd_window::do_make_visible_with_new_height): Remove.

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

	* gdb.tui/empty.exp: Enable resizing tests.
2019-08-15 14:17:11 -06:00
Tom Tromey 272560b577 Fix bug with character enumeration literal
gnat encodes character enumeration literals using a few different
schemes.  The gnat compiler documented the "QU" and "QW" encodings,
but failed to document that a simpler encoding was used for certain
characters.

This patch updates gdb to handle this simple Q encoding.  Note that
wide character literals are still not handled.

gdb/ChangeLog
2019-08-15  Tom Tromey  <tromey@adacore.com>

	* ada-exp.y (convert_char_literal): Handle "Q%c" encoding.
	* ada-lang.c (ada_enum_name): Likewise.

gdb/testsuite/ChangeLog
2019-08-15  Tom Tromey  <tromey@adacore.com>

	* gdb.ada/char_enum.exp: Add regression tests.
	* gdb.ada/char_enum/foo.adb (Char_Enum_Type): Use '_'
	and '0'.
	(Char, Gchar): Update.
	* gdb.ada/char_enum/pck.ads (Global_Enum_Type): Use '+'.
2019-08-15 13:42:31 -06:00
Christian Biesinger 08235187bc Rename internal Python functions to start with an underscore
I could not tell if GdbSetPythonDirectory is internal or not because
I could not find any references to it, so I left it as-is.

Tested by running the testsuite on gdb.python/*.exp; everything still
passes.

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

	* python/lib/gdb/__init__.py (GdbOutputFile): Rename to have a
	leading underscore.
	(GdbOutputErrorFile): Likewise.
	(global scope): Adjust constructor calls to GdbOutput{,Error}File
	accordingly.
	(execute_unwinders): Rename to have a leading underscore.
	(auto_load_packages): Likewise.
	(global scope): Adjust call to auto_load_packages accordingly.
	(GdbSetPythonDirectory): Likewise.
	* python/py-unwind.c (pyuw_sniffer): Call _execute_unwinders
	instead of execute_unwinders.

gdb/testsuite/ChangeLog:

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

	* gdb.python/python.exp: Expect a leading underscore on
	GdbOutput{,Error}File.
2019-08-15 14:21:57 -05:00
Tom Tromey db502012fc TUI window resize should not need invisibility
When resizing a window, the TUI currently first makes it invisible,
then changes the size, and then restores its visibility.

I think this is done because curses doesn't truly support resizing a
window -- there is a "wresize" extension, but the man page says it
isn't available in all versions of curses.

First, this is probably not a major problem any more.  I imagine most
of those old systems are gone now.

Second, I think it's a better API to have this detail hidden inside of
the resize method.

This patch changes the code to follow this idea, and changes the
ordinary resize method to use wresize when it is available.  The
special case for the command window is also moved to methods on the
command window.

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

	* tui/tui-layout.c (show_layout, show_source_disasm_command)
	(show_data): Don't change window visibility.
	(tui_gen_win_info::resize): Remove special case for command
	window.  Use wresize, when available.
	(show_source_or_disasm_and_command): Don't change window
	visibility.
	* tui/tui-command.h (struct tui_cmd_window) <resize>: Declare.
	<make_visible>: New method.
	* tui/tui-command.c (tui_cmd_window::resize): New method.
2019-08-15 12:29:28 -06:00
Tom Tromey 3891b65efe Change TUI source window iteration
Currently the TUI does separate bookkeeping to track which source
windows exist.  It seems better to me to just refer to the list of
windows for this, so this patch removes the special handling and
instead adds a new iterator.

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

	* tui/tui-winsource.h (struct tui_source_window_iterator): New.
	(struct tui_source_windows): New.
	* tui/tui-winsource.c (tui_display_main): Update.
	* tui/tui-win.c (tui_resize_all, tui_adjust_win_heights)
	(new_height_ok, parse_scrolling_args): Update.
	* tui/tui-layout.c (show_layout, show_data): Update.
	* tui/tui-data.h (tui_source_windows, tui_clear_source_windows)
	(tui_add_to_source_windows): Don't declare.
	* tui/tui-data.c (source_windows, tui_source_windows)
	(tui_clear_source_windows, tui_add_to_source_windows): Remove.
2019-08-15 12:29:28 -06:00
Tom Tromey ee556432c4 Rename the "reset" method to "resize"
tui_gen_win_info::reset really just resizes the window.  This patch
renames it to reflect this.

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

	* tui/tui-winsource.h (struct tui_source_window_base) <resize>:
	Rename from reset.
	* tui/tui-winsource.c (tui_source_window_base::resize): Rename.
	* tui/tui-layout.c (show_source_disasm_command, show_data):
	Update.
	(tui_gen_win_info::resize): Rename.
	(show_source_or_disasm_and_command): Update.
	* tui/tui-data.h (struct tui_gen_win_info) <resize>: Rename from
	reset.
2019-08-15 12:29:28 -06:00
Tom Tromey 46f438e3d5 Remove tui_initialize_static_data
tui_initialize_static_data is not needed, because locator moving and
resizing is already handled in the layout code.

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

	* tui/tui-stack.c (tui_initialize_static_data): Remove.
	* tui/tui-interp.c (tui_interp::init): Don't call
	tui_initialize_static_data.
	* tui/tui-data.h (tui_initialize_static_data): Don't declare.
2019-08-15 12:29:28 -06:00
Tom Tromey f4ce562c7f Minor simplification in tui_default_win_viewport_height
tui_default_win_viewport_height doesn't need to look at tui_win_list;
it can simply check the type directly.

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

	* tui/tui-layout.c (tui_default_win_viewport_height): Don't
	examine tui_win_list.
2019-08-15 12:29:28 -06:00
Tom Tromey c398c3d0b5 Remove tui_clear_source_content
tui_clear_source_content is not needed.  Instead, the callers can call
erase_source_content, which is also changed to clear the content
vector.

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

	* tui/tui-winsource.h (tui_clear_source_content): Don't declare.
	* tui/tui-winsource.c (tui_update_source_window_as_is): Don't call
	tui_clear_source_content.
	(tui_clear_source_content): Remove.
	(tui_source_window_base::do_erase_source_content): Hoist call to
	content.clear().
	* tui/tui-stack.c (tui_show_frame_info): Don't call
	tui_clear_source_content.
2019-08-15 12:29:28 -06:00
Tom Tromey e25d200487 Turn tui_erase_source_content into a method
This changes tui_erase_source_content into a method on
tui_source_window_base.  The bulk of the work is moved into a helper
method, so that the callers can each pass the string appropriate to
the particular window class.

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

	* tui/tui-winsource.h (struct tui_source_window_base)
	<do_erase_source_content>: New method.
	<erase_source_content>: New method.
	(tui_erase_source_content): Don't declare.
	* tui/tui-winsource.c (tui_clear_source_content): Update.
	(tui_source_window_base::do_erase_source_content): Rename from
	tui_erase_source_content.
	(tui_source_window_base::show_source_content): Update.
	* tui/tui-win.c (tui_resize_all, tui_adjust_win_heights): Update.
	* tui/tui-source.h (struct tui_source_window)
	<erase_source_content>: New method.
	* tui/tui-disasm.h (struct tui_disasm_window)
	<erase_source_content>: New method.
2019-08-15 12:29:28 -06:00
Tom Tromey 002f15c277 Remove tui_alloc_source_buffer
There is no longer any need for tui_alloc_source_buffer.  The two
callers of this function immediately change the contents of the
window, undoing the work done by this function.

This required adding a move constructor to tui_source_element -- a
mildly surprising find, but without this, resizing the vector will
cause crashes.  This issue was masked earlier because
tui_alloc_source_buffer handled this.

Note that a patch for this bug was submitted here:

    https://sourceware.org/ml/gdb-patches/2019-08/msg00094.html

That patch is better, IMO, but the author as yet hasn't responded to a
request for a ChangeLog entry.

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

	* tui/tui-winsource.h (tui_alloc_source_buffer): Don't declare.
	(struct tui_source_element): Add DISABLE_COPY_AND_ASSIGN, and move
	constructor.
	* tui/tui-winsource.c (tui_alloc_source_buffer): Remove.
	* tui/tui-source.c (tui_set_source_content): Update.
	* tui/tui-disasm.c (tui_set_disassem_content): Update.
2019-08-15 12:29:28 -06:00
Tom Tromey c9033fe839 Change tui_line_is_displayed to be a method
This changes tui_line_is_displayed to be a method on
tui_source_window, now that it is obvious that it can only be called
for this type.

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

	* tui/tui-winsource.h (tui_line_is_displayed): Don't declare.
	* tui/tui-winsource.c (tui_line_is_displayed): Move to
	tui-source.c.
	* tui/tui-source.h (struct tui_source_window) <line_is_displayed>:
	Declare.
	* tui/tui-source.c (tui_source_window::line_is_displayed): New
	method.
	(tui_source_window::maybe_update): Update.
2019-08-15 12:29:28 -06:00
Tom Tromey 088f37dd90 Change tui_addr_is_displayed into a method
This changes tui_addr_is_displayed to be a method on
tui_disasm_window, now that it is obvious that it can only be called
for this type.

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

	* tui/tui-winsource.h (tui_addr_is_displayed): Don't declare.
	* tui/tui-winsource.c (tui_addr_is_displayed): Move to
	tui-disasm.c.
	* tui/tui-disasm.h (struct tui_disasm_window) <addr_is_displayed>:
	Declare.
	* tui/tui-disasm.c (tui_disasm_window::addr_is_displayed): New
	method.
	(tui_disasm_window::maybe_update): Update.
2019-08-15 12:29:28 -06:00
Tom Tromey a54700c6c4 Move contents of tui_show_frame_info to new method
This moves much of the body of tui_show_frame_info to a new method on
tui_source_window_base.  This removes a check for the type of a
window.

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

	* tui/tui-winsource.h (struct tui_source_window_base)
	<maybe_update>: Declare.
	* tui/tui-stack.c (tui_show_frame_info): Call maybe_update
	method.
	* tui/tui-source.h (struct tui_source_window) <maybe_update>:
	Declare.
	* tui/tui-source.c (tui_source_window::maybe_update): New method.
	* tui/tui-disasm.h (struct tui_disasm_window) <maybe_update>:
	Declare.
	* tui/tui-disasm.c (tui_disasm_window::maybe_update): New method.
2019-08-15 12:29:28 -06:00
Tom Tromey e2a678a557 Avoid string_file in tui_make_status_line
tui_make_status_line uses string_file where a simple std::string
constructor would do.  This makes this change.

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

	* tui/tui-stack.c (tui_make_status_line): Use string constructor.
2019-08-15 12:29:28 -06:00
Tom Tromey f2dda47784 Move locator code to tui-stack.c
The locator is mostly implemented in tui-stack.c.  This moves the
remaining bits to tui-stack.c and tui-stack.h, as appropriate.

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

	* tui/tui-wingeneral.c: Include tui-stack.h.
	* tui/tui-stack.h (MAX_LOCATOR_ELEMENT_LEN)
	(struct tui_locator_window): Move from tui-data.h.
	* tui/tui-stack.c (_locator, tui_locator_win_info_ptr)
	(tui_initialize_static_data): Move from tui-data.c.
	* tui/tui-data.h (MAX_LOCATOR_ELEMENT_LEN)
	(struct tui_locator_window): Move to tui-stack.c.
	* tui/tui-data.c (_locator, tui_locator_win_info_ptr)
	(tui_initialize_static_data): Move to tui-stack.c.
2019-08-15 12:29:28 -06:00
Tom Tromey ed4a1084d7 Remove FIXMEs from tui-layout.c
An earlier patch added a couple of FIXME comments to tui-layout.c.
This removes them.  This is possible due to the previous patch that
changed how boxing works in the TUI -- now, no special case for the
command window is needed in box_win.

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

	* tui/tui-layout.c (show_source_disasm_command)
	(show_source_or_disasm_and_command): Use make_visible method, not
	tui_make_window.
	* tui/tui-command.h (struct tui_cmd_window) <make_visible>:
	Remove.
2019-08-15 12:29:28 -06:00
Tom Tromey 65962b20b6 Simplify TUI boxing
In the TUI, whether or not a window can be boxed is a property of the
window's type.  This adds a can_box method to the window classes, and
changes tui_make_window to defer to this, removing the "box_it"
paramter.  This also lets us remove "enum tui_box", as it is no longer
used.

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

	* tui/tui-wingeneral.h (tui_make_window): Update.
	* tui/tui-wingeneral.c (tui_make_window): Remove "box_it"
	parameter.
	(tui_gen_win_info::make_visible): Update.
	* tui/tui-regs.c (tui_data_window::display_registers_from):
	Update.
	* tui/tui-layout.c (show_source_disasm_command)
	(show_source_or_disasm_and_command): Update.
	* tui/tui-data.h (struct tui_gen_win_info) <can_box>: New method.
	(enum tui_box): Remove.
	(struct tui_win_info) <can_box>: New method.
	* tui/tui-command.h (struct tui_cmd_window) <can_box>: New
	method.
2019-08-15 12:29:28 -06:00
Sandra Loosemore 22a2ab04f5 Disable dw2-dir-file-name.exp on remote and/or Windows host.
This test has many hardwired assumptions that pathnames on build and
host are the same, and that POSIX pathname syntax is used.  This
results in dozens of failures on a remote Windows host.  Fixing these
assumptions would involve nontrivial rewrites; meanwhile, let's make
the test results reflect the reality that this testcase isn't supported
on remote host.

2019-08-15  Sandra Loosemore  <sandra@codesourcery.com>

	gdb/testsuite/
	* gdb.dwarf2/dw2-dir-file-name.exp: Skip on remote or
	Windows host.
2019-08-15 10:41:58 -07:00
Sandra Loosemore 835b995b57 Skip batch-preserve-term-settings.exp tests that cannot work on Windows.
This group of tests assume that the gdb "shell" command launches a
POSIX-compliant shell supporting the PPID environment variable, which
is used to get gdb's pid for killing it from a remote_exec shell.  But
on Windows host "shell" launches cmd.exe, which doesn't have an
equivalent query.

2019-08-15  Sandra Loosemore  <sandra@codesourcery.com>

	gdb/testsuite/
	* gdb.base/batch-preserve-term-settings.exp
	(test_terminal_settings_preserved_after_sigterm): Skip on Windows.
2019-08-15 10:41:58 -07:00
Tom Tromey d59b55f095 Use gdb::byte_vector in target_write_memory
Pedro pointed out that target_write_memory should use gdb::byte_vector
rather than std::vector<unsigned char>.

gdb/gdbserver/ChangeLog
2019-08-15  Tom Tromey  <tromey@adacore.com>

	* target.c (target_write_memory): Use gdb::byte_vector.
2019-08-15 11:24:22 -06:00
Christian Biesinger 97dd8e07d9 [testsuite] Make the testsuite work on mingw
Dejagnu produces an objdir like /c/, but GDB expects something like c:/.
So fix it up in lib/gdb.exp.

gdb/testsuite/ChangeLog:

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

	* lib/gdb.exp: When running on a mingw target, replace
	/x/ with x:/.
2019-08-15 11:14:35 -05:00
Tom Tromey 4196ab2a6d Replace write_inferior_memory with target_write_memory
target_write_memory is just a simple wrapper for
write_inferior_memory.  Because target_write_memory is needed for
gdbsupport, and because gdb uses the name "target_write_memory"
everywhere, this patch renames write_inferior_memory and removes the
wrapper.  I think this brings gdb and gdbserver slightly more in sync.

gdb/gdbserver/ChangeLog
2019-08-15  Tom Tromey  <tromey@adacore.com>

	* tracepoint.c (write_inferior_data_pointer)
	(write_inferior_integer, write_inferior_int8)
	(write_inferior_uinteger, m_tracepoint_action_download)
	(r_tracepoint_action_download, x_tracepoint_action_download)
	(l_tracepoint_action_download, clear_inferior_trace_buffer)
	(download_agent_expr, download_tracepoint_1)
	(download_trace_state_variables, upload_fast_traceframes): Update.
	* server.c (gdb_write_memory): Update.
	* remote-utils.c (relocate_instruction): Update.
	* proc-service.c (ps_pdwrite): Update.
	* mem-break.c (remove_memory_breakpoint)
	(delete_fast_tracepoint_jump, set_fast_tracepoint_jump)
	(uninsert_fast_tracepoint_jumps_at)
	(reinsert_fast_tracepoint_jumps_at): Update.
	* linux-x86-low.c (append_insns)
	(i386_install_fast_tracepoint_jump_pad)
	(amd64_write_goto_address, i386_write_goto_address): Update.
	* linux-s390-low.c (append_insns, s390_write_goto_address):
	Update.
	* linux-ppc-low.c (ppc_relocate_instruction)
	(ppc_install_fast_tracepoint_jump_pad, emit_insns)
	(ppc_write_goto_address): Update.
	* linux-aarch64-low.c (append_insns): Update.
	* target.h (struct target_ops): Update.
	(write_inferior_memory): Don't declare.
	* target.c (target_write_memory): Rename from
	write_inferior_memory.  Remove old target_write_memory.
2019-08-15 07:42:21 -06:00
Tom Tromey c6778d00df Simplify write_inferior_memory
gdbserver's write_inferior_memory uses a static variable to avoid
memory leaks, and has a comment referring to the lack of cleanups.
This patch removes this comment and the code in favor of a
straightforward use of std::vector.

gdb/gdbserver/ChangeLog
2019-08-15  Tom Tromey  <tromey@adacore.com>

	* target.c (write_inferior_memory): Use std::vector.
2019-08-15 07:42:21 -06:00
Tom de Vries 2208ee9170 [gdb] Fix gdb build on mips64-linux
When compiling for mips64-linux, we get:
...
src/gdb/linux-nat-trad.c:139:12: error: ‘gdbarch_num_regs’ was not declared \
  in this scope
  139 |   regnum < gdbarch_num_regs (regcache->arch ());
...

Fix this by including gdbarch.h in linux-nat-trad.c, similar to commit
b1c896b365 "Fix gdb build on macOS".

Build on mips64-linux.

gdb/ChangeLog:

2019-08-15  Tom de Vries  <tdevries@suse.de>

	* linux-nat-trad.c: Include gdbarch.h.
2019-08-15 08:14:31 +02:00
Alan Hayward 75faf5c41d AArch64: Allow additional sizes in prologue
When saving registers to the stack at the start of a function, not all state
needs to be saved. For example, only the first 64bits of float registers need
saving.  However, a program may choose to store extra state if it wishes,
there is nothing preventing it doing so.

The aarch64_analyze_prologue will error if it detects extra state being
stored.  Relex this restriction.

Tested via aarch64-prologue test.

gdb/ChangeLog:

	* aarch64-tdep.c (aarch64_analyze_prologue): Allow any valid
	register sizes.

gdb/testsuite/ChangeLog:

	* gdb.arch/aarch64-prologue.c: New test.
	* gdb.arch/aarch64-prologue.exp: New file.
2019-08-14 15:58:21 +01:00
Tom Tromey b1c896b365 Fix gdb build on macOS
Internal testing showed that the macOS port did not build.  The
breakage was caused by the patch to remove the gdbarch.h include from
defs.h.  This patch fixes the problem.

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

	* darwin-nat.c: Include gdbarch.h.
	* darwin-nat-info.c: Include gdbarch.h.
2019-08-14 08:40:18 -06:00
Tom Tromey 6405cd73c0 Remove tui_gen_win_info::last_visible_line
The last_visible_line field of tui_gen_win_info is not used, so remove
it.

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

	* tui/tui-data.h (struct tui_gen_win_info) <last_visible_line>:
	Remove.
	* tui/tui-data.c (tui_initialize_static_data): Update.
2019-08-13 14:52:10 -06:00
Tom Tromey 5216580d7a Don't track the contents of the execution info window
The curses library keeps track of the contents of each window, and can
redraw the screen as needed.  This means that in most cases is no need
for the TUI windows to also keep track of their contents.  This patch
removes content tracking from the execution window, leaving that to
curses.

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

	* tui/tui-winsource.h (struct tui_exec_info_window)
	<~tui_exec_info_window, maybe_allocate_content, get_content,
	m_content>: Remove.
	(struct tui_source_window_base) <set_exec_info_content,
	show_exec_info_content>: Don't declare.
	* tui/tui-winsource.c
	(tui_exec_info_window::maybe_allocate_content): Remove.
	(tui_source_window_base::update_exec_info): Rename from
	set_exec_info_content.
	(tui_source_window_base::show_exec_info_content)
	(tui_source_window_base::update_exec_info): Remove.
2019-08-13 14:52:10 -06:00
Tom Tromey 93858ad34e Remove tui_clear_exec_info_content
After the previous patch, all calls to tui_clear_exec_info_content
come just after a call to tui_clear_source_content.  Because these two
windows are linked, I think it makes sense to have
tui_clear_source_content simply do the work.  So, this patch removes
tui_clear_exec_info_content.

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

	* tui/tui-winsource.h (tui_clear_exec_info_content): Don't
	declare.
	* tui/tui-winsource.c (tui_update_source_window_as_is)
	(tui_update_source_windows_with_addr, tui_erase_source_content):
	Update.
	(tui_clear_exec_info_content): Remove.
2019-08-13 14:52:10 -06:00
Tom Tromey e321e7ce75 Remove tui_erase_exec_info_content
One call to tui_erase_exec_info_content can be removed.  This call is
not needed because the function in question then immediately sets the
execution info window contents.

Once this is done, tui_clear_exec_info_content is just a wrapper for
the only call to tui_erase_exec_info_content, so
tui_erase_exec_info_content can be renamed and the wrapper function
removed.

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

	* tui/tui-winsource.h (tui_erase_exec_info_content): Don't
	declare.
	* tui/tui-winsource.c (tui_source_window_base::refresh_all): Don't
	call tui_erase_exec_info_content.
	(tui_clear_exec_info_content): Rename from
	tui_erase_exec_info_content.
	(tui_clear_exec_info_content): Delete.
2019-08-13 14:52:09 -06:00
Tom Tromey 8270ac6229 Turn tui_show_exec_info_content into a method
This changes tui_show_exec_info_content to be a method on
tui_source_window_base.  As it is only called by other methods on this
class, it can be private.

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

	* tui/tui-winsource.h (struct tui_source_window_base)
	<show_exec_info_content>: Declare.
	(tui_show_exec_info_content): Don't declare.
	* tui/tui-winsource.c
	(tui_source_window_base::show_exec_info_content): Rename from
	tui_show_exec_info_content.
	(tui_source_window_base::update_exec_info): Update.
2019-08-13 14:52:09 -06:00
Tom Tromey 7b56485db5 Move code to tui-winsource.h
This moves code related to the execution info window from tui-data.h
to tui-winsource.h.  It fits better here because the execution info is
conceptually part of the source and disassembly windows, and
tui-winsource.h is where this common class lives.

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

	* tui/tui-data.h (enum tui_bp_flag, tui_bp_flags, struct tui_source_element)
	(TUI_BP_HIT_POS, TUI_BP_BREAK_POS, TUI_EXEC_POS)
	(TUI_EXECINFO_SIZE, tui_exec_info_content): Move ...
	* tui/tui-winsource.h (enum tui_bp_flag, tui_bp_flags, struct
	tui_source_element, TUI_BP_HIT_POS, TUI_BP_BREAK_POS)
	(TUI_EXEC_POS, TUI_EXECINFO_SIZE, tui_exec_info_content):
	... here.
2019-08-13 14:52:09 -06:00
Tom Tromey 7ba913dcdf Change tui_update_exec_info to be a method
This changes tui_update_exec_info to be a method on
tui_source_window_base.

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

	* tui/tui-winsource.h (struct tui_source_window_base)
	<update_exec_info>: Declare.
	(tui_update_exec_info): Don't declare.
	* tui/tui-winsource.c (tui_update_source_window_as_is)
	(tui_source_window_base::refresh_all)
	(tui_update_all_breakpoint_info): Update.
	(tui_source_window_base::update_exec_info): Rename from
	tui_update_exec_info.
	* tui/tui-stack.c (tui_show_frame_info): Update.
2019-08-13 14:52:09 -06:00
Tom Tromey 37a4a13104 Change tui_set_exec_info_content to be a method
This changes tui_set_exec_info_content to bea method on
tui_source_window_base.

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

	* tui/tui-winsource.h (struct tui_source_window_base)
	<set_exec_info_content>: Declare.
	(tui_set_exec_info_content): Don't declare.
	* tui/tui-winsource.c
	(tui_source_window_base::set_exec_info_content): Rename from
	tui_set_exec_info_content.
	(tui_update_exec_info): Update.
2019-08-13 14:52:09 -06:00
Tom Tromey 0bd27e079a Change tui_show_source_content to be a method
This changes tui_show_source_content to be a method on
tui_source_window_base.

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

	* tui/tui-winsource.h (struct tui_source_window_base)
	<show_source_content>: Declare.
	(tui_show_source_content): Don't declare.
	* tui/tui-winsource.c (tui_update_source_window_as_is): Update.
	(tui_source_window_base::show_source_content): Rename from
	tui_show_source_content.
	(tui_source_window_base::refresh_all): Update.
	* tui/tui-layout.c (show_source_disasm_command)
	(show_source_or_disasm_and_command): Update.
2019-08-13 14:52:09 -06:00
Tom Tromey b4ef5aeb3a Change tui_check_and_display_highlight_if_needed to be a method
This changes tui_check_and_display_highlight_if_needed to be a method
on tui_win_info.  This makes it clear that the NULL check in that
function is not needed, so it is removed here.

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

	* tui/tui-winsource.c (tui_erase_source_content)
	(tui_show_source_content, tui_source_window_base::refresh_all):
	Update.
	* tui/tui-wingeneral.h
	(tui_check_and_display_highlight_if_needed): Don't declare.
	* tui/tui-wingeneral.c
	(tui_win_info::check_and_display_highlight_if_needed): Rename from
	check_and_display_highlight_if_needed.
	* tui/tui-win.c (tui_rehighlight_all)
	(tui_win_info::make_visible_with_new_height): Update.
	* tui/tui-regs.c (tui_data_window::display_registers_from_line)
	(tui_data_window::erase_data_content)
	(tui_data_window::display_all_data): Update.
	* tui/tui-data.h (struct tui_win_info)
	<check_and_display_highlight_if_needed>: Declare.
2019-08-13 14:52:09 -06:00
Tom Tromey fede52738f Delete invisible TUI windows
This changes the TUI so that when the layout changes, any windows that
are invisible are now deleted.  This makes it simpler to understand
window lifetimes.

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

	* tui/tui-win.c (tui_resize_all): Call
	tui_delete_invisible_windows.
	* tui/tui-layout.c (show_layout): Call
	tui_delete_invisible_windows.
	* tui/tui-data.h (tui_delete_invisible_windows): Declare.
	* tui/tui-data.c (tui_delete_invisible_windows): New function.
2019-08-13 14:52:09 -06:00
Tom Tromey 22c3f4909a Simplify tui_show_disassem
tui_show_disassem does not need to call tui_add_win_to_layout, because
the callers that could change the layout have already ensured that it
exists.

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

	* tui/tui-disasm.c (tui_show_disassem): Add assertion.  Don't call
	tui_add_win_to_layout.
2019-08-13 14:52:09 -06:00
Tom Tromey 16cb7910b9 Make tui_default_win_height static
tui_default_win_height is only used in tui-layout.c, so make it static.

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

	* tui/tui-layout.h (tui_default_win_height): Don't declare.
	* tui/tui-layout.c (tui_default_win_height): Now static.
2019-08-13 14:52:09 -06:00
Tom Tromey cc0c3ffbc9 Two simplifications in tui-layout.c
This patch simplifies some code in tui-layout.c.

In show_layout, all the layout settings can be handled by a single
switch statement.  In show_source_disasm_command and
show_source_or_disasm_and_command, there is no need to check the
current layout, as the caller has already done so.

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

	* tui/tui-layout.c (show_layout): Unify all layout cases into a
	single switch.
	(show_source_disasm_command, show_source_or_disasm_and_command):
	Don't check current layout.
2019-08-13 14:52:09 -06:00
Tom Tromey 3f3ffe54e2 Simplify tui_make_all_invisible
This simplifies the implementation of tui_make_all_invisible.  Also,
because show_data is only called by show_layout, this hoists the call
to tui_make_all_invisible and removes the call from show_data.

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

	* tui/tui-wingeneral.c (make_all_visible): Remove.
	(tui_make_all_invisible): Simplify.
	* tui/tui-layout.c (tui_make_all_invisible): Move from
	tui-wingeneral.c; simplify.
	(show_layout): Hoist call to tui_make_all_invisible.
	(show_data): Don't call tui_make_all_invisible.
2019-08-13 14:52:09 -06:00
Tom Tromey 6925809176 Remove tui_make_all_visible
The function tui_make_all_visible is not used, so remove it.

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

	* tui/tui-wingeneral.h (tui_make_all_visible): Don't declare.
	* tui/tui-wingeneral.c (tui_make_all_visible): Remove.
2019-08-13 14:52:09 -06:00
Tom Tromey 62cf57fee7 Move current_layout to tui-layout.c
This moves the current_layout global to tui-layout.c.  This allows for
the removal of an accessor function; but also it just seems clearer to
have it here.

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

	* tui/tui-layout.c (current_layout, tui_current_layout): Move from
	tui-data.c.
	(show_source_disasm_command, show_data)
	(show_source_or_disasm_and_command): Don't use
	tui_set_current_layout_to.
	* tui/tui-data.h (tui_set_current_layout_to): Don't declare.
	* tui/tui-data.c (current_layout, tui_current_layout): Move to
	tui-layout.c.
	(tui_set_current_layout_to): Remove.
2019-08-13 14:52:09 -06:00
Tom Tromey 2afade5dbe Remove struct tui_layout_def
"layout_def" isn't actually used in the TUI, so remove it.

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

	* tui/tui-layout.c (tui_set_layout): Update.
	* tui/tui-data.h (struct tui_layout_def): Remove.
	(tui_layout_def): Don't declare.
	* tui/tui-data.c (layout_def): Remove.
	(tui_layout_def): Remove.
2019-08-13 14:52:09 -06:00
Tom Tromey a3504e9654 clear_detail can only be called on TUI source windows
The clear_detail method can only be called on source windows, so
remove definitions from the base of the class hierarchy, leaving only
a single non-virtual method.

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

	* tui/tui-winsource.h (struct tui_source_window_base)
	<clear_detail>: No longer "override".
	* tui/tui-regs.h (struct tui_data_window) <clear_detail>: Remove.
	* tui/tui-regs.c (tui_data_window::clear_detail): Remove.
	* tui/tui-data.h (struct tui_win_info) <clear_detail>: Remove.
	* tui/tui-command.h (struct tui_cmd_window) <clear_detail>:
	Remove.
	* tui/tui-command.c (tui_cmd_window::clear_detail): Remove.
2019-08-13 14:52:09 -06:00
Tom Tromey 29c9291108 Don't include readline headers from tracepoint.c
I was curious why updating readline caused so much to be to rebuilt,
so I look at all the uses of the readline headers.  Most are included
for valid reasons (either readline directory or for tilde_expand); but
the includes in tracepoint.c didn't seem to be used.

This patch removes them.  Tested by rebuilding.

gdb/ChangeLog
2019-08-13  Tom Tromey  <tromey@adacore.com>

	* tracepoint.c: Don't include readline.h or history.h.
2019-08-13 12:28:38 -06:00
Tom de Vries abc6c00fb6 [gdb/testsuite] Fix gdb.gdb/selftest.exp regexp
With gdb.gdb/selftest.exp, we get:
...
(xgdb) PASS: gdb.gdb/selftest.exp: send SIGINT signal to child process
^M
Thread 1 "xgdb" received signal SIGINT, Interrupt.^M
0x00007ffff5bf01db in poll () from /lib64/libc.so.6^M
(gdb) FAIL: gdb.gdb/selftest.exp: send ^C to child process again
...

The failure is due to gdb printing 'Thread 1 "xgdb" received signal SIGINT',
but the regexp in the test-case expecting 'Program received signal SIGINT'.

Fix this by updating the regexp, similar to how that is done earlier in the
test-case.

gdb/testsuite/ChangeLog:

2019-08-13  Tom de Vries  <tdevries@suse.de>

	* gdb.gdb/selftest.exp (send ^C to child process again): Accept also
	Thread.
2019-08-13 18:57:50 +02:00
Sandra Loosemore 74c2c1f45f Fixes for gdb.python tests on remote Windows host.
This patch fixes several test ERRORs and FAILs seen from running
gdb.python tests on a remote Windows host.  The problems fixed
generally fall into these categories:
- Failure to copy the .py script to the host.
- Confusion between build and host pathnames.
- Assuming pathnames printed on the host include "/" as a directory
  separator.
- Tests that need to be conditionally disabled due to missing features
  on the host, etc.

2019-08-13  Sandra Loosemore  <sandra@codesourcery.com>

	gdb/testsuite/
	* gdb.python/py-completion.exp: Download the .py file to the host
	and use its host pathname.  Conditionalize tests that use
	tab completion and manipulate files on the build machine.
	* gdb.python/py-events.exp: Download the .py file to the host
	and use its host pathname.
	* gdb.python/py-evsignal.exp: Likewise.
	* gdb.python/py-evthreads.exp: Likewise.
	* gdb.python/py-framefilter-invalidarg.exp: Match Windows
	pathname syntax.
	* gdb.python/py-framefilter.exp: Download the .py file to the right
	place on the host.  Match Windows pathname syntax.
	* gdb.python/py-mi-var-info-path-expression.exp: Download the
	.py file to the host and use its host pathname.
	* gdb.python/py-objfile-script.exp: Match Windows pathname syntax.
	* gdb.python/py-objfile.exp: Expect a host pathname, not a
	build pathname.  Skip symlink test on Windows host.  Add missing
	newline at end of file.
	* gdb.python/py-pp-maint.exp: Download the .py file to the host
	and use its host pathname.
	* gdb.python/py-pp-registration.exp: Match Windows pathname syntax.
	* gdb.python/py-section-script.exp: Use host location of binfile
	on safe-path.  Use correct path separator on Windows host.
	Reorder alternatives in gdb_test_multiple to prevent matching
	the wrong alternative on success.
	* gdb.python/py-symtab.exp: Match Windows pathname syntax.
2019-08-13 09:09:30 -07: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
Tom Tromey 5db2718ce4 Remove readline hack from gdb_select
As discussed on gdb-patches, this removes the readline hack from the
mingw-hdep.c version of gdb_select.  It's believed that this is not
needed any more.  See:

    https://sourceware.org/ml/gdb-patches/2019-03/msg00465.html

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

	* mingw-hdep.c (gdb_select): Remove readline hack.
2019-08-12 10:57:56 -06:00
Patrick Palka ca2589f3bb Fix gdb's selftest.exp after readline import
After the sync there is one testsuite regression, the test
"signal SIGINT" in gdb.gdb/selftest.exp which now FAILs.  Previously,
the readline 6.2 SIGINT handler would temporarily reinstall the
underlying application's SIGINT handler and immediately re-raise SIGINT
so that the orginal handler gets invoked.  But now (since readline 6.3)
its SIGINT handler does not re-raise SIGINT or directly invoke the
original handler; it now sets a flag marking that SIGINT was raised, and
waits until readline explicitly has control to call the application's
SIGINT handler.  Anyway, because SIGINT is no longer re-raised from
within readline's SIGINT handler, doing "signal SIGINT" with a stopped
inferior gdb process will no longer resume and then immediately stop the
process (since there is no 2nd SIGINT to immediately catch).  Instead,
the inferior gdb process will now just print "Quit" and continue to run.
So with this commit, this particular test case is adjusted to reflect
this change in behavior (we now have to send a 2nd SIGINT manually to
stop it).

gdb/testsuite/ChangeLog
2019-08-12  Patrick Palka  <patrick@parcs.ath.cx>

	* gdb.gdb/selftest.exp (test_with_self): Update test to now
	expect the GDB inferior to no longer immediately stop after
	being resumed with "signal SIGINT".
2019-08-12 10:57:56 -06:00
Sandra Loosemore 020a839d52 Match Windows pathnames in gdb.linespec/break-ask.exp.
2019-08-09  Sandra Loosemore  <sandra@codesourcery.com>

	gdb/testsuite/
	* gdb.linespec/break-ask.exp: Generalize regexps to match
	Windows pathnames too.
2019-08-09 13:45:44 -07:00
Pedro Franco de Carvalho dac36daf78 Fix access to uninitialized variable in fill_in_stop_func
This patch changes find_pc_partial_function so that *block is set to
nullptr when it fails, so that fill_in_stop_func won't access an
uninitialized variable.

gdb/ChangeLog:
2019-08-09  Pedro Franco de Carvalho  <pedromfc@linux.ibm.com>

	* blockframe.c (find_pc_partial_function): Set *block to nullptr
	when the function fails.
2019-08-09 16:49:46 -03:00
Andreas Arnez 1022c627db s390: Implement 'type_align' gdbarch method
The align.exp test case yields many FAILs on s390x, since GDB's _Alignoff
doesn't always agree with the compiler's.  On s390x, the maximum alignment
is 8, but GDB returns an alignment of 16 for 16-byte data types such as
"long double".

This is fixed by implementing the type_align gdbarch method.  The new
method returns an alignment of 8 for all integer, floating-point, and
vector types larger than 8 bytes.  With this change, all align.exp tests
pass.

gdb/ChangeLog:

	* s390-tdep.c (s390_type_align): New function.
	(s390_gdbarch_init): Set it as type_align gdbarch method.
2019-08-09 20:27:03 +02:00
Alan Hayward 1ba7cdcd93 doc: fix PAC typo
gdb/doc/ChangeLog:

	* gdb.texinfo (AArch64 Pointer Authentication): Fix typo.
2019-08-09 10:32:24 +01:00
Tom de Vries eba4caf231 [gdb] Fix gdb.dwarf2/varval.exp with -fPIE/-pie
With target board unix/-fPIE/-pie, we get:
...
FAIL: gdb.dwarf2/varval.exp: print varval2
...

This is due comparing a get_frame_pc result (which includes the for PIE
non-zero relocation offset) with pc_high and pc_low obtained using
get_scope_pc_bounds (which do not include the relocation offset).

Fix this by adjusting pc_high and pc_low with the relocation offset.

Tested on x86_64-linux with target board unix/-fPIE/-pie.

gdb/ChangeLog:

2019-08-09  Tom de Vries  <tdevries@suse.de>

	PR gdb/24591
	* dwarf2read.c (dwarf2_fetch_die_loc_sect_off): Adjust pc_high and
	pc_low with relocation offset.
2019-08-09 06:49:04 +02:00
Tom de Vries 128d650981 [gdb/testsuite] Fix gdb.tui/basic.exp with check-read1
With gdb.tui/basic.exp and check-read1, we run into (using -v for
verbose log):
...
^[[0+++ _csi_0 <<<>>>
ERROR: (DejaGnu) proc "_csi_0" does not exist.
...

In contrast, without check-read1, we have:
...
^[[0;10m<SNIP>+++ _csi_m <<<0;10>>>
...

The problem is that this regexp in _accept:
...
           -re "^\x1b\\\[(\[0-9;\]*)(\[0-9a-zA-Z@\])" {
...
while matching the longer sequence '^[' '[' '0' ';' '1' '0' 'm', also matches
the shorter sequence '^[' '[' '0'.

The regexp attempts to match a CSI (Control Sequence Introducer) sequence, and
the final byte of such a sequence cannot be a digit.

Fix the regexp accordingly:
...
-           -re "^\x1b\\\[(\[0-9;\]*)(\[0-9a-zA-Z@\])" {
+           -re "^\x1b\\\[(\[0-9;\]*)(\[a-zA-Z@\])" {
...

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-08-08  Tom de Vries  <tdevries@suse.de>

	PR testsuite/24862
	* lib/tuiterm.exp (_accept): Fix CSI regexp.
2019-08-08 22:26:28 +02:00
Tom Tromey 123cd85148 Make struct frame_arg self-managing
This changes struct frame_arg to be self-managing and then fixes the
various users.

Tested by the buildbot.

gdb/ChangeLog
2019-08-07  Tom Tromey  <tromey@adacore.com>

	* stack.c (print_frame_arg, read_frame_local, read_frame_arg)
	(print_frame_args): Update.
	* python/py-framefilter.c (py_print_single_arg, enumerate_args):
	Update.
	* mi/mi-cmd-stack.c (list_arg_or_local): Update.
	* frame.h (struct frame_arg): Add initializers.
	<error>: Now a unique_xmalloc_ptr.
2019-08-07 06:37:21 -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
Tom Tromey 0cf9feb996 Introduce obstack_strndup
This introduces obstack_strndup and changes gdb to use it.

Note that obstack_strndup works like savestring, and not exactly like
xstrndup.  The difference is that obstack_strndup uses the passed-in
length, while xstrndup uses strnlen to choose the length.

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

	* stabsread.c (patch_block_stabs, read_one_struct_field)
	(read_enum_type): Use obstack_strndup.
	* rust-exp.y (rust_parser::copy_name): Use obstack_strndup.
	* gdb_obstack.h (obstack_strndup): Use obstack_strndup.
	* dwarf2read.c (guess_full_die_structure_name)
	(anonymous_struct_prefix): Use obstack_strndup.
	* dbxread.c (cp_set_block_scope): Use obstack_strndup.
	* c-exp.y (yylex): Use obstack_strndup.
	* ada-exp.y (write_object_renaming, write_ambiguous_var)
	(write_var_or_type): Use obstack_strndup.
2019-08-06 20:08:48 -06:00
Tom Tromey efba19b06a Add obstack_strdup overload taking a std::string
This adds an obstack_strdup overload that takes a std::string, and
changes a few spots in gdb to use it.

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

	* symfile.c (reread_symbols): Use obstack_strdup.
	* stabsread.c (read_type): Use obstack_strdup.
	* gdb_obstack.h (obstack_strdup): New overload.
	* dwarf2read.c (dwarf2_compute_name, create_dwo_unit_in_dwp_v1)
	(create_dwo_unit_in_dwp_v2, build_error_marker_type)
	(dwarf2_canonicalize_name): Use obstack_strdup.
	* dbxread.c (read_dbx_symtab): Use obstack_strdup.
	* cp-support.c (inspect_type, replace_typedefs_qualified_name):
	Use obstack_strdup.
2019-08-06 20:08:48 -06:00
Tom Tromey f25102f7b1 Make obstack_strdup inline
This changes obstack_strdup to be an inline function.  This seems
better to me, considering how small it is; but also it follows what
the code did before the previous patch.

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

	* gdb_obstack.h (obstack_strdup): Define.
	* gdb_obstack.c (obstack_strdup): Don't define.
2019-08-06 20:08:48 -06:00
Tom Tromey 021887d88a Use obstack_strdup more
This changes gdb to use obstack_strdup when appropriate, rather than
the wordier obstack_copy0.

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

	* xcoffread.c (SYMNAME_ALLOC, process_xcoff_symbol): Use
	obstack_strdup.
	* typeprint.c (typedef_hash_table::find_global_typedef): Use
	obstack_strdup.
	* symfile.c (allocate_compunit_symtab): Use obstack_strdup.
	* stabsread.c (common_block_start): Use obstack_strdup.
	* objfiles.c (set_objfile_main_name, objfile): Use
	obstack_strdup.
	* namespace.c (add_using_directive): Use obstack_strdup.
	* mdebugread.c (parse_symbol, parse_type): Use obstack_strdup.
	* jit.c (finalize_symtab): Use obstack_strdup.
	* dwarf2read.c (fixup_go_packaging, dwarf2_physname)
	(guess_partial_die_structure_name, partial_die_info::fixup)
	(dwarf2_name): Use obstack_strdup.
	* coffread.c (coff_read_struct_type, coff_read_enum_type): Use
	obstack_strdup.
	* c-exp.y (scan_macro_expansion): Use obstack_strdup.
	* buildsym.c (buildsym_compunit::end_symtab_with_blockvector): Use
	obstack_strdup.
	* ada-lang.c (ada_decode_symbol): Use obstack_strdup.
2019-08-06 20:08:48 -06:00
Philippe Waroquiers d2834edcb6 Add a selftest that checks documentation invariants.
Several approaches were discussed (mail or irc) to verify the invariants of
the GDB help documentation : checking with apropos ., modifying add_cmd
to do the check and output a warning, implement maintenance check-doc.

A selftest was finally chosen as:
  * this can be run on demand, including by users if they want
    to check user defined commands.
  * it does not interact with the normal behaviour of apropos, define,
    python, ...
    (such as output warnings when a user defines a command help that
     does not respect the doc).
  * when the selftest runs, it checks the user defined and python
    defined commands currently defined.

gdb/ChangeLog
	* unittests/help-doc-selftests.c: New file.
	* Makefile.in: Add the new file.
2019-08-07 00:05:34 +02:00
Philippe Waroquiers 590042fc45 Make first and last lines of 'command help documentation' consistent.
With this patch, the help docs now respect 2 invariants:
  * The first line of a command help is terminated by a '.' character.
  * The last character of a command help is not a newline character.

Note that the changes for the last invariant were done by Tom, as part of :
 [PATCH] Remove trailing newlines from help text
 https://sourceware.org/ml/gdb-patches/2019-06/msg00050.html
but some occurrences have been re-introduced since then.

Some help docs had to be rephrased/restructured to respect the above
invariants.

Before this patch, print_doc_line was printing the first line
of a command help documentation, but stopping at the first '.'
or ',' character.

This was giving inconsistent results :
  * The first line of command helps was sometimes '.' terminated,
    sometimes not.
  * The first line of command helps was not always designed to be
    readable/understandable/unambiguous when stopping at the first
    '.' or ',' character.

This e.g. created the following inconsistencies/problems:
< catch exception -- Catch Ada exceptions
< catch handlers -- Catch Ada exceptions
< catch syscall -- Catch system calls by their names
< down-silently -- Same as the `down' command
while the new help is:
> catch exception -- Catch Ada exceptions, when raised.
> catch handlers -- Catch Ada exceptions, when handled.
> catch syscall -- Catch system calls by their names, groups and/or numbers.
> down-silently -- Same as the `down' command, but does not print anything.

Also, the command help doc should not be terminated by a newline
character, but this was not respected by all commands.
The cli-option -OPT framework re-introduced some occurences.
So, the -OPT build help framework was changed to not output newlines at the
end of %OPTIONS% replacement.

This patch changes the help documentations to ensure the 2 invariants
given above.

It implied to slightly rephrase or restructure some help docs.

Based on the above invariants, print_doc_line (called by
'apropos' and 'help' commands to print the first line of a command
help) now outputs the full first line of a command help.

This all results in a lot of small changes in the produced help docs.
There are less code changes than changes in the help docs, as a lot
of docs are produced by some code (e.g. the remote packet usage settings).

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

	* cli/cli-decode.h (print_doc_line): Add for_value_prefix argument.
	* cli/cli-decode.c (print_doc_line): Likewise.  It now prints
	the full first line, except when FOR_VALUE_PREFIX.  In this case,
	the trailing '.' is not output, and the first character is uppercased.
	(print_help_for_command): Update call to print_doc_line.
	(print_doc_of_command): Likewise.
	* cli/cli-setshow.c (deprecated_show_value_hack): Likewise.
	* cli/cli-option.c (append_indented_doc): Do not append newline.
	(build_help_option): Append newline after first appended_indented_doc
	only if a second call is done.
	(build_help): Append 2 new lines before each option, except the first
	one.
	* compile/compile.c (_initialize_compile): Add new lines after
	%OPTIONS%, when not at the end of the help.
	Change help doc or code
	producing the help doc to respect the invariants.
	* maint-test-options.c (_initialize_maint_test_options): Likewise.
	Also removed the new line after 'Options:', as all other commands
	do not put an empty line between 'Options:' and the first option.
	* printcmd.c (_initialize_printcmd): Likewise.
	* stack.c (_initialize_stack): Likewise.
	* interps.c (interpreter_exec_cmd): Fix "Usage:" line that was
	incorrectly telling COMMAND is optional.
	* ada-lang.c (_initialize_ada_language): Change help doc or code
	producing the help doc to respect the invariants.
	* ada-tasks.c (_initialize_ada_tasks): Likewise.
	* breakpoint.c (_initialize_breakpoint): Likewise.
	* cli/cli-cmds.c (_initialize_cli_cmds): Likewise.
	* cli/cli-logging.c (_initialize_cli_logging): Likewise.
	* cli/cli-setshow.c (_initialize_cli_setshow): Likewise.
	* cli/cli-style.c (cli_style_option::add_setshow_commands,
	_initialize_cli_style): Likewise.
	* corelow.c (core_target_info): Likewise.
	* dwarf-index-cache.c (_initialize_index_cache): Likewise.
	* dwarf2read.c (_initialize_dwarf2_read): Likewise.
	* filesystem.c (_initialize_filesystem): Likewise.
	* frame.c (_initialize_frame): Likewise.
	* gnu-nat.c (add_task_commands): Likewise.
	* infcall.c (_initialize_infcall): Likewise.
	* infcmd.c (_initialize_infcmd): Likewise.
	* interps.c (_initialize_interpreter): Likewise.
	* language.c (_initialize_language): Likewise.
	* linux-fork.c (_initialize_linux_fork): Likewise.
	* maint-test-settings.c (_initialize_maint_test_settings): Likewise.
	* maint.c (_initialize_maint_cmds): Likewise.
	* memattr.c (_initialize_mem): Likewise.
	* printcmd.c (_initialize_printcmd): Likewise.
	* python/lib/gdb/function/strfns.py (_MemEq, _StrLen, _StrEq,
	_RegEx): Likewise.
	* ravenscar-thread.c (_initialize_ravenscar): Likewise.
	* record-btrace.c (_initialize_record_btrace): Likewise.
	* record-full.c (_initialize_record_full): Likewise.
	* record.c (_initialize_record): Likewise.
	* regcache-dump.c (_initialize_regcache_dump): Likewise.
	* regcache.c (_initialize_regcache): Likewise.
	* remote.c (add_packet_config_cmd, init_remote_threadtests,
	_initialize_remote): Likewise.
	* ser-tcp.c (_initialize_ser_tcp): Likewise.
	* serial.c (_initialize_serial): Likewise.
	* skip.c (_initialize_step_skip): Likewise.
	* source.c (_initialize_source): Likewise.
	* stack.c (_initialize_stack): Likewise.
	* symfile.c (_initialize_symfile): Likewise.
	* symtab.c (_initialize_symtab): Likewise.
	* target-descriptions.c (_initialize_target_descriptions): Likewise.
	* top.c (init_main): Likewise.
	* tracefile-tfile.c (tfile_target_info): Likewise.
	* tracepoint.c (_initialize_tracepoint): Likewise.
	* tui/tui-win.c (_initialize_tui_win): Likewise.
	* utils.c (add_internal_problem_command): Likewise.
	* valprint.c (value_print_option_defs): Likewise.

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

	* gdb.base/style.exp: Update tests for help doc new invariants.
	* gdb.base/help.exp: Likewise.
2019-08-07 00:04:33 +02:00
Frank Ch. Eigler 404f29021a [PR build/24886] disable glibc mcheck support
This patch drops gdb's configury support for glibc's mcheck function.
It has been observed to cause false abort()s, because it is
thread-unsafe yet interposes every malloc/free operation.  So if any
library transitively used by gdb also uses threads, then these
functions can easily corrupt their own checking data.  These days, gcc
ASAN and valgrind provide high quality checking, and mcheck is
apparently itself being slowly deprecated.

So, let's stop linking to it.  Attached patch drops the
autoconf/Makefile machinery for both gdb and gdbserver.  No
testsuite-visible impact.  IMHO not worth mentioning in NEWS.

See also: https://sourceware.org/bugzilla/show_bug.cgi?id=9939

gdb/ChangeLog

        PR build/24886
        * configure.ac: Drop enable-libmcheck support.
        * configure, config.in: Rebuild.
        * libmcheck.m4: Remove.
        * acinclude.m4: Don't include it.
        * Makefile.in: Don't distribute it.
        * top.c (print_gdb_configuration): Don't mention it.

gdb/gdbserver/ChangeLog

        PR build/24886
        * configure.ac: Drop enable-libmcheck support.
        * configure, config.in: Rebuild.
        * acinclude.m4: Don't include it.
2019-08-06 15:09:53 -04:00
Tom Tromey 046bebe1c0 Add more styling to "disassemble"
This adds more styling to the disassemble command.  In particular,
addresses and function names in the disassembly are now styled.

This required fixing a small latent bug in set_output_style.  This
function always passed NULL to emit_style_escape; but when writing to
a file other than gdb_stdout, it should emit the style escape
directly.  (FWIW this is another argument for better integrating the
pager with ui_file and getting rid of this entire layer.)

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

	* utils.c (set_output_style): Sometimes pass stream to
	emit_style_escape.
	* ui-out.h (class ui_out) <can_emit_style_escape>: Declare.
	* record-btrace.c (btrace_insn_history): Update.
	* mi/mi-out.h (class mi_ui_out) <can_emit_style_escape>: New
	method.
	* disasm.h (gdb_pretty_print_disassembler): Add uiout parameter.
	Update initializers.
	<m_uiout>: New field.
	<m_di>: Move lower.
	* disasm.c (gdb_pretty_print_disassembler::pretty_print_insn):
	Remove "uiout" parameter.
	(dump_insns): Update.
	* cli-out.h (class cli_ui_out) <can_emit_style_escape>: Declare.
	* cli-out.c (cli_ui_out::can_emit_style_escape): New method.

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

	* gdb.base/style.exp: Add disassemble test.
	* gdb.base/style.c (some_called_function): New function.
	(main): Use it.
2019-08-06 11:37:51 -06:00
Christian Biesinger ddbcedf5de Replace int with enum block_enum where appropriate.
For better readability and type safety.

gdb/ChangeLog:

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

	* symtab.c (symbol_cache_lookup): Change int to enum block_enum.
	(error_in_psymtab_expansion): Likewise.
	(lookup_symbol_via_quick_fns): Likewise.
	(basic_lookup_transparent_type_quick): Likewise.
	(basic_lookup_transparent_type_1): Likewise.
2019-08-06 11:50:52 -05:00
Tom Tromey b08b16c839 Clean up source file error reporting
print_source_lines_base reopens the source file every time that a
source line is to be printed.  However, there's no need to do this so
frequently -- it's enough to do it when switching source files, and
otherwise rely on the cache.

The code seems to try to avoid these multiple opens; at a guess I'd
say something just got confused along the way.

This patch fixes the problem by reorganizing the code both to make it
more clear, and to ensure that reopens only occur when the "last
source visited" changes.

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

	* source.c (last_source_error): Now bool.
	(print_source_lines_base): Make "noprint" bool.  Only open
	source file when last_source_visited changes.
2019-08-06 08:04:33 -06:00
Tom Tromey cb44333d99 Add file offsets to the source cache
Currently, gdb stores the number of lines and an array of file offsets
for the start of each line in struct symtab.  This patch moves this
information to the source cache.  This has two benefits.

First, it allows gdb to read a source file less frequently.
Currently, a source file may be read multiple times: once when
computing the file offsets, once when highlighting, and then pieces
may be read again while printing source lines.  With this change, the
file is read once for its source text and file offsets; and then
perhaps read again if it is evicted from the cache.

Second, if multiple symtabs cover the same source file, then this will
share the file offsets between them.  I'm not sure whether this
happens in practice.

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

	* annotate.c (annotate_source_line): Use g_source_cache.
	* source-cache.c (source_cache::get_plain_source_lines): Change
	parameters.  Populate m_offset_cache.
	(source_cache::ensure): New method.
	(source_cache::get_line_charpos): New method.
	(extract_lines): Move lower.  Change parameters.
	(source_cache::get_source_lines): Move lower.
	* source-cache.h (class source_cache): Update comment.
	<get_line_charpos>: New method.
	<get_source_lines>: Update comment.
	<clear>: Clear m_offset_cache.
	<get_plain_source_lines>: Change parameters.
	<ensure>: New method
	<m_offset_cache>: New member.
	* source.c (forget_cached_source_info_for_objfile): Update.
	(info_source_command): Use g_source_cache.
	(find_source_lines, open_source_file_with_line_charpos): Remove.
	(print_source_lines_base, search_command_helper): Use g_source_cache.
	* source.h (open_source_file_with_line_charpos): Don't declare.
	* symtab.h (struct symtab) <nlines, line_charpos>: Remove.
	* tui/tui-source.c (tui_source_window::do_scroll_vertical):
	Use g_source_cache.
2019-08-06 08:04:33 -06:00
Tom Tromey 872dceaaff Save plain text in the source cache
Currently the source cache will only store highlighted text.  However,
there's no reason it could not also store plain text, when styling is
turned off.

This patch makes this change.  This also simplifies the source cache
code somewhat.

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

	* source-cache.c (source_cache::get_plain_source_lines):
	Remove "first_line" and "last_line" parameters.
	(source_cache::get_source_lines): Cache plain text.
	* source-cache.h (class source_cache)
	<get_plain_source_lines>: Update.
2019-08-06 08:04:33 -06:00
Tom Tromey 269249d940 Fix latent bug in source cache
The source cache was not returning the final \n of the requested range
of lines.  This caused regressions with later patches in this series,
so this patch pre-emptively fixes the bug.

This adds a self-test of "extract_lines" to the source cache code.  To
make it simpler to test, I changed extract_lines to be a static
function, and changed it's API a bit.

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

	* source-cache.c (extract_lines): No longer a method.
	Changed type of parameter.  Include final newline.
	(selftests::extract_lines_test): New function.
	(_initialize_source_cache): Likewise.
	* source-cache.h (class source_cache)
	<extract_lines>: Don't declare.
2019-08-06 08:04:33 -06:00
Tom Tromey c0e8dcd871 Change breakpoint::filter to be a unique_xmalloc_ptr
This changes breakpoint::filter to be a unique_xmalloc_ptr, removing
an explicit xfree, as well as a use of a "release" method.

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

	* breakpoint.c (init_breakpoint_sal): Update.
	(breakpoint): Update.
	* breakpoint.h (struct breakpoint) <filter>: Now a
	unique_xmalloc_ptr.
2019-08-06 08:01:21 -06: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
Christian Biesinger 4ee94178af Add a comment briefly explaining partial symbols
Based on an explanation by tromey on IRC.

gdb/ChangeLog:

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

	* objfiles.h (objfile): Add a comment describing partial symbols.
2019-08-05 10:35:35 -05:00
Simon Marchi 580f1034d1 Increase timeout in gdb.mi/list-thread-groups-available.exp
Running

    make check-read1 TESTS="gdb.mi/list-thread-groups-available.exp"

on my machine results in timeout failures.  Running it while having
`tail -F testsuite/gdb.log` on the side shows that the test is never
really blocked, it is just slow at consuming the large output generated
by `-list-thread-groups --available` (which lists all the processes on
the system).

If I increase the timeout to a large value, the test passes in ~30
seconds (compared to under 1 second normally).

Increase the timeout for the particular mi_gdb_test that is long to
execute under read1.  The new timeout value is a bit arbitrary.  The
default timeout is 10 seconds, so I set the new timeout to be
"old-timeout * 10", so 100 seconds in the typical case.

gdb/testsuite/ChangeLog:

	PR gdb/24863
	* gdb.mi/list-thread-groups-available.exp: Increase timeout for
	-list-thread-groups --available test when running under
	check-read1.
2019-08-05 10:21:48 -04:00
Tom de Vries d86bd7cba1 [gdb/testsuite] Run read1 timeout tests with with_read1_timeout_factor
When running tests with check-read1, we run into some timeouts where the tests
are not easy to rewrite using gdb_test_sequence:
...
FAIL: gdb.base/help.exp: help data (timeout)
FAIL: gdb.base/help.exp: help files (timeout)
FAIL: gdb.base/help.exp: help internals (timeout)
FAIL: gdb.base/help.exp: help user-defined (timeout)
FAIL: gdb.base/help.exp: help breakpoint "b" abbreviation (timeout)
FAIL: gdb.base/help.exp: help breakpoint "br" abbreviation (timeout)
FAIL: gdb.base/help.exp: help breakpoint "bre" abbreviation (timeout)
FAIL: gdb.base/info-macros.exp: info macros 2 (timeout)
FAIL: gdb.base/info-macros.exp: next (timeout)
FAIL: gdb.base/info-macros.exp: info macros 3 (timeout)
FAIL: gdb.base/info-macros.exp: next (timeout)
FAIL: gdb.base/info-macros.exp: next (timeout)
FAIL: gdb.base/info-macros.exp: info macros (timeout)
FAIL: gdb.base/info-macros.exp: next (timeout)
FAIL: gdb.base/info-macros.exp: next (timeout)
FAIL: gdb.base/info-macros.exp: info macros 7 (timeout)
FAIL: gdb.cp/nested-types.exp: ptype S10 (limit = -1) // parse failed (timeout)
FAIL: gdb.cp/nested-types.exp: set print type nested-type-limit 1 (timeout)
...

Fix these by increasing the timeout by a factor 10.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-08-05  Tom de Vries  <tdevries@suse.de>

	PR testsuite/24863
	* lib/gdb.exp (with_read1_timeout_factor): New proc.
	* gdb.base/help.exp: Use with_read1_timeout_factor.
	* gdb.base/info-macros.exp: Same.
	* gdb.cp/nested-types.exp: Same.
2019-08-05 15:41:04 +02:00
Tom Tromey 8abfcabcb4 Use _() in calls to build_help
Currently some code in gdb uses build_help with N_(), like:

  static const std::string compile_print_help
    = gdb::option::build_help (N_("\

I believe this is incorrect.  The N_ macro is used to mark text that
should end up in the message catalog, but which will be translated by
a later call to gettext.

However, in this case, there is no later call to gettext, so (if gdb
had translations), this text would remain untranslated.

Instead, I think using the ordinary _() macro is correct here.
Translators will have to know to preserve "%OPTIONS%" in the text --
but that seems both unavoidable and fine.

Tested by rebuilding as there's not much else to do.

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

	* compile/compile.c (_initialize_compile): Use _(), not N_().
	* thread.c (_initialize_thread): Use _(), not N_().
	* stack.c (_initialize_stack): Use _(), not N_().
	* printcmd.c (_initialize_printcmd): Use _(), not N_().
2019-08-05 07:36:28 -06:00
Tom de Vries a80cf5d88e [gdb/testsuite] Fail in gdb_compile if pie results in non-PIE executable
When running gdb.base/break-idempotent.exp with
--target_board=unix/-fno-PIE/-no-pie, we get:
...
nr of expected passes            140
...

The test-case is compiled once with nopie and once with pie, but in both cases
we end up with a non-PIE executable.  The "-fno-PIE -no-pie" options specified
using the target_board are interpreted by dejagnu as multilib_flags, and end up
overriding the pie flags.

Fix this by checking in gdb_compile if the resulting exec is non-PIE despite of
a pie setting, and if so return an error:
...
Running gdb/testsuite/gdb.base/break-idempotent.exp ...
gdb compile failed, pie failed to generate PIE executable

                === gdb Summary ===

nr of expected passes            70
nr of untested testcases         1
...

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-08-05  Tom de Vries  <tdevries@suse.de>

	* lib/gdb.exp (version_at_least): Factor out of ...
	(tcl_version_at_least): ... here.
	(gdb_compile): Fail if pie results in non-PIE executable.
	(readelf_version, readelf_prints_pie): New proc.
	(exec_is_pie): Return -1 if unknown.
2019-08-05 12:51:58 +02:00
Tom de Vries d096283854 [gdb/testsuite] Fix typo in tcl_version_at_least
In tcl_version_at_least we compare a minor against a major version number:
...
    } elseif { $tcl_version_major == $major \
                  && $tcl_version_major >= $minor } {
...

Fix this by using $tcl_version_minor in the comparison instead.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-08-05  Tom de Vries  <tdevries@suse.de>

	* lib/gdb.exp (tcl_version_at_least): Fix typo.
2019-08-05 12:51:58 +02:00
Simon Marchi 2b79f3761c Remove some variables in favor of using gdb::optional
While reading that code, I noticed that some variables essentially meant
whether to consider some other variable or not.  I think using
gdb::optional (which was not available when this code was written) is
clearer, as it embeds the used/not used predicate directly in the type
of the variable, making it harder to miss.

gdb/ChangeLog:

	* dwarf2read.c (struct dw2_symtab_iterator):
	<want_specific_block>: Remove.
	<block_index>: Change type to gdb::optional.
	(dw2_symtab_iter_init): Remove WANT_SPECIFIC_BLOCK parameter,
	change type of BLOCK_INDEX parameter to gdb::optional.
	(dw2_symtab_iter_next): Re-write in function of gdb::optional.
	(dw2_lookup_symbol): Don't pass argument for
	WANT_SPECIFIC_BLOCK.
	(dw2_expand_symtabs_for_function): Don't pass argument for
	WANT_SPECIFIC_BLOCK, pass empty optional for BLOCK_INDEX.
	(class dw2_debug_names_iterator)
	<dw2_debug_names_iterator>: Remove WANT_SPECIFIC_BLOCK
	parameter, change BLOCK_INDEX type to gdb::optional.
	<m_want_specific_block>: Remove.
	<m_block_index>: Change type to gdb::optional.
	(dw2_debug_names_iterator::next): Change type of IS_STATIC to
	gdb::optional.  Re-write in function of gdb::optional.
	(dw2_debug_names_lookup_symbol): Don't pass argument for
	WANT_SPECIFIC_BLOCK.
	(dw2_debug_names_expand_symtabs_for_function): Don't pass
	argument for WANT_SPECIFIC_BLOCK, pass empty optional for
	BLOCK_INDEX.
2019-08-04 22:44:05 -04:00
Sandra Loosemore 2252ff3d90 Skip GDB test reconnect-ctrl-c.exp if nointerrupts is set.
2019-08-04  Sandra Loosemore  <sandra@codesourcery.com>

	gdb/testsuite/
	* gdb.server/reconnect-ctrl-c.exp: Skip if nointerrupts.
2019-08-04 14:34:31 -07:00
Sandra Loosemore 26655f5306 Add check for readline support to more GDB tab-completion tests.
2019-08-04  Sandra Loosemore  <sandra@codesourcery.com>

	gdb/testsuite/
	* lib/completion-support.exp (test_gdb_complete_none): Skip
	tab completion tests if no readline support.
	(test_gdb_complete_unique_re): Likewise.
	(test_gdb_complete_multiple): Likewise.
2019-08-04 14:26:39 -07: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
Philippe Waroquiers db4dc13eeb New test for 'info sources [-dirname | -basename] [--] [REGEXP]'.
This patch introduces a test for the 'info sources' command
and its new arguments [-dirname | -basename] [--] [REGEXP].

gdb/testsuite/ChangeLog

2019-08-03  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

	* gdb.base/info_sources.exp: New file.
	* gdb.base/info_sources.c: New file.
	* gdb.base/info_sources_base.c: New file.
2019-08-03 21:27:06 +02:00
Philippe Waroquiers 28cd9371e8 New "info sources" args [-dirname | -basename] [--] [REGEXP]
gdb/ChangeLog

2019-08-03  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

	* symtab.c (filename_partial_match_opts): New struct type.
	(struct output_source_filename_data): New members
	regexp, c_regexp, partial_match.
	(output_source_filename): Use new members to decide to print file.
	(info_sources_option_defs): New variable.
	(make_info_sources_options_def_group, print_info_sources_header,
	info_sources_command_completer):
	New functions.
	(info_sources_command): Read new optional arguments.
	(_initialize_symtab): Update info sources help.
2019-08-03 21:26:37 +02:00
Alexandre Oliva ca683e3a86 support Ada EH ABI v1
A new pair of hooks used by Ada exception handlers, for correct
release of reraised exception occurrences, involves the introduction
of new v1 symbols that GDB should use when available.  The older, v0
ABI remains available in newer runtimes for bootstrapping purposes
only.


for  gdb/ChangeLog

	* ada-lang.c (exception_support_info_v0): Renamed from...
	(default_exception_support_info): ... this.  Create new
	definition for v1.
	(ada_has_this_exception_support): Look up catch_handlers_sym.
	(ada_exception_support_info_sniffer): Try v0 after default.
2019-08-02 15:40:32 -03:00
Pedro Franco de Carvalho 0eba165a74 Remove directory names from gdb.base/batch-exit-status.exp
Adjust gdb.base/batch-exit-status.exp so that test prefixes don't show
directory names for the source scripts passed with -x, to make test
results from different build directories comparable.

gdb/testsuite/ChangeLog:
2019-08-01  Pedro Franco de Carvalho  <pedromfc@linux.ibm.com>

	* gdb.base/batch-exit-status.exp: Call test_exit_status with
	prefix argument.
	(test_exit_status): Add prefix argument.
2019-08-01 16:51:44 -03:00
Tom Tromey f126416240 Fix the ia64 libunwind build
This fixes the ia64 libunwind build.

gdb/ChangeLog
2019-08-01  Tom Tromey  <tromey@adacore.com>

	* ia64-libunwind-tdep.h (struct libunwind_descr): Include
	gdbarch.h.
2019-08-01 12:14:07 -06:00
Christian Biesinger 0a7b24850e Include s12z-opc.h using ../opcodes.
This file exists in binutils-gdb/opcodes, and nothing in Makefile.in adds this
to the include path.  Default builds work because in-tree readline adds
binutils-gdb/ to the include path (!). However, this is broken when compiling
with system readline.

Other files already use this way to include files in opcodes:
./gdb/lm32-tdep.c:#include "../opcodes/lm32-desc.h"
./gdb/or1k-tdep.h:#include "../opcodes/or1k-desc.h"
./gdb/mep-tdep.c:#include "../opcodes/mep-desc.h"

etc.

gdb/ChangeLog:

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

	* s12z-tdep.c: Fix include path for s12z-opc.h.
2019-08-01 12:40:49 -05: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
Tom de Vries 59bd512b9c [gdb/testsuite] Fix gdb.threads/fork-plus-threads.exp timeout with check-run1
With gdb.threads/fork-plus-threads.exp and check-run1 we get:
...
FAIL: gdb.threads/fork-plus-threads.exp: detach-on-fork=off: \
  inferior 1 exited (timeout)
...

Fix this by calling exp_continue for new thread and thread exited messages.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-08-01  Tom de Vries  <tdevries@suse.de>

	PR testsuite/24863
	* gdb.threads/fork-plus-threads.exp: Fix check-run1 timeout by
	calling exp_continue for new thread and thread exited messages.
2019-08-01 10:48:11 +02:00
Tom de Vries 2a3ad588e0 [gdb/testsuite] Fix gdb.base/structs.exp timeout with check-read1
With gdb.base/structs.exp and check-read1 we get:
...
FAIL: gdb.base/structs.exp: p chartest (timeout)
...

Fix this by using gdb_test_sequence.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-08-01  Tom de Vries  <tdevries@suse.de>

	PR testsuite/24863
	* gdb.base/structs.exp: Fix check-read1 timeout using
	gdb_test_sequence.
	* lib/gdb.exp (tcl_version_at_least, lrepeat): New proc.
2019-08-01 10:48:11 +02:00
Tom de Vries 117eb59422 [gdb/testsuite] Fix gdb.base/break-interp.exp timeout with check-read1
With gdb.base/break-interp.exp and check-read1, we run get:
...
FAIL: gdb.base/break-interp.exp: LDprelinkNOdebugNO: \
  BINprelinkNOdebugNOpieNO: symbol-less: info files (timeout)
FAIL: gdb.base/break-interp.exp: LDprelinkNOdebugNO: \
  BINprelinkNOdebugNOpieYES: symbol-less: info files (timeout)
FAIL: gdb.base/break-interp.exp: LDprelinkNOdebugIN: \
  BINprelinkNOdebugNOpieNO: symbol-less: info files (timeout)
FAIL: gdb.base/break-interp.exp: LDprelinkNOdebugIN: \
  BINprelinkNOdebugNOpieYES: symbol-less: info files (timeout)
...

Fix this by calling exp_continue after each "info files" line.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-08-01  Tom de Vries  <tdevries@suse.de>

	PR testsuite/24863
	* gdb.base/break-interp.exp: Use exp_continue after each "info files"
	line.
2019-08-01 10:48:11 +02:00
Tom de Vries ed5913402b [gdb/testsuite] Fix gdb.base/signals.exp timeout with check-read1
With gdb.base/signals.exp and check-read1 we get:
...
FAIL: gdb.base/signals.exp: info signals (timeout)
...

Fix this by using gdb_test_sequence.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-08-01  Tom de Vries  <tdevries@suse.de>

	PR testsuite/24863
	* gdb.base/signals.exp: Fix check-read1 timeout using gdb_test_sequence.
2019-08-01 10:48:11 +02:00
Tom Tromey a2bd7b82ee Don't declare tui_copy_win or tui_box_win
tui_copy_win and tui_box_win are not implemented, so don't declare
them.

gdb/ChangeLog
2019-07-16  Tom Tromey  <tom@tromey.com>

	* tui/tui-wingeneral.h (tui_copy_win, tui_box_win): Don't
	declare.
2019-07-30 16:19:59 -06:00
Tom Tromey aa3b653351 Allow nested function displays
In Ada, it's possible to have nested functions.  However,
block.c:contained_in does not recognize this.  Normally, this is no
problem, but if gdb is stopped inside a nested function, then you can
end up in the unexpected situation that "print" of an expression will
work, whereas "display" of the same expression will not -- because
contained_in returns 0.

This patch simply removes the BLOCK_FUNCTION check from contained_in.
The rationale here is that in languages without nested functions, this
will not cause any issues.

gdb/ChangeLog
2019-07-30  Tom Tromey  <tromey@adacore.com>

	* block.c (contained_in): Remove BLOCK_FUNCTION check.

gdb/testsuite/ChangeLog
2019-07-30  Tom Tromey  <tromey@adacore.com>

	* gdb.ada/display_nested.exp: New file.
	* gdb.ada/display_nested/foo.adb: New file.
	* gdb.ada/display_nested/pack.adb: New file.
	* gdb.ada/display_nested/pack.ads: New file.
2019-07-30 12:34:51 -06:00
Kevin Buettner a1530dc731 Allow display of negative offsets in print_address_symbolic()
When examining addresses associated with blocks with non-contiguous
address ranges, it's not uncommon to see large positive offsets which,
for some address width, actually represent a smaller negative offset.
Here's an example taken from the test case (using the
dw2-ranges-func-lo-cold executable):

    (gdb) x/5i foo_cold
       0x40110d <foo+4294967277>:	push   %rbp
       0x40110e <foo+4294967278>:	mov    %rsp,%rbp
       0x401111 <foo+4294967281>:	callq  0x401106 <baz>
       0x401116 <foo+4294967286>:	nop
       0x401117 <foo+4294967287>:	pop    %rbp

This commit, in conjuction with an earlier patch from this series, causes
cases like the above to be displayed like this (below) instead:

(gdb) x/5i foo_cold
   0x40110d <foo_cold>:	push   %rbp
   0x40110e <foo-18>:	mov    %rsp,%rbp
   0x401111 <foo-15>:	callq  0x401106 <baz>
   0x401116 <foo-10>:	nop
   0x401117 <foo-9>:	pop    %rbp

Note that the address of foo_cold is now (due to another patch) being
displayed as <foo_cold> instead of <foo+BigOffset>.  The subsequent
lines are shown as negative offsets from foo.

Disassembly using the "disassemble" command is somewhat affected by
these changes:

Before:

(gdb) disassemble foo_cold
Dump of assembler code for function foo:
Address range 0x401120 to 0x40113b:
   0x0000000000401120 <+0>:	push   %rbp
   0x0000000000401121 <+1>:	mov    %rsp,%rbp
   0x0000000000401124 <+4>:	callq  0x401119 <bar>
   0x0000000000401129 <+9>:	mov    0x2ef1(%rip),%eax        # 0x404020 <e>
   0x000000000040112f <+15>:	test   %eax,%eax
   0x0000000000401131 <+17>:	je     0x401138 <foo+24>
   0x0000000000401133 <+19>:	callq  0x40110d <foo+4294967277>
   0x0000000000401138 <+24>:	nop
   0x0000000000401139 <+25>:	pop    %rbp
   0x000000000040113a <+26>:	retq
Address range 0x40110d to 0x401119:
   0x000000000040110d <+-19>:	push   %rbp
   0x000000000040110e <+-18>:	mov    %rsp,%rbp
   0x0000000000401111 <+-15>:	callq  0x401106 <baz>
   0x0000000000401116 <+-10>:	nop
   0x0000000000401117 <+-9>:	pop    %rbp
   0x0000000000401118 <+-8>:	retq
End of assembler dump.

After:

(gdb) disassemble foo_cold
Dump of assembler code for function foo:
Address range 0x401120 to 0x40113b:
   0x0000000000401120 <+0>:	push   %rbp
   0x0000000000401121 <+1>:	mov    %rsp,%rbp
   0x0000000000401124 <+4>:	callq  0x401119 <bar>
   0x0000000000401129 <+9>:	mov    0x2ef1(%rip),%eax        # 0x404020 <e>
   0x000000000040112f <+15>:	test   %eax,%eax
   0x0000000000401131 <+17>:	je     0x401138 <foo+24>
   0x0000000000401133 <+19>:	callq  0x40110d <foo_cold>
   0x0000000000401138 <+24>:	nop
   0x0000000000401139 <+25>:	pop    %rbp
   0x000000000040113a <+26>:	retq
Address range 0x40110d to 0x401119:
   0x000000000040110d <-19>:	push   %rbp
   0x000000000040110e <-18>:	mov    %rsp,%rbp
   0x0000000000401111 <-15>:	callq  0x401106 <baz>
   0x0000000000401116 <-10>:	nop
   0x0000000000401117 <-9>:	pop    %rbp
   0x0000000000401118 <-8>:	retq
End of assembler dump.

Note that negative offsets are now displayed without the leading "+".
Also, the callq to foo_cold is now displayed as such instead of a callq
to foo with a large positive offset.

gdb/ChangeLog:

	* printcmd.c (print_address_symbolic): Print negative offsets.
	(build_address_symbolic): Force signed arithmetic when computing
	offset.
2019-07-30 09:19:13 -07: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 5c4dde850c Add missing changelog entry
I forgot to commit the change before pushing commit
25ec892484
2019-07-30 10:41:32 -05:00
Tom de Vries 0f575925b6 [gdb/testsuite] Work around tcl bug in libsegfault.exp with check-read1
When running libsegfault.exp with check-read1, I get:
...
Running gdb/testsuite/gdb.base/libsegfault.exp ...
ERROR: tcl error sourcing gdb/testsuite/gdb.base/libsegfault.exp.
ERROR: no such variable
    (read trace on "env(LD_PRELOAD)")
    invoked from within
"set env(LD_PRELOAD)"
    ("uplevel" body line 1)
    invoked from within
"uplevel 1 [list set $var]"
    invoked from within
"if [uplevel 1 [list array exists $var]] {
                set saved_arrays($var) [uplevel 1 [list array get $var]]
            } else {
                set saved_scalars($var) [uplevel ..."
    invoked from within
"if [uplevel 1 [list info exists $var]] {
            if [uplevel 1 [list array exists $var]] {
                set saved_arrays($var) [uplevel 1 [list array get $var]]
          ..."
    (procedure "save_vars" line 11)
    invoked from within
"save_vars { env(LD_PRELOAD) } {
        if { ![info exists env(LD_PRELOAD) ]
             || $env(LD_PRELOAD) == "" } {
            set env(LD_PRELOAD) "$lib"
        } else {
         ..."
    (procedure "gdb_spawn_with_ld_preload" line 4)
    invoked from within
"gdb_spawn_with_ld_preload $libsegfault """
...

There are several things here interacting with environment variable
LD_PRELOAD:
- the expect "binary" build/gdb/testsuite/expect-read1 with does
  export LD_PRELOAD=build/gdb/testsuite/read1.so before calling native expect
- read1.so which does unsetenv ("LD_PRELOAD") upon first call to read
- the test-case, which wants to set or append libSegFault.so to LD_PRELOAD

The error occurs when accessing $env(LD_PRELOAD), in a branch where
"info exists env(LD_PRELOAD)" returns true. AFAIU, this is
https://core.tcl-lang.org/tcl/tktview?name=67fd4f973a "incorrect results of
'info exists' when unset env var in one interp and check for existence from
another interp".

Work around the tcl bug by not unsetting the variable, but setting it to ""
instead:
...
-      unsetenv ("LD_PRELOAD");
+      setenv ("LD_PRELOAD", "", 1);
...

Verified that reverting commit de28a3b72e "[gdb/testsuite, 2/2] Fix
gdb.linespec/explicit.exp with check-read1" reintroduced the check-read1
failure in gdb.linespec/explicit.exp.

This fixes a similar error in attach-slow-waitpid.exp, which also sets
LD_PRELOAD.

Tested on x86_64-linux with check-read1.

gdb/testsuite/ChangeLog:

2019-07-30  Tom de Vries  <tdevries@suse.de>

	* lib/read1.c (read): Don't use unsetenv (v), use setenv (v, "", 1)
	instead.
2019-07-30 16:15:46 +02:00
Tom de Vries b13057d9ce [gdb/testsuite] Fail in gdb_compile if nopie results in PIE executable
When running gdb.base/dump.exp with --target_board=unix/-fPIE/-pie, we get:
...
Running gdb/testsuite/gdb.base/dump.exp ...
FAIL: gdb.base/dump.exp: dump array as value, intel hex
...

The FAIL happens because although the test specifies nopie, the exec is
in fact compiled as PIE.  The "-fPIE -pie" options specified using the
target_board are interpreted by dejagnu as multilib_flags, and end up
overriding the nopie flags.

Fix this by checking in gdb_compile if the resulting exec is PIE despite of
a nopie setting, and if so return an error:
...
Running gdb/testsuite/gdb.base/dump.exp ...
gdb compile failed, nopie failed to prevent PIE executable

                === gdb Summary ===

nr of untested testcases         1
...

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-07-30  Tom de Vries  <tdevries@suse.de>

	PR testsuite/24834
	* lib/gdb.exp (gdb_compile): Fail if nopie results in PIE executable.
	(exec_is_pie): New proc.
2019-07-30 09:42:07 +02:00
Christian Biesinger 25ec892484 Fix misspelling (nonexistant -> nonexistent)
gdb/testsuite/ChangeLog:

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

	* gdb.python/py-objfile.exp: Fix misspelling (nonexistant -> nonexistent)
2019-07-29 21:01:13 -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
Tom Tromey 3d2357068b Two fixes for test suite's terminal
Exactly which escape sequences are emitted by gdb in TUI mode are
determined largely by the curses implementation.  Testing my latest
(as yet unsubmitted) series to refactor the TUI showed a couple of
failures that I tracked to the test suite's terminal implementation.

In particular, the CSI "@" sequence was not implemented; and the CSI
"X" sequence was implemented incorrectly.

This patch fixes both of these problems.  Tested on x86-64 Fedora 28.

gdb/testsuite/ChangeLog
2019-07-29  Tom Tromey  <tom@tromey.com>

	* lib/tuiterm.exp (Term::_csi_@): New proc.
	(Term::_csi_X): Don't move cursor.
2019-07-29 16:06:58 -06: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
Philippe Waroquiers c7e4c0a648 Test 'set print frame-info|frame-arguments presence'.
Updated tests to test the new options and new values.
Test the default for print_what in python frame filtering.
Updated the tests impacted by the default in python frame filtering
which is now consistent with the backtrace command.

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

	* gdb.base/options.exp: Update backtrace - completion to
	new option -frame-info.
	* gdb.base/frame-args.exp: Test new 'frame-arguments presence'.
	Test new 'set print frame-info'.  Test backtrace -frame-info
	overriding 'set print frame-info'.
	* gdb.python/py-framefilter.exp: Test new 'frame-arguments presence'.
	Test new 'set print frame-info'.
	Verify consistency of backtrace with and without filters, with and
	without -no-filters.
	* gdb.python/py-framefilter-invalidarg.exp: Update to new print_what
	default.
2019-07-29 21:42:52 +02:00
Philippe Waroquiers 4b5e8d19af Implement 'set print frame-info|frame-arguments presence'.
New settings allow to better control what frame information is printed.

'set print frame-info' allows to override the default frame information
printed when a GDB command prints a frame.
The backtrace command has a new option -frame-info to override
this global setting.

It is now possible to have very short frame information by using the
new 'set print frame-arguments presence' and
'set print frame-info short-location'.

Combined with 'set print address off', a backtrace will only show
the essential information to see the function call chain, e.g.:
  (gdb) set print address off
  (gdb) set print frame-arguments presence
  (gdb) set print frame-info short-location
  (gdb) bt
  #0  break_me ()
  #1  call_me (...)
  #2  main ()
  (gdb)

This is handy in particular for big backtraces with functions having
many arguments.

Python frame filter printing logic has been updated to respect the new
setting in non MI mode.

Also, the default frame information printed was inconsistent when
backtrace was printing the frame information itself, or when the python
frame filtering code was printing the frame information.
This patch changes the default of python frame filtering to have a
consistent behaviour regarding printed frame-information, whatever
the presence/activity/matches of python filters.

2019-07-29  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

	* frame.h (enum print_what): New value 'SHORT_LOCATION', update
	comments.
	(print_frame_info_auto, print_frame_info_source_line,
	print_frame_info_location, print_frame_info_source_and_location,
	print_frame_info_location_and_address, print_frame_info_short_location):
	New declarations.
	(struct frame_print_options): New member print_frame_info.
	* extension.h (enum ext_lang_frame_args): New value CLI_PRESENCE.
	* stack.h (get_user_print_what_frame_info): New declaration.
	(frame_show_address): New declaration.
	* stack.c (print_frame_arguments_choices): New value 'presence'.
	(print_frame_info_auto, print_frame_info_source_line,
	print_frame_info_location, print_frame_info_source_and_location,
	print_frame_info_location_and_address, print_frame_info_short_location,
	print_frame_info_choices, print_frame_info_print_what): New definitions.
	(print_frame_args): Only print dots for args if print frame-arguments
	is 'presence'.
	(frame_print_option_defs): New element for "frame-info".
	(get_user_print_what_frame_info): New function.
	(frame_show_address): Make non static.  Move comment to stack.h.
	(print_frame_info_to_print_what): New function.
	(print_frame_info): Update comment.  Use fp_opts.print_frame_info
	to decide what to print.
	(backtrace_command_1): Handle the new print_frame_arguments_presence
	value.
	(_initialize_stack): Call add_setshow_enum_cmd for frame-info.
	* python/py-framefilter.c (py_print_args): Handle CLI_PRESENCE.
	(py_print_frame): In non-mi mode, use LOCATION as default for
	print_what, similarly to frame information printed directly by
	backtrace command. Handle frame-info user option in non MI mode.
2019-07-29 21:42:29 +02:00
Tom de Vries de28a3b72e [gdb/testsuite, 2/2] Fix gdb.linespec/explicit.exp with check-read1
When running gdb.linespec/explicit.exp with check-read1, we get:
...
(gdb) PASS: gdb.linespec/explicit.exp: set max-completions unlimited
break 
-function
  ...
top
(gdb) PASS: gdb.linespec/explicit.exp: complete with no arguments
break
-function
 ...
top
(gdb) FAIL: gdb.linespec/explicit.exp: complete with no arguments (clearing input line)
...

The problem is that the send_gdb "\t\t" triggers completion twice:
...
        set tst "complete with no arguments"
        send_gdb "break \t"
        gdb_test_multiple "" $tst {
            "break \\\x07" {
                send_gdb "\t\t"
                gdb_test_multiple "" $tst {
	...
	}
	clear_input_line $tst
...
but the following gdb_test_multiple only parses it once, so the second
completion is left for clear_input_line, which fails.

Fix this by triggering completion only once.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-07-29  Tom de Vries  <tdevries@suse.de>

	* gdb.linespec/explicit.exp: Fix completion trigger for "complete with
	no arguments".
2019-07-29 16:24:57 +02:00
Tom de Vries 507dd60e28 [gdb/testsuite, 1/2] Fix gdb.linespec/explicit.exp with check-read1
When running gdb.linespec/explicit.exp with check-read1, we get:
...
(gdb) PASS: gdb.linespec/explicit.exp: complete unique file name: break -source "3explicit.c"
break -source exp^Glicit^G^M
explicit.c   explicit2.c  ^M
(gdb) FAIL: gdb.linespec/explicit.exp: complete non-unique file name
...

The problem is that we have a gdb_test_multiple where we match two regexps:
...
        set tst "complete non-unique file name"
        send_gdb "break -source exp\t"
        gdb_test_multiple "" $tst {
            -re "break -source exp\\\x07licit" {
                ...
            }

            -re "break -source exp\\\x07l" {
                # This pattern may occur when glibc debuginfo is installed.
		...
            }
        }
...
but since second is a substring of the first, we'll usually match the first,
but with check-read1 we'll match the second.

Fix this by using a single regexp and merging the related code.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-07-29  Tom de Vries  <tdevries@suse.de>

	* gdb.linespec/explicit.exp: Fix gdb_test_multiple regexps where second
	is a substring of the first for "complete non-unique file name".
2019-07-29 16:24:57 +02:00
Tom de Vries 5beafce944 [gdb/testsuite] Fix python.exp with check-read1
when running python/python.exp with check-read1, we get:
...
(gdb) PASS: gdb.python/python.exp: prompt substitution readline - end
python gdb.prompt_hook = error_prompt^M
Python Exception <type 'exceptions.RuntimeError'> Python exception calledPASS: gdb.python/python.exp: set hook
: ^M
(gdb) PASS: gdb.python/python.exp: set the hook to default
python gdb.prompt_hook = None^M
(gdb) PASS: gdb.python/python.exp: set print-stack full for prompt error test
set python print-stack full^M
(gdb) FAIL: gdb.python/python.exp: set the hook
python gdb.prompt_hook = error_prompt^M
Traceback (most recent call last):^M
  File "<string>", line 3, in error_prompt^M
RuntimeError: Python exception called^M
(gdb) FAIL: gdb.python/python.exp: set the hook to default
...

The problem is that gdb_test_multiple here:
...
gdb_test_multiple "python gdb.prompt_hook = error_prompt" "set the hook" {
    -re "Python Exception (exceptions.RuntimeError|<(type 'exceptions.|class ')RuntimeError'>) Python excepti
on called.*" {
       pass "set hook"
    }
}
...
specifies a regexp that ends with ".*" but doesn't specify the expected
$gdb_prompt.

Consequently, due to check-read1, the ".*" is matched to "" and the remaining
$gdb_prompt  is read by the the following gdb_py_test_silent_cmd, which has
its own $gdb_prompt read by the following gdb_py_test_silent_cmd, which has
its own $gdb_prompt causing a mismatch for the following gdb_test_multiple:
...
gdb_test_multiple "python gdb.prompt_hook = error_prompt" "set the hook" {
    -re "Traceback.*File.*line.*RuntimeError.*Python exception called.*" {
        pass "set hook"
    }
}
...
which causes both FAILs.

The second gdb_test_multiple has the same problem as the first, but it happens
not to cause a FAIL because it's followed by a gdb_py_test_silent_cmd and a
clean_restart.

Fix the regexps in both gdb_test_multiple calls.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-07-29  Tom de Vries  <tdevries@suse.de>

	* gdb.python/python.exp: Don't terminate gdb_test_multiple regexp
	with ".*".
2019-07-29 15:07:47 +02:00
Tom de Vries 2d274232f3 [gdb/testsuite] Fix mi-catch-cpp-exceptions.exp and mi-nonstop.exp with check-read1
With check-read1 we get:
...
FAIL: gdb.mi/mi-catch-cpp-exceptions.exp: check for stap probe in libstdc++
FAIL: gdb.mi/mi-nonstop.exp: probe for target remote
...

In both cases this is due to using gdb_test_multiple (which expects $gdb_prompt
by default) in combination with gdb using $gdb_mi_prompt, similar to the
problem fixed by commit d17725d72f "Don't expect gdb_prompt in
mi_skip_python_test".

Fix this by adding the $prompt_regexp argument to the gdb_test_multiple calls.

gdb/testsuite/ChangeLog:

2019-07-29  Tom de Vries  <tdevries@suse.de>

	* lib/gdb.exp (skip_libstdcxx_probe_tests_prompt, gdb_is_target_1):
	Pass prompt_regexp parameter to gdb_test_multiple calls.
2019-07-29 14:11:13 +02:00
Tom de Vries 9197cd8b52 [gdb/testsuite] Fix gdb.base/maint.exp with check-read1
With gdb.base/maint.exp and check-read1, we get:
...
FAIL: gdb.base/maint.exp: maint print registers
...

Using this patch:
...
diff --git a/gdb/testsuite/gdb.base/maint.exp b/gdb/testsuite/gdb.base/maint.exp
index a7675ea215..b81d7ec660 100644
--- a/gdb/testsuite/gdb.base/maint.exp
+++ b/gdb/testsuite/gdb.base/maint.exp
@@ -81,7 +81,9 @@ gdb_test_multiple $test $test {
         exp_continue
     }
     -re "$gdb_prompt $" {
-        gdb_assert { $saw_registers && $saw_headers } $test
+       gdb_assert { $saw_headers } "$test: saw headers"
+       gdb_assert { $saw_registers } "$test: saw registers"
+       pass "$test: got prompt"
     }
 }
...

We get more information:
...
PASS: gdb.base/maint.exp: maint print registers: saw headers
FAIL: gdb.base/maint.exp: maint print registers: saw registers
PASS: gdb.base/maint.exp: maint print registers: got prompt
...

The problem is that when matching:
...
(gdb) maint print registers^M
 Name         Nr  Rel Offset    Size  Type            ^M
 rax           0    0      0       8 int64_t         ^M
...
the regexp for $saw_headers ends in "\[\r\n\]+", which
allows it to match only the "\r".  The remaining "\n" then start the next line
to be matched, which doesn't match for the $saw_registers regexp since it
starts with "^\[^\r\n\]+".

Fix this by ending the regexps with "\r\n".

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-07-29  Tom de Vries  <tdevries@suse.de>

	* gdb.base/maint.exp: Use "\r\n" instead of "\[\r\n\]+" in "maint
          print registers" regexps.
2019-07-29 11:24:04 +02:00
Tom de Vries b528dae095 [gdb/testsuite] Fix gdb.base/define.exp with check-read1
When running gdb.base/define.exp with check-read1, we get:
...
show prompt^M
Gdb's prompt is "(gdb) ".^M
(gdb) PASS: gdb.base/define.exp: save gdb_prompt
set prompt \(blah\) ^M
(blah) PASS: gdb.base/define.exp: set gdb_prompt
set prompt (gdb) PASS: gdb.base/define.exp: reset gdb_prompt
^M
(gdb) FAIL: gdb.base/define.exp: define do-define
...

The problem is that the "$gdb_prompt $" regexp here:
...
gdb_test_multiple "set prompt $prior_prompt " "reset gdb_prompt" {
    -re "$gdb_prompt $" {
        pass "reset gdb_prompt"
    }
}
...
triggers for the echoing of the command "set prompt $prior_prompt " rather
than for the prompt after the command has executed.

Fix this by changing the regexp to "\r\n$gdb_prompt $".

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-07-29  Tom de Vries  <tdevries@suse.de>

	* gdb.base/define.exp: Add "\r\n" to "reset gdb_prompt" regexp.
2019-07-29 11:24:04 +02:00
Tom de Vries d17725d72f [gdb/testsuite] Don't expect gdb_prompt in mi_skip_python_test
When running gdb.python/py-mi-events.exp with make check-read1, we get:
...
(gdb) ^M
python print ('test')^M
&"python print ('test')\n"^M
~"test\n"^M
^done^M
(gdb) FAIL: gdb.python/py-mi-events.exp: verify python support
^M
python print (sys.version_info[0])^M
&"python print (sys.version_info[0])\n"^M
~"2\n"^M
^done^M
(gdb) FAIL: gdb.python/py-mi-events.exp: check if python 3
^M
...

The FAILs happen as follows.

On one hand, skip_python_tests_prompt uses the prompt_regexp parameter for the
user_code argument of gdb_test_multiple:
...
proc skip_python_tests_prompt { prompt_regexp } {
    global gdb_py_is_py3k

    gdb_test_multiple "python print ('test')" "verify python support" {
	-re "not supported.*$prompt_regexp" {
	    unsupported "Python support is disabled."
	    return 1
	}
	-re "$prompt_regexp" {}
    }

    gdb_test_multiple "python print (sys.version_info\[0\])" "check if python 3" {
	-re "3.*$prompt_regexp" {
            set gdb_py_is_py3k 1
        }
	-re ".*$prompt_regexp" {
            set gdb_py_is_py3k 0
        }
    }
...

On the other hand, gdb_test_multiple itself uses $gdb_prompt:
...
         -re "\r\n$gdb_prompt $" {
            if ![string match "" $message] then {
                fail "$message"
            }
            set result 1
        }
...

So when mi_skip_python_test calls skip_python_tests_prompt with prompt_regexp
set to $mi_gdb_prompt:
...
proc mi_skip_python_tests {} {
    global mi_gdb_prompt
    return [skip_python_tests_prompt "$mi_gdb_prompt$"]
}
...
and expect reads "(gdb) " and tries to match it (due to the READ1=1 setting),
the user_code regexps using $prompt_regexp (set to $mi_gdb_prompt) don't match,
but the $gdb_prompt regexp in gdb_test_multiple does match.

Fix this by adding a prompt_regexp parameter to gdb_test_multiple, and using the
parameter in skip_python_tests_prompt.

Tested gdb.python/py-mi-events.exp with make check READ1=1 x86_64-linux.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-07-29  Tom de Vries  <tdevries@suse.de>

	PR gdb/24855
	* lib/gdb.exp (gdb_test_multiple): Add prompt_regexp parameter.
	(skip_python_tests_prompt): Add prompt_regexp argument to
	gdb_test_multiple calls.
2019-07-29 11:24:04 +02:00
Tom Tromey 52b75bf1dc Add test that "file" shows "main"
This adds a new test that checks that the "file" command will show the
program's "main".

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

	* gdb.tui/main.exp: New file.
2019-07-27 21:08:36 -06:00
Tom Tromey 2b1d00c2b8 Add test case for empty TUI windows
My original intent here was to add a test case to test that empty TUI
windows re-render their contents after a resize.  However, this seems
pretty broken at the moment, so a lot of the test is actually
disabled.

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

	* lib/tuiterm.exp (Term::clean_restart): Make "executable"
	optional.
	* gdb.tui/empty.exp: New file.
2019-07-27 21:08:35 -06:00
Tom Tromey ded631d57d Add TUI resizing test
This adds a test case that resizes the terminal and then checks that
the TUI updates properly.

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

	* lib/tuiterm.exp (spawn): New proc.
	(Term::resize): New proc.
	* gdb.tui/resize.exp: New file.
2019-07-27 21:08:35 -06:00
Tom Tromey 58ac439d38 Add TUI test for "list"
This adds a test to check that the "list" command will update the TUI
source window.

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

	* gdb.tui/list.exp: New file.
2019-07-27 21:08:34 -06:00
Tom Tromey fe1f56ee14 Add TUI register window test
This adds a very simple test of the TUI register window.

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

	* gdb.tui/regs.exp: New file.
2019-07-27 21:08:34 -06:00
Tom Tromey f790b310d2 Add "layout split" test
This adds a test of "layout split" to the TUI test suite.

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

	* gdb.tui/basic.exp: Add "layout split" test.
2019-07-27 21:08:33 -06:00
Tom Tromey d95fc6eec0 Add test for "layout asm"
This adds a very simple test for "layout asm".

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

	* gdb.tui/basic.exp: Add "layout asm" test.
2019-07-27 21:08:33 -06:00
Tom Tromey c3786b3aa3 A virtual terminal for the test suite
This patch implements a simple ANSI terminal emulator for the test
suite.  It is still quite basic, but it is good enough to allow some
simple TUI testing to be done.

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

	* lib/tuiterm.exp: New file.
	* gdb.tui/basic.exp: New file.
2019-07-27 21:08:32 -06:00
Kevin Buettner 6bdfee8157 Fix gdb.python/py-thrhandle.exp failures for -m32 multilib
This patch fixes the following failures when testing with
"target_board unix/-m32" using a x86_64-pc-linux-gnu native GDB.

FAIL: gdb.python/py-thrhandle.exp: print thread for bogus handle thrs[3]
FAIL: gdb.python/py-thrhandle.exp: print thread for bogus handle thrs[4]
FAIL: gdb.python/py-thrhandle.exp: print thread id for thrs[0]
FAIL: gdb.python/py-thrhandle.exp: print thread id for thrs[1]
FAIL: gdb.python/py-thrhandle.exp: print thread id for thrs[2]
FAIL: gdb.python/py-thrhandle.exp: thread 0: fetch thread handle from thread
FAIL: gdb.python/py-thrhandle.exp: thread 0: verify that handles are the same
FAIL: gdb.python/py-thrhandle.exp: thread 1: fetch thread handle from thread
FAIL: gdb.python/py-thrhandle.exp: thread 1: verify that handles are the same
FAIL: gdb.python/py-thrhandle.exp: thread 2: fetch thread handle from thread
FAIL: gdb.python/py-thrhandle.exp: thread 2: verify that handles are the same

I've written it so that it might work for other 64-bit host / 32-bit target
combos too.

gdb/ChangeLog:

	* linux-thread-db.c (thread_db_target::thread_handle_to_thread_info):
	Add case for debugging 32-bit target on 64-bit host.  Revise
	comment.
2019-07-27 13:52:45 -07:00
Kevin Buettner 98a617f8d5 Fix stepping bug associated with non-contiguous blocks
I recently noticed the following behavior while debugging
dw2-ranges-func-low-cold.  This is one of the test programs associated
with the test gdb.dwarf2/dw2-ranges-func.exp.

(gdb) b 70
Breakpoint 1 at 0x401129: file dw2-ranges-func-lo-cold.c, line 70.
(gdb) run
Starting program: dw2-ranges-func-lo-cold

Breakpoint 1, foo ()
    at dw2-ranges-func-lo-cold.c:70
70	  if (e) foo_cold ();				/* foo foo_cold call */
(gdb) set var e=1
(gdb) step
[Inferior 1 (process 12545) exited normally]

This is incorrect.  When stepping, we expect a step to occur.  We do not
expect the program to exit.  Instead, we should see the following behavior:

...
(gdb) set var e=1
(gdb) step
foo ()
    at dw2-ranges-func-lo-cold.c:54
54	  baz ();					/* foo_cold baz call */

(Note that I've shortened the paths in the above sessions to improve
readability.)

The bug is in fill_in_stop_func() in infrun.c.  While working on
non-contiguous address range improvements in 2018, I replaced the
call to find_pc_partial_function() with a call to
find_function_entry_range_from_pc().  Although this seemed like the
right thing to do at the time, I now think that calling
find_pc_partial_function (along with some other tweaks) is the right
thing to do.

For blocks with a single contiguous range, these functions do pretty
much the same thing: when the function succeeds, the function name,
start address, and end address are all filled in.  Additionally,
find_pc_partial_function contains an additional output parameter
which is set to the block containing that PC.

For blocks with non-contiguous ranges, find_pc_partial_function
sets the start and end addresses to the start and end addresses
of the range containing the pc.  find_function_entry_range_from_pc
does what it says; it sets the start and end addresses to those
of the range containing the entry pc.

The reason that I had thought that using the entry pc range was
correct is due to the fact that fill_in_stop_func() contains some
code for advancing past the function start and entry point.  To do
this, we'd need the range that contains the entry pc.

However, when stepping, we actually want the range that contains the
stop pc.  If that range also contains the entry pc, we should then
attempt to advance stop_func_start past the start offset and entry
point.  (I haven't thought very hard about the reason for advancing
the stop_func_start in this manner.  Since it's been there for quite
a while, I'm assuming that it's still a good idea.)

Back when I wrote the test case, I had included a test for doing the
step shown in the example above.  I had problems with it, however.  At
the time, I thought it was due to differing compiler versions, so I
disabled that portion of the test.  I have now reenabled those tests,
but have left in place the logic which may be used to disable it.

The changes to dw2-ranges-func.exp depend on my other recent changes
to the file which have not been pushed yet.

Finally, I'll note that the only caller of
find_function_entry_range_from_pc() is/was fill_in_stop_func().  Once
this commit goes in, it'll be dead code.  I considered removing it,
but I think that it ought to be used (instead of
find_pc_partial_function) for determining the correct range to scan
for prologue analysis, so I'm going to leave it in place for now.

gdb/ChangeLog:

	* infrun.c (fill_in_stop_func): Use find_pc_partial_function
	instead of find_function_entry_range_from_pc.

testsuite/ChangeLog:

	* gdb.dwarf2/dw2-ranges-func.exp (enable_foo_cold_stepping):
	Enable tests associated with this flag.  Adjust regex
	referencing "foo_low" to now refer to "foo_cold" instead.
2019-07-27 13:43:10 -07:00
Kevin Buettner 5c076da45c Improve test gdb.dwarf2/dw2-ranges-func.exp
The original dw2-ranges-func.exp test caused a function named foo to be
created with two non-contiguous address ranges.  In the C source file,
a function named foo_low was incorporated into the function foo which
was also defined in that file.  The DWARF assembler is used to do this
manipulation.  The source file had been laid out so that foo_low would
likely be placed (by the compiler and linker) at a lower address than
foo().

The case where a range at a higher set of addresses (than foo) was not
being tested.  In a recent discussion on gdb-patches, it became clear
that performing such tests are desirable because bugs were discovered
which only became evident when the other range was located at high(er)
addresses than the range containing the entry point for the function.

This other (non entry pc) address range is typically used for "cold"
code which executes less frequently.  Thus, I renamed foo_low to
foo_cold and renamed the C source file from dw-ranges-func.c to
dw-ranges-func-lo.c.  I then made a copy of this file, naming it
dw-ranges-func-hi.c.  (That was my intent anyway.  According to git,
I renamed dw-ranges-func.c to dw-ranges-func-hi.c and then modified it.
dw-ranges-func-lo.c shows up as an entirely new file.)

Within dw-ranges-func-hi.c, I changed the placement of foo_cold()
along with some of the other functions so that foo_cold() would be at
a higher address than foo() while also remaining non-contiguous.  The
two files, dw-ranges-func-lo.c and dw-ranges-func-hi.c, are
essentially the same except for the placement of some of the functions
therein.

The tests in dw2-ranges-func.exp where then wrapped in a new proc named
do_test which was then called in a loop from the outermost level.  The
loop causes each of the source files to have the same tests run upon
them.

I also added a few new tests which test functionality fixed by the other
commits to this patch series.  Due to the reorganization of the file,
it's hard to identify these changes in the patch.  So, here are the
tests which were added:

    with_test_prefix "no-cold-names" {

	# Due to the calling sequence, this backtrace would normally
	# show function foo_cold for frame #1.  However, we don't want
	# this to be the case due to placing it in the same block
	# (albeit at a different range) as foo.  Thus it is correct to
	# see foo for frames #1 and #2.  It is incorrect to see
	# foo_cold at frame #1.
	gdb_test_sequence "bt" "backtrace from baz" {
	    "\[\r\n\]#0 .*? baz \\(\\) "
	    "\[\r\n\]#1 .*? foo \\(\\) "
	    "\[\r\n\]#2 .*? foo \\(\\) "
	    "\[\r\n\]#3 .*? main \\(\\) "
	}

	# Doing x/2i foo_cold should show foo_cold as the first symbolic
	# address and an offset from foo for the second.  We also check to
	# make sure that the offset is not too large - we don't GDB to
	# display really large offsets that would (try to) wrap around the
	# address space.
	set foo_cold_offset 0
	set test "x/2i foo_cold"
	gdb_test_multiple $test $test {
	    -re "   (?:$hex) <foo_cold>.*?\n   (?:$hex) <foo\[+-\](\[0-9\]+)>.*${gdb_prompt}" {
	        set foo_cold_offset $expect_out(1,string)
		pass $test
	    }
	}
	gdb_assert {$foo_cold_offset <= 10000} "offset to foo_cold is not too large"

	# Likewise, verify that second address shown by "info line" is at
	# and offset from foo instead of foo_cold.
	gdb_test "info line *foo_cold" "starts at address $hex <foo_cold> and ends at $hex <foo\[+-\].*?>.*"

    }

When run against a GDB without the requisite bug fixes (from this patch
series), these 6 failures should be seen:

FAIL: gdb.dwarf2/dw2-ranges-func.exp: lo-cold: no-cold-names: backtrace from baz (pattern 4)
FAIL: gdb.dwarf2/dw2-ranges-func.exp: lo-cold: no-cold-names: x/2i foo_cold
FAIL: gdb.dwarf2/dw2-ranges-func.exp: lo-cold: no-cold-names: info line *foo_cold
FAIL: gdb.dwarf2/dw2-ranges-func.exp: hi-cold: no-cold-names: backtrace from baz (pattern 3)
FAIL: gdb.dwarf2/dw2-ranges-func.exp: hi-cold: no-cold-names: x/2i foo_cold
FAIL: gdb.dwarf2/dw2-ranges-func.exp: hi-cold: no-cold-names: info line *foo_cold

gdb/testsuite/ChangeLog:

	* gdb.dwarf2/dw2-ranges-func.c: Rename to...
	* gdb.dwarf2/dw2-ranges-func-lo-cold.c: ...this.
	* gdb.dwarf2/dw2-ranges-func-lo-cold.c (foo_low): Change name to
	foo_cold.  Revise comments to match.
	* gdb.dwarf2/dw2-ranges-func-hi-cold.c: New file.
	* gdb.dwarf2/dw2-ranges-func.exp (do_test): New proc. Existing tests
	were wrapped into this proc; Call do_test in loop from outermost
	level.
	(foo_low): Rename all occurrences to "foo_cold".
	(backtrace from baz): New test.
	(x2/i foo_cold): New test.
	(info line *foo_cold): New test.
2019-07-27 13:38:44 -07:00
Kevin Buettner 1aff717310 dwarf2-frame.c: Fix FDE processing bug involving non-contiguous ranges
In the course of revising the test case for
gdb.dwarf2/dw2-ranges-func.exp, I added a new .c file which would
cause the "cold" range to be at a higher address than the rest of the
function.  In these tests, the range in question isn't really cold in
the sense that a compiler has determined that it'll be executed less
frequently.  Instead, it's simply the range that does not include the
entry pc.  These tests are intended to mimic the output of such a
compiler, so I'll continue to refer to this range as "cold" in the
following discussion.

The original test case had only tested a cold range placed
at lower addresses than the rest of the function.  During testing of the
new code where the cold range was placed at higher addresses, I found
that I could produce the following backtrace:

    (gdb) bt
    #0  0x0000000000401138 in baz ()
	at dw2-ranges-func-hi-cold.c:72
    #1  0x0000000000401131 in foo_cold ()
	at dw2-ranges-func-hi-cold.c:64
    #2  0x000000000040111e in foo ()
	at dw2-ranges-func-hi-cold.c:50
    #3  0x0000000000401144 in main ()
	at dw2-ranges-func-hi-cold.c:78

This is correct, except that we'd like to see foo() listed instead
of foo_cold().  (I handle that problem in another patch.)

Now look at what happens for a similar backtrace where the cold range
is at a lower address than the foo's entry pc:

    (gdb) bt
    #0  0x000000000040110a in baz ()
	at dw2-ranges-func-lo-cold.c:48
    #1  0x0000000000401116 in foo ()
	at dw2-ranges-func-lo-cold.c:54
    #2  0x00007fffffffd4c0 in ?? ()
    #3  0x0000000000401138 in foo ()
	at dw2-ranges-func-lo-cold.c:70

Note that the backtrace doesn't go all the way back to main().  Moreover,
frame #2 is messed up.

I had seen this behavior when I had worked on the non-contiguous
address problem last year.  At the time I convinced myself that the
mangled backtrace was "okay" since we're doing strange things with
the DWARF assembler.  We're taking a function called foo_cold (though
it was originally called foo_low - my recent changes to the test case
changed the name) and via the magic of the DWARF assembler, we're
combining it into a separate (non-contiguous) range for foo.  Thus,
it was a surprise to me when I got a good and complete backtrace when
the cold symbol is placed at an address that's greater than entry pc.

The function dwarf2_frame_cache (in dwarf2-frame.c) is making this
call:

    if (get_frame_func_if_available (this_frame, &entry_pc)) ...

If that call succeeds (returns a true value), the FDE is then
processed up to the entry pc.  It doesn't make sense to do this,
however, when the FDE in question does not contain the entry pc.  This
can happen when the function in question is comprised of more than one
(non-contiguous) address range.

My fix is to add some comparisons to the test above to ensure that
ENTRY_PC is within the address range covered by the FDE.

gdb/ChangeLog:

	* dwarf2-frame.c (dwarf2_frame_cache): Don't decode FDE instructions
	for entry pc when entry pc is out of range for that FDE.
2019-07-27 13:35:53 -07:00
Kevin Buettner 2dc80cf8a5 Restrict use of minsym names when printing addresses in disassembled code
build_address_symbolic contains some code which causes it to
prefer the minsym over the the function symbol in certain cases.
The cases where this occurs are the same as the "certain pathological
cases" that used to exist in find_frame_funname().

This commit largely disables that code; it will only prefer the
minsym when the address of minsym is identical to that of the address
under consideration AND the function address for the symbtab sym is
not the same as the address under consideration.

So, without this change, when using the dw2-ranges-func-lo-cold
executable from the gdb.dwarf2/dw2-ranges-func.exp test, GDB exhibits
the following behavior:

(gdb) x/5i foo_cold
   0x40110d <foo+4294967277>:	push   %rbp
   0x40110e <foo+4294967278>:	mov    %rsp,%rbp
   0x401111 <foo+4294967281>:	callq  0x401106 <baz>
   0x401116 <foo+4294967286>:	nop
   0x401117 <foo+4294967287>:	pop    %rbp

On the other hand, still without this change, using the
dw2-ranges-func-hi-cold executable from the same test, GDB
does this instead:

(gdb) x/5i foo_cold
   0x401128 <foo_cold>:	push   %rbp
   0x401129 <foo_cold+1>:	mov    %rsp,%rbp
   0x40112c <foo_cold+4>:	callq  0x401134 <baz>
   0x401131 <foo_cold+9>:	nop
   0x401132 <foo_cold+10>:	pop    %rbp

This is inconsistent behavior.  When foo_cold is at a lower
address than the function's entry point, the symtab symbol (foo)
is displayed along with a large positive offset which would wrap
around the address space if the address space were only 32 bits wide.
(A later patch fixes this problem by displaying negative offsets.)

This commit makes the behavior uniform for both the "lo-cold" and
"hi-cold" cases:

lo-cold:

(gdb) x/5i foo_cold
   0x40110d <foo_cold>:	push   %rbp
   0x40110e <foo-18>:	mov    %rsp,%rbp
   0x401111 <foo-15>:	callq  0x401106 <baz>
   0x401116 <foo-10>:	nop
   0x401117 <foo-9>:	pop    %rbp

hi-cold:

(gdb) x/5i foo_cold
   0x401128 <foo_cold>:	push   %rbp
   0x401129 <foo+35>:	mov    %rsp,%rbp
   0x40112c <foo+38>:	callq  0x401134 <baz>
   0x401131 <foo+43>:	nop
   0x401132 <foo+44>:	pop    %rbp

In both cases, the symbol shown for the address at which foo_cold
resides is shown as <foo_cold>.  Subsequent offsets are shown as
either negative or positive offsets from the entry pc for foo.

When disassembling a function, care must be taken to NOT display
<+0> as the offset for the second range.  For this reason, I found
it necessary to add the "prefer_sym_over_minsym" parameter to
build_address_symbolic.  The type of this flag is a bool; do_demangle
ought to be a bool also, so I made this change at the same time.

gdb/ChangeLog:

	* valprint.h (build_address_symbolic): Add "prefer_sym_over_minsym"
	parameter.  Change type of "do_demangle" to bool.
	* disasm.c (gdb_pretty_print_disassembler::pretty_print_insn):
	Pass suitable "prefer_sym_over_minsym" flag to
	build_address_symbolic().  Don't output "+" for negative offsets.
	* printcmd.c (print_address_symbolic): Update invocation of
	build_address_symbolic to include a "prefer_sym_over_minsym"
	flag.
	(build_address_symbolic): Add "prefer_sym_over_minsym" parameter.
	Restrict cases in which use of minimal symbol is preferred to that
	of a found symbol.  Update comments.
2019-07-27 13:28:56 -07:00
Kevin Buettner 567238c956 Prefer symtab symbol over minsym for function names in non-contiguous blocks
The discussion on gdb-patches which led to this patch may be found
here:

https://www.sourceware.org/ml/gdb-patches/2019-05/msg00018.html

Here's a brief synopsis/analysis:

Eli Zaretskii, while debugging a Windows emacs executable, found
that functions comprised of more than one (non-contiguous)
address range were not being displayed correctly in a backtrace.  This
is the example that Eli provided:

  (gdb) bt
  #0  0x76a63227 in KERNELBASE!DebugBreak ()
     from C:\Windows\syswow64\KernelBase.dll
  #1  0x012e7b89 in emacs_abort () at w32fns.c:10768
  #2  0x012e1f3b in print_vectorlike.cold () at print.c:1824
  #3  0x011d2dec in print_object (obj=<optimized out>, printcharfun=XIL(0),
      escapeflag=true) at print.c:2150

The function print_vectorlike consists of two address ranges, one of
which contains "cold" code which is expected to not execute very often.
There is a minimal symbol, print_vectorlike.cold.65, which is the address
of the "cold" range.

GDB is prefering this minsym over the the name provided by the
DWARF info due to some really old code in GDB which handles
"certain pathological cases".  This comment reads as follows:

      /* In certain pathological cases, the symtabs give the wrong
	 function (when we are in the first function in a file which
	 is compiled without debugging symbols, the previous function
	 is compiled with debugging symbols, and the "foo.o" symbol
	 that is supposed to tell us where the file with debugging
	 symbols ends has been truncated by ar because it is longer
	 than 15 characters).  This also occurs if the user uses asm()
	 to create a function but not stabs for it (in a file compiled
	 with -g).

	 So look in the minimal symbol tables as well, and if it comes
	 up with a larger address for the function use that instead.
	 I don't think this can ever cause any problems; there
	 shouldn't be any minimal symbols in the middle of a function;
	 if this is ever changed many parts of GDB will need to be
	 changed (and we'll create a find_pc_minimal_function or some
	 such).  */

In an earlier version of this patch, I had left the code for the
pathological case intact, but those who reviwed that patch recommended
removing it.  So that's what I've done - I've removed it.

gdb/ChangeLog:

	* stack.c (find_frame_funname): Remove code which preferred
	minsym over symtab sym in "certain pathological cases".
2019-07-27 13:26:46 -07:00
Brian Callahan 89b085acaf Fix return type typo in obsd-nat.c that breaks build on OpenBSD
To recap the bug report:
Commit a068643 introduced a small typo that breaks the gdb build on OpenBSD.
Line 38 of obsd-nat.c needs to be changed from std::sring to std::string.

gdb/ChangeLog
2019-07-26  Brian Callahan  <bcallah@openbsd.org>

	PR gdb/24839:
	* gdb/obsd-nat.c (obsd_nat_target::pid_to_str): Fix typo in return
	type.
2019-07-26 15:04:41 -06:00
Tom de Vries 1512d3b7b9 [gdb/testsuite] Fix unterminated string in i386-pkru.exp
I ran into this error:
...
ERROR: tcl error sourcing gdb/testsuite/gdb.arch/i386-pkru.exp.
ERROR: missing "
    while executing
"untested ""
    invoked from within
"if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     [list debug additional_flags=${comp_flags}]] } {
    untested "failed to c..."
    (file "gdb/testsuite/gdb.arch/i386-pkru.exp" line 25)
    invoked from within
...
caused by:
...
    untested "failed to compile x86 PKEYS test.
...

Fix the unterminated string.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-07-26  Tom de Vries  <tdevries@suse.de>

	* gdb.arch/i386-pkru.exp: Fix unterminated string.
2019-07-26 21:49:45 +02:00
Christian Biesinger f32feb4ab3 Fix comment about the signature of add_separate_debug_file
Also fixes the date in the changelog of my last commit.

gdb/ChangeLog:

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

	* python/py-objfile.c (add_separate_debug_file): Fix comment about
  this function's Python signature.
2019-07-25 17:17:49 -05:00
Tom de Vries 297989a10c [gdb/testsuite] Test skip_libstdcxx_probe_tests in mi-catch-cpp-exceptions.exp
On a system without SDT probes in libstdc++, we run into:
...
FAIL: gdb.mi/mi-catch-cpp-exceptions.exp: all with invalid regexp: run until \
  breakpoint in main (unknown output after running)
...

The test-case uses a regexp argument for the catch throw/rethrow/catch
command, which is only supported on systems with SDT probes in libstdc++.

Fix this by marking the portions of the test-case that use a regexp argument
as unsupported on a system without SDT probes.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-07-25  Tom de Vries  <tdevries@suse.de>

	PR testsuite/24830
	* gdb.mi/mi-catch-cpp-exceptions.exp: Call
	mi_skip_libstdcxx_probe_tests, and skip unsupported tests.
	* lib/gdb.exp (skip_libstdcxx_probe_tests_prompt): Factor out of ...
	(skip_libstdcxx_probe_tests): ... here.
	* lib/mi-support.exp (mi_skip_libstdcxx_probe_tests): New proc.
2019-07-25 18:39:31 +02:00
Christian Biesinger 442853af24 Allow passing a block to lookup_global_symbol_from_objfile
This has no behavior change in itself, but allows a future patch
to add a function to the Python API to look up symbols in the
static block.

gdb/ChangeLog:

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

	* compile/compile-object-load.c (compile_object_load): Pass GLOBAL_SCOPE.
	* solib-spu.c (spu_lookup_lib_symbol): Pass GLOBAL_SCOPE.
	* solib-svr4.c (elf_lookup_lib_symbol): Pass GLOBAL_SCOPE.
	* symtab.c (lookup_global_symbol_from_objfile): Add a scope parameter.
	* symtab.h (lookup_global_symbol_from_objfile): Likewise.
2019-07-24 19:02:50 -05:00
Tom de Vries b3b965fb91 [gdb/testsuite] Fix implicit declaration of printf in gdb.objc/*.m
When running gdb.objc/objcdecode.exp we get:
...
objcdecode.m: In function '-[Decode multipleDef]':
objcdecode.m:14:3: warning: incompatible implicit declaration of built-in \
  function 'printf'
   printf("method multipleDef\n");
   ^~~~~~
objcdecode.m:14:3: note: include '<stdio.h>' or provide a declaration of \
  'printf'
...

Fix this in the three gdb.objc/*.m test-cases by including stdio.h.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-07-24  Tom de Vries  <tdevries@suse.de>

	PR testsuite/24807
	* gdb.objc/basicclass.m: Include stdio.h.
	* gdb.objc/nondebug.m: Same.
	* gdb.objc/objcdecode.m: Same.
2019-07-24 19:01:59 +02:00
Tom de Vries 4625b4d081 [gdb/testsuite] Fix infoline-reloc-main-from-zero.exp compilation
When running gdb.base/infoline-reloc-main-from-zero.exp, I see:
...
Running gdb/testsuite/gdb.base/infoline-reloc-main-from-zero.exp ...
gdb compile failed, ld: infoline-reloc-main-from-zero: \
  not enough room for program headers, try linking with -N
ld: final link failed: bad value
collect2: error: ld returned 1 exit status
UNTESTED: gdb.base/infoline-reloc-main-from-zero.exp: infoline-reloc-main-from-zero.exp
UNTESTED: gdb.base/infoline-reloc-main-from-zero.exp: failed to compile
...

Fix this by following the suggestion:
...
-set opts {debug "additional_flags=-nostdlib -emain -Wl,-Ttext=0x00"}
+set opts {debug "additional_flags=-nostdlib -emain -Wl,-Ttext=0x00 -Wl,-N"}
...

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-07-24  Tom de Vries  <tdevries@suse.de>

	PR testsuite/24612
	* gdb.base/infoline-reloc-main-from-zero.exp: Add -Wl,-N to
	additional_flags.
2019-07-24 17:16:01 +02:00
Yoshinori Sato c54e42531a gdb/h8300-tdep.c: Fix register name in h8300h machine.
H8/300H general register name "ER0" - "ER7".
But gdb using "R0" - "R7".
This changes register name "ER0" - "ER7" in h8300h machine mode.

gdb/ChangeLog:

	* h8300-tdep.c (h8300_register_name_common): New.
	h8300_register_name): Use h8300_register_name_common.
	(h8300s_register_name): Likewise.
	(h8300sx_register_name): Likewise.
	(h8300h_register_nam): New.
	(h8300_gdbarch_init): Use h8300h_register_name in h8300h machine.
2019-07-24 20:51:52 +09:00
Tom de Vries 024a584000 Update expected info threads error messages in gdb.multi/tids.exp
We currently have these FAILs:
...
FAIL: gdb.multi/tids.exp: two inferiors: info threads -1
FAIL: gdb.multi/tids.exp: two inferiors: info threads -$one
...
because we're expecting:
...
Invalid thread ID: -1
...
but instead we have:
...
Unrecognized option at: -1
...

This error message for info threads has changed since commit 54d6600669
'Make "info threads" use the gdb::option framework'.

Update the test accordingly.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-07-24  Tom de Vries  <tdevries@suse.de>

	PR testsuite/24831
	* gdb.multi/tids.exp: Update error messages for info threads.
2019-07-24 08:36:17 +02:00
Tom de Vries c76ddaa3f4 [gdb/testsuite] Fix info-types.exp for debug info from more than one file
On openSUSE Leap 15.0, I get:
...
FAIL: gdb.base/info-types.exp: l=c: info types
FAIL: gdb.base/info-types.exp: l=c++: info types
...
because the info type command prints info for files info-types.c, stddef.h,
elf-init.c and init.c, while the regexp in the test-case expect only info for
info-types.c.

Fix this by extending the regexp.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-07-24  Tom de Vries  <tdevries@suse.de>

	* gdb.base/info-types.exp: Allow info types to print info for more than
	one file.
2019-07-24 08:04:59 +02:00
Tom de Vries 9a618ef615 [gdb/testsuite] Add missing initial prompt read in multidictionary.exp
When running multidictionary.exp in conjunction with:
...
$ stress -c $(($(cat /proc/cpuinfo | grep -c "^processor") + 1))
...
we get:
...
Running gdb/testsuite/gdb.dwarf2/multidictionary.exp ...
ERROR: Couldn't load multidictionary into gdb.

                === gdb Summary ===

nr of unresolved testcases       1
...

The multidictionary test-case needs -readnow, and achieves this using:
...
gdb_spawn_with_cmdline_opts "-readnow"
gdb_load
...
but the initial gdb prompt is not read.  Usually, the following gdb_load
command accidentally consumes that initial prompt (at the gdb_expect for the
kill command in gdb_file_cmd).  But under high load, that doesn't happen and
we run into the error.

Fix this by consuming the initial gdb prompt after spawning gdb.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-07-23  Tom de Vries  <tdevries@suse.de>

	PR testsuite/24842
	* gdb.dwarf2/multidictionary.exp: Consume initial prompt after
	gdb_spawn_with_cmdline_opts.
2019-07-23 15:15:20 +02:00
Srinath Parvathaneni 40eadf04ff [gdb][Arm]: gdb cannot step across CMSE secure entry function code.
GDB is not able to execute "step" command on function calls of Armv8-M cmse secure entry functions.
Everytime GNU linker come across definition of any cmse secure entry function in object file(s),
it creates two new instructions secure gateway (sg) and original branch destination (b.w),
place those two instructions in ".gnu.sgstubs" section of executable.
Any function calls to these cmse secure entry functions is re-directed through secure gateway (sg)
present in ".gnu.sgstubs" section.

Example:
Following is a function call to cmse secure entry function "foo":
        ...
        bl xxxx <foo>   --->(a)
        ...
        <foo>
        xxxx: push    {r7, lr}

GNU linker on finding out "foo" is a cmse secure entry function, created sg and b.w instructions and
place them in ".gnu.sgstubs" section (marked by c).

The "bl" instruction (marked by a) which is a call to cmse secure entry function is modified by GNU linker
(as marked by b) and call flow is re-directly through secure gateway (sg) in ".gnu.sgstubs" section.
       ...
       bl yyyy <foo>  ---> (b)
       ...
       section .gnu.sgstubs: ---> (c)
       yyyy <foo>
       yyyy: sg   // secure gateway
	     b.w xxxx <__acle_se_foo>  // original_branch_dest
       ...
       0000xxxx <__acle_se_foo>
       xxxx: push    {r7, lr} ---> (d)

On invoking GDB, when the control is at "b" and we pass "step" command, the pc returns "yyyy"
(sg address) which is a trampoline and which does not exist in source code. So GDB jumps
to next line without jumping to "__acle_se_foo" (marked by d).

The above details are published on the Arm website [1], please refer to section 5.4 (Entry functions)
and section 3.4.4 (C level development flow of secure code).

[1] https://developer.arm.com/architectures/cpu-architecture/m-profile/docs/ecm0359818/latest/armv8-m-security-extensions-requirements-on-development-tools-engineering-specification

This patch fixes above problem by returning target pc "xxxx" to GDB on executing "step"
command at "b", so that the control jumps to "__acle_se_foo" (marked by d).

gdb/ChangeLog:

	* arm-tdep.c (arm_skip_cmse_entry): New function.
	(arm_is_sgstubs_section): New function.
	(arm_skip_stub): Add call to arm_skip_cmse_entry function.

gdb/testsuite/ChangeLog:

	* gdb.arch/arm-cmse-sgstubs.c: New test.
	* gdb.arch/arm-cmse-sgstubs.exp: New file.
2019-07-23 12:06:05 +01:00
Tom de Vries 5ba2943476 [gdb/testsuite] Fix command result testing in mi-complete.exp
When running gdb.mi/mi-complete.exp in conjunction with:
...
$ stress -c $(($(cat /proc/cpuinfo | grep -c "^processor") + 1))
...
we get less than 50% full passes:
...
$ for n in  $(seq 1 100); do \
    make V=1 -O check \
      'RUNTESTFLAGS=gdb.mi/mi-complete.exp --target_board=unix'; \
  done 2>&1 \
  | grep "expected passes" | sort | uniq -c
     45 # of expected passes            7
      9 # of expected passes            8
     46 # of expected passes            9
...

A diff between a passing and failing gdb.log shows this difference:
...
-&"set max-completions 1\n"
 2-complete br
+&"set max-completions 1\n"
...

The problem is that the test-case issues the "set max-completion <n>" command,
and without waiting for the output issues a next command, and tries to parse
the results of both commands, expecting a specific interleaving of the various
output streams.

Fix the FAIL by waiting for the result of the "set max-completion <n>" command
before issuing another command.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-07-23  Tom de Vries  <tdevries@suse.de>

	PR testsuite/24711
	* gdb.mi/mi-complete.exp: Wait for "set max-completions" result before
	issuing next command.
2019-07-23 10:38:33 +02:00
Tom Tromey bfa2a36d94 Remove self-assign from make_invisible_and_set_new_height
In https://sourceware.org/ml/gdb-patches/2019-07/msg00509.html, Jan
pointed out that clang points out that
make_invisible_and_set_new_height self-assigns "height".

This patch fixes the bug by renaming the formal parameter.

gdb/ChangeLog
2019-07-22  Tom Tromey  <tom@tromey.com>

	* tui/tui-win.c (tui_win_info::make_invisible_and_set_new_height):
	Don't self-assign.
2019-07-22 08:34:25 -06:00
Andrew Burgess a8e9d24718 gdb: Show type summary for anonymous structures from c_print_typedef
Currently each language has a la_print_typedef method, this is only
used for the "info types" command.

The documentation for "info types" says:

   Print a brief description of all types whose names match the regular
   expression @var{regexp} (or all types in your program, if you supply
   no argument).

However, if we consider this C code:

   typedef struct {
     int a;
   } my_type;

Then currently with "info types" this will be printed like this:

   3:      typedef struct {
       int a;
   } my_type;

I see two problems with this, first the indentation is clearly broken,
second, if the struct contained more fields then it feels like the
actual type names could easily get lost in the noise.

Given that "info types" is about discovering type names, I think there
is an argument to be made that we should focus on giving _only_ the
briefest summary for "info types", and if the user wants to know more
they can take the type name and plug it into "ptype".  As such, I
propose that a better output would be:

   3:      typedef struct {...} my_type;

The user understands that there is a type called `my_type`, and that
it's an alias for an anonymous structure type.

The change to achieve this turns out to be pretty simple, but only
effects languages that make use of c_print_typedef, which are C, C++,
asm, minimal, d, go, objc, and opencl.  Other languages will for now
do whatever they used to do.

The patch to change how anonymous structs are displayed also changes
the display of anonymous enums, consider this code sample:

   typedef enum {
     AA, BB, CC
   } anon_enum_t;

This used to be displayed like this:

   3:      typedef enum {AA, BB, CC} anon_enum_t;

Which will quickly become cluttered for enums with a large number of
values.  The modified output looks like this:

   3:      typedef enum {...} anon_enum_t;

Again, the user can always make use of ptype if they want to see the
details of the anon_enum_t type.

It is worth pointing out that this change (to use {...}) only effects
anonymous structs and enums, named types don't change with this patch,
consider this code:

   struct struct_t {
     int i;
   };
   enum enum_t {
    AA, BB, CC
   };

The output from 'info types' remains unchanged, like this:

   4:      enum enum_t;
   1:      struct struct_t;

An additional area of interest is how C++ handles anonymous types used
within a typedef; enums are handled basically inline with how C
handles them, but structs (and classes) are slightly different.  The
behaviour before the patch is different, and is unchanged by this
patch.  Consider this code compiled for C++:

   typedef struct {
     int i;
   } struct_t;

Both before and after this patch, this is show by 'info types' as:

   3:      typedef struct_t struct_t;

Unions are displayed similarly to structs in both C and C++, the
handling of anonymous unions changes for C in the same way that
it changes for anonymous structs.

I did look at ada, as this is the only language to actually have some
tests for "info types", however, as I understand it ada doesn't really
support typedefs, however, by forcing the language we can see what ada
would print.  So, if we 'set language ada', then originally we printed
this:

   3:      record
       a: int;
   end record

Again the indentation is clearly broken, but we also have no mention
of the type name at all, which is odd, but understandable given the
lack of typedefs.  If I make a similar change as I'm proposing for C,
then we now get this output:

   3:      record ... end record

Which is even less informative I think.  However, the original output
_is_ tested for in gdb.ada/info_auto_lang.exp, and its not clear to me
if the change is a good one or not, so for now I have left this out.

gdb/ChangeLog:

	* c-typeprint.c (c_print_typedef): Pass -1 instead of 0 to
	type_print.

gdb/testsuite/ChangeLog:

	* gdb.ada/info_auto_lang.exp: Update expected results.
	* gdb.base/info-types.c: Add additional types to check.
	* gdb.base/info-types.exp: Update expected results.
2019-07-22 10:43:03 +01:00
Andrew Burgess eb86c5e2e8 gdb: Improve output from "info types" commad
This commit makes two changes to the "info types" command:

First, only use typedef_print for printing typedefs, and use
type_print for printing non-typedef scalar (non-struct) types.  The
result of this is the output for builtin types goes from this:

    typedef double;
    typedef float;
    typedef int;

to this:

    double;
    float;
    int;

which seems to make more sense.

Next GDB no longer matches msymbols as possible type names.  When
looking for function symbols it makes sense to report matching
msymbols from the text sections, and for variables msymbols from the
data/bss sections, but when reporting types GDB would match msymbols
of type absolute.  But I don't see why these are likely to indicate
type names.  As such I've updated the msymbol matching lists in
symtab.c:search_symbols so that when searching in the TYPES_DOMAIN, we
never match any msymbols.

gdb/ChangeLog:

	* symtab.c (search_symbols): Adjust msymbol matching type arrays
	so that GDB doesn't match any msymbols when searching in the
	TYPES_DOMAIN.
	(print_symbol_info): Print using typedef_print or type_print based
	on the type of the symbol.  Add updated FIXME comment moved from...
	(_initialize_symtab): ... move and update FIXME comment to above.

gdb/testsuite/ChangeLog:

	* gdb.base/info-types.c: New file.
	* gdb.base/info-types.exp: New file.
2019-07-22 10:43:02 +01: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
Christian Biesinger b4603c3464 Add ChangeLog entry for the last commit
Forgot to commit before pushing :(
2019-07-21 22:27:07 -05:00
Christian Biesinger c32e6a04f4 Use block_enum instead of int for better typesafety
gdb/ChangeLog:

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

	* symtab.c (lookup_symbol_in_objfile_symtabs): Change int to block_enum.
	(lookup_symbol_in_objfile): Change int to block_enum and add a
	gdb_assert to make sure block_index is GLOBAL_BLOCK or STATIC_BLOCK.
2019-07-21 22:23:12 -05:00
Christian Biesinger c8cdc1e083 [FYI] Add myself to gdb/MAINTAINERS
gdb/Changelog:

	* MAINTAINERS (Write After Approval): Add myself.
2019-07-21 22:00:22 -05:00