Commit Graph

29817 Commits

Author SHA1 Message Date
Pedro Alves 087e161b3c Don't write to inferior_ptid in tracefile-tfile.c
gdb/ChangeLog:
2020-06-18  Pedro Alves  <palves@redhat.com>

	* tracefile-tfile.c (tfile_target_open): Don't write to
	inferior_ptid directly, instead switch to added thread.
	(tfile_target::close): Use switch_to_no_thread instead of writing
	to inferior_ptid directly.
2020-06-18 23:06:57 +01:00
Pedro Alves 7fb43e53d5 Don't write to inferior_ptid in procfs.c
The inferior_ptid write in procfs_do_thread_registers should be
unnecessary because the target_fetch_registers method should (and
does) extract the ptid from the regcache.

Not tested.

gdb/ChangeLog:
2020-06-18  Pedro Alves  <palves@redhat.com>

	* procfs.c (procfs_target::attach): Don't write to inferior_ptid.
	(procfs_target::detach): Use switch_to_no_thread
	instead of writing to inferior_ptid directly.
	(do_attach): Change return type to void.  Switch to the added
	thread.
	(procfs_target::create_inferior): Switch to the added thread.
	(procfs_do_thread_registers): Don't write to inferior_ptid.
2020-06-18 23:06:03 +01:00
Pedro Alves 18493a005a Don't write to inferior_ptid in infrun.c
gdb/ChangeLog:
2020-06-18  Pedro Alves  <palves@redhat.com>

	* infrun.c (generic_mourn_inferior): Use switch_to_thread instead
	of writing to inferior_ptid.
	(scoped_restore_exited_inferior): Delete.
	(handle_vfork_child_exec_or_exit): Simplify using
	scoped_restore_current_pspace_and_thread.  Use switch_to_thread
	instead of writing to inferior_ptid.
	(THREAD_STOPPED_BY): Delete.
	(thread_stopped_by_watchpoint, thread_stopped_by_sw_breakpoint)
	(thread_stopped_by_hw_breakpoint): Delete.
	(save_waitstatus): Use
	scoped_restore_current_thread+switch_to_thread, and call
	target_stopped_by_watchpoint instead of
	thread_stopped_by_watchpoint, target_stopped_by_sw_breakpoint
	instead of thread_stopped_by_sw_breakpoint, and
	target_stopped_by_hw_breakpoint instead of
	thread_stopped_by_hw_breakpoint.
	(handle_inferior_event)
	<TARGET_WAITKIND_EXITED/TARGET_WAITKIND_SIGNALLED>: Don't write to
	inferior_ptid directly, nor
	set_current_inferior/set_current_program_space.  Use
	switch_to_thread / switch_to_inferior_no_thread instead.
2020-06-18 23:05:18 +01:00
Pedro Alves a0776b131d Don't write to inferior_ptid in target.c
gdb/ChangeLog:
2020-06-18  Pedro Alves  <palves@redhat.com>

	* target.c (generic_mourn_inferior): Use switch_to_no_thread
	instead of writing to inferior_ptid.
2020-06-18 23:04:50 +01:00
Pedro Alves 6155c136cc Don't write to inferior_ptid in inf-ptrace.c
gdb/ChangeLog:
2020-06-18  Pedro Alves  <palves@redhat.com>

	* inf-ptrace.c (inf_ptrace_target::create_inferior): Switch to the
	added thread.
	(inf_ptrace_target::attach): Don't write to inferior_ptid.  Switch
	to the added thread.
	(inf_ptrace_target::detach_success): Use switch_to_no_thread
	instead of writing to inferior_ptid.
2020-06-18 23:04:17 +01:00
Pedro Alves c5316fc6e6 Don't write to inferior_ptid in gdbarch-selftests.c, mock address_space too
Use switch_to_thread instead of writing to inferior_ptid.  This
requires a couple of improvements to the mocking environment.  One is
to mock a pspace too, and assigning it to the inferior.  In turn, this
requires heap-allocating the address space, so that the regular
program_space dtor destroys the address space correctly.

(Note that new the mock program_space is allocated on the stack, and
thus depends on the previous patch that eliminated
delete_program_space.)

gdb/ChangeLog:
2020-06-18  Pedro Alves  <palves@redhat.com>

	* gdbarch-selftests.c: Include "progspace-and-thread.h".
	(register_to_value_test): Mock a program_space too.  Heap-allocate
	the address space.  Don't write to inferior_ptid.  Use
	switch_to_thread instead.
2020-06-18 23:03:47 +01:00
Pedro Alves 8df017996f gcore, handle exited threads better
An early (and since discarded) version of this series tried to make
exited threads have distinct PTID between each other, and that change
exposed a problem in linux-tdep.c...  This was exposed by the
gdb.threads/gcore-stale-thread.exp testcase, which is exactly about
calling gcore with an exited thread selected:

 (gdb) [Thread 0x7ffff7fb6740 (LWP 31523) exited]
 PASS: gdb.threads/gcore-stale-thread.exp: continue to breakpoint: break-here
 gcore /home/pedro/gdb/binutils-gdb/build/gdb/testsuite/outputs/gdb.threads/gcore-stale-thread/gcore-stale-thread.core
 /home/pedro/gdb/binutils-gdb/build/../src/gdb/inferior.c:66: internal-error: void set_current_inferior(inferior*): Assertion `inf != NULL' failed.
 A problem internal to GDB has been detected,

That was find_inferior_ptid being called on the "exited" ptid, which
on that previous (and discarded attempt) had pid==-1.  The problem is
that linux-tdep.c, where it looks for the signalled thread, isn't
considering exited threads.  Also, while at it, that code isn't
considering multi-target either, since it is using
iterate_over_threads which iterates over all threads of all targets.
Fixed by switching to range-for iteration instead.

gdb/ChangeLog:
2020-06-18  Pedro Alves  <palves@redhat.com>

	* linux-tdep.c (find_signalled_thread(thread_info *,void *)):
	Delete.
	(find_signalled_thread()): New, factored out from
	linux_make_corefile_notes and adjusted to handle exited threads.
	(linux_make_corefile_notes): Adjust to use the new
	find_signalled_thread.
2020-06-18 23:03:08 +01:00
Pedro Alves 41792d688a Don't write to inferior_ptid in linux_get_siginfo_data
gdb/ChangeLog:
2020-06-18  Pedro Alves  <palves@redhat.com>

	* linux-tdep.c (btrace_fetch): Save/restore current thread instead
	of saving/restoring inferior_ptid.
2020-06-18 21:28:17 +01:00
Tom Tromey 612f258a49 Remove unnecessary TUI declarations
I found some unnecessary declarations (and one unused macro) in the
TUI.  This patch removes them.

gdb/ChangeLog
2020-06-17  Tom Tromey  <tom@tromey.com>

	* tui/tui-win.h (tui_scroll_forward, tui_scroll_backward)
	(tui_scroll_left, tui_scroll_right, struct tui_win_info): Don't
	declare.
	* tui/tui-data.h (MIN_CMD_WIN_HEIGHT): Remove.
2020-06-17 20:07:04 -06:00
Simon Marchi efb763a5ea gdb: check for partial symtab presence in dwarf2_initialize_objfile
This patch fixes an internal error that is triggered when loading the
same binary twice with the index-cache on:

    $ ./gdb -q -nx --data-directory=data-directory
    (gdb) set index-cache on
    (gdb) shell mktemp -d
    /tmp/tmp.BLgouVoPq4
    (gdb) set index-cache directory /tmp/tmp.BLgouVoPq4
    (gdb) file a.out
    Reading symbols from a.out...
    (gdb) file a.out
    Load new symbol table from "a.out"? (y or n) y
    Reading symbols from a.out...
    /home/smarchi/src/binutils-gdb/gdb/dwarf2/read.c:2540: internal-error: void create_cus_from_index(dwarf2_per_bfd*, const gdb_byte*, offset_type, const gdb_byte*, offset_type): Assertion `per_bfd->all_comp_units.empty ()' failed.
    A problem internal to GDB has been detected,
    further debugging may prove unreliable.
    Quit this debugging session? (y or n)

This is what happens:

1. We load the binary the first time, partial symtabs are created,
   per_bfd->all_comp_units is filled from those.
2. Because index-cache is on, we also generate an index in the cache.
3. We load the binary a second time, in dwarf2_initialize_objfile we
   check: was an index already loaded for this BFD?  No, so we try to
   read the index and fill the per-bfd using it.  We do find an index,
   it's in the cache.
4. The function create_cus_from_index asserts (rightfully) that
   per_cu->all_comp_units is empty, and the assertion fails.

This assertion verifies that we are not reading an index for a BFD for
which we have already built partial symtabs or read another index.

The index-cache gives a situation that isn't currently accounted for: a
BFD for which we have built the partial symtabs the first time, but has
an index the second time.

This patch addresses it by checking for the presence of partial symtabs
in dwarf2_initialize_objfile.  If there are, we don't try reading the
index.

gdb/ChangeLog:

	* dwarf2/read.c (dwarf2_initialize_objfile): Check for presence
	of partial symtabs.

gdb/testsuite/ChangeLog:

	* gdb.base/index-cache-load-twice.c: New.
	* gdb.base/index-cache-load-twice.exp: New.

Change-Id: Ie05474c44823fcdff852b73170dd28dfd66cb6a2
2020-06-17 14:49:33 -04:00
Simon Marchi 2951f6c068 gdb/regformats: remove unused regformats/reg-*.dat
I believe that the .dat files starting with `reg-` are the manually
written ones, the other being generated from xml files from the features
directory.

This patch removes the manually-written files that are no longer needed.
They are unused since the recent series that removed a bunch of
gdbserver ports.

gdb/ChangeLog:

	* regformats/reg-arm.dat: Remove.
	* regformats/reg-bfin.dat: Remove.
	* regformats/reg-cris.dat: Remove.
	* regformats/reg-crisv32.dat: Remove.
	* regformats/reg-m32r.dat: Remove.
	* regformats/reg-tilegx.dat: Remove.
	* regformats/reg-tilegx32.dat: Remove.

Change-Id: I55ab6e45e3d0d316cda93f863c51fc9b867adfaa
2020-06-17 14:42:54 -04:00
Simon Marchi 7d458ea516 gdb, gdbserver: remove ARM regdat files
This patch removes the leftover regformats .dat files for the arm
architecture.  There are no longer relevant, since the arm architecture
has been converted to use feature-based target-descriptions.  These .dat
files are used by GDBserver ports that still use static target
descriptions.

These .dat files are generated from corresponding .xml files in the
features directory.  And since the corresponding .xml files for these
arm .dat files don't exist anymore, it is impossible to re-generated
them.  If you delete these .dat files and type "make" in the features
directory, you'll get:

  make: *** No rule to make target '../regformats/arm/arm-with-iwmmxt.dat', needed by 'all'.  Stop.

So it removes the entries in the `WHICH` variable of
gdb/features/Makefile.

Finally, it removes the rule in gdbserver/Makefile to generate .cc files
from `../gdb/regformats/arm/%.dat`.

gdb/ChangeLog:

	* features/Makefile (WHICH): Remove arm files.
	* regformats/arm/arm-with-iwmmxt.dat: Remove.
	* regformats/arm/arm-with-neon.dat: Remove.
	* regformats/arm/arm-with-vfpv2.dat: Remove.
	* regformats/arm/arm-with-vfpv3.dat: Remove.

gdbserver/ChangeLog:

	* Makefile.in (%-generated.cc: ../gdb/regformats/arm/%.dat):
	Remove.

Change-Id: I3b7d989c50e2cb92235c1f7c7071a26839d84c78
2020-06-17 14:42:53 -04:00
Simon Marchi 3af96c0d99 gdb/features: remove rx.xml from XMLTOC list
When trying to run `make` in the features directory, in a clean repo, we
get:

    Makefile:254: warning: overriding recipe for target 'rx.c'
    Makefile:250: warning: ignoring old recipe for target 'rx.c'
    make: Nothing to be done for 'all'.

The warnings come from the fact that `rx.xml` is present in two lists,
causing two `rx.c` targets to be defined.  It is ok for it to be in the
FEATURES_XMLFILES list, as this architecture uses the "feature-based"
target-descriptions.  It shouldn't be in the XMLTOC list, as this is for
architectures that define complete/static target descriptions as XML
files.

gdb/ChangeLog:

	* features/Makefile (XMLTOC): Remove rx.xml.

Change-Id: Iada4ab54b3d4542588fac543d16ee35a92537319
2020-06-17 14:42:51 -04:00
Pedro Alves b25e22fd16 Update thread_control_state::trap_expected comments
The comments describing trap_expected are out of date.  It
predates displaced stepping and non-stop mode ("keep other threads
stopped").  It predates stepping over watchpoints with breakpoints
inserted (keep_going_pass_signal).  Says the variable is cleared
in normal_stop, when it isn't.  This fixes it.

gdb/ChangeLog:
2020-06-17  Pedro Alves  <palves@redhat.com>

	* gdbthread.h (thread_control_state) <trap_expected> Update
	comments.
2020-06-17 11:56:43 +01:00
Andrew Burgess a78a19b152 gdb: Convert language la_lookup_symbol_nonlocal field to a method
This commit changes the language_data::la_lookup_symbol_nonlocal
function pointer member variable into a member function of
language_defn.

There should be no user visible changes after this commit.

gdb/ChangeLog:

	* ada-lang.c (ada_lookup_symbol_nonlocal): Rename to
	ada_language::lookup_symbol_nonlocal.
	(ada_language_data): Delete la_lookup_symbol_nonlocal initializer.
	(ada_language::lookup_symbol_nonlocal): New member function,
	implementation from ada_lookup_symbol_nonlocal.
	* c-lang.c (c_language_data): Delete la_lookup_symbol_nonlocal
	initializer.
	(cplus_language_data): Delete la_lookup_symbol_nonlocal
	initializer.
	(cplus_language::lookup_symbol_nonlocal): New member function.
	(asm_language_data): Delete la_lookup_symbol_nonlocal initializer.
	(minimal_language_data) Likewise.
	* cp-namespace.c (cp_lookup_nested_symbol): Update comment.
	* d-lang.c (d_language_data): Delete la_lookup_symbol_nonlocal
	initializer.
	(d_language::lookup_symbol_nonlocal): New member function.
	* f-lang.c (f_language_data): Delete la_lookup_symbol_nonlocal
	initializer.
	(f_language::lookup_symbol_nonlocal): New member function.
	* go-lang.c (go_language_data): Delete la_lookup_symbol_nonlocal
	initializer.
	* language.c (unknown_language_data): Likewise.
	(auto_language_data): Likewise.
	* language.h (language_data): Delete la_lookup_symbol_nonlocal
	field.
	(language_defn::lookup_symbol_nonlocal): New member function.
	* m2-lang.c (m2_language_data): Delete la_lookup_symbol_nonlocal
	initializer.
	* objc-lang.c (objc_language_data): Likewise.
	* opencl-lang.c (opencl_language_data): Likewise.
	* p-lang.c (pascal_language_data): Likewise.
	* rust-lang.c (rust_lookup_symbol_nonlocal): Rename to
	rust_language::lookup_symbol_nonlocal.
	(rust_language_data): Delete la_lookup_symbol_nonlocal
	initializer.
	(rust_language::lookup_symbol_nonlocal): New member function,
	implementation from rust_lookup_symbol_nonlocal.
	* symtab.c (lookup_symbol_aux): Update call to
	lookup_symbol_nonlocal.
	(basic_lookup_symbol_nonlocal): Rename to...
	(language_defn::lookup_symbol_nonlocal): ...this, and update
	header comment.  Remove language_defn parameter, and replace with
	uses of `this'.
	* symtab.h (basic_lookup_symbol_nonlocal): Delete declaration.
2020-06-17 09:25:12 +01:00
Andrew Burgess ebe2334ee6 gdb: Convert language la_value_print_inner field to a method
This commit changes the language_data::la_value_print_inner function
pointer member variable into a member function of language_defn.

There should be no user visible changes after this commit.

gdb/ChangeLog:

	* ada-lang.c (ada_language_data): Delete la_value_print_inner
	initializer.
	(ada_language::value_print_inner): New member function.
	* c-lang.c (c_language_data): Delete la_value_print_inner
	initializer.
	(cplus_language_data): Likewise.
	(asm_language_data): Likewise.
	(minimal_language_data): Likewise.
	* d-lang.c (d_language_data): Likewise.
	(d_language::value_print_inner): New member function.
	* f-lang.c (f_language_data): Delete la_value_print_inner
	initializer.
	(f_language::value_print_inner): New member function.
	* f-lang.h (f_value_print_innner): Rename to...
	(f_value_print_inner): ...this (note spelling of 'inner').
	* f-valprint.c (f_value_print_innner): Rename to...
	(f_value_print_inner): ...this (note spelling of 'inner').
	* go-lang.c (go_language_data): Delete la_value_print_inner
	initializer.
	(go_language::value_print_inner): New member function.
	* language.c (language_defn::value_print_inner): Define new member
	function.
	(unk_lang_value_print_inner): Delete.
	(unknown_language_data): Delete la_value_print_inner initializer.
	(unknown_language::value_print_inner): New member function.
	(auto_language_data): Delete la_value_print_inner initializer.
	(auto_language::value_print_inner): New member function.
	* language.h (language_data): Delete la_value_print_inner field.
	(language_defn::value_print_inner): Delcare new member function.
	* m2-lang.c (m2_language_data): Delete la_value_print_inner
	initializer.
	(m2_language::value_print_inner): New member function.
	* objc-lang.c (objc_language_data): Delete la_value_print_inner
	initializer.
	* opencl-lang.c (opencl_language_data): Likewise.
	* p-lang.c (pascal_language_data): Likewise.
	(pascal_language::value_print_inner): New member function.
	* rust-lang.c (rust_language_data): Delete la_value_print_inner
	initializer.
	(rust_language::value_print_inner): New member function.
	* valprint.c (do_val_print): Update call to value_print_inner.
2020-06-17 09:25:11 +01:00
Andrew Burgess a1d1fa3e41 gdb: Convert language la_value_print field to a method
This commit changes the language_data::la_value_print function pointer
member variable into a member function of language_defn.

There should be no user visible changes after this commit.

gdb/ChangeLog:

	* ada-lang.c (ada_language_data): Delete la_value_print
	initializer.
	(ada_language::value_print): New member function.
	* c-lang.c (c_language_data): Delete la_value_print initializer.
	(cplus_language_data): Likewise.
	(asm_language_data): Likewise.
	(minimal_language_data): Likewise.
	* d-lang.c (d_language_data): Likewise.
	* f-lang.c (f_language_data): Likewise.
	* go-lang.c (go_language_data): Likewise.
	* language.c (unk_lang_value_print): Delete.
	(language_defn::value_print): Define new member function.
	(unknown_language_data): Delete la_value_print initializer.
	(unknown_language::value_print): New member function.
	(auto_language_data): Delete la_value_print initializer.
	(auto_language::value_print): New member function.
	* language.h (language_data): Delete la_value_print field.
	(language_defn::value_print): Declare new member function.
	(LA_VALUE_PRINT): Update call to value_print.
	* m2-lang.c (m2_language_data): Delete la_value_print initializer.
	* objc-lang.c (objc_language_data): Likewise.
	* opencl-lang.c (opencl_language_data): Likewise.
	* p-lang.c (pascal_language_data): Likewise.
	(pascal_language::value_print): New member function.
	* rust-lang.c (rust_language_data): Delete la_value_print
	initializer.
2020-06-17 09:25:11 +01:00
Andrew Burgess f16a9f57b5 gdb: Convert language la_watch_location_expression field to a method
This commit changes the language_data::la_watch_location_expression
function pointer member variable into a member function of
language_defn.

There should be no user visible changes after this commit.

gdb/ChangeLog:

	* ada-lang.c (ada_watch_location_expression): Rename to
	ada_language::watch_location_expression.
	(ada_language_data): Delete la_watch_location_expression
	initializer.
	(ada_language::watch_location_expression): New member function,
	implementation from ada_watch_location_expression.
	* breakpoint.c (watch_command_1): Update call to
	watch_location_expression.
	* c-lang.c (c_watch_location_expression): Rename to
	language_defn::watch_location_expression.
	(c_language_data): Delete la_watch_location_expression
	initializer.
	(cplus_language_data): Likewise.
	(asm_language_data): Likewise.
	(minimal_language_data): Likewise.
	* c-lang.h (c_watch_location_expression): Delete declaration.
	* d-lang.c (d_language_data): Delete la_watch_location_expression
	initializer.
	* f-lang.c (f_language_data): Likewise.
	* go-lang.c (go_language_data): Likewise.
	* language.c (language_defn::watch_location_expression): Member
	function implementation from c_watch_location_expression.
	(unknown_language_data): Delete la_watch_location_expression
	initializer.
	(auto_language_data): Likewise.
	* language.h (language_data): Delete la_watch_location_expression
	field.
	(language_defn::watch_location_expression): Declare new member
	function.
	* m2-lang.c (m2_language_data): Delete
	la_watch_location_expression initializer.
	* objc-lang.c (objc_language_data): Likewise.
	* opencl-lang.c (opencl_language_data): Likewise.
	* p-lang.c (pascal_language_data): Likewise.
	* rust-lang.c (rust_watch_location_expression): Rename to
	rust_language::watch_location_expression.
	(rust_language_data): Delete la_watch_location_expression
	initializer.
	(rust_language::watch_location_expression): New member function,
	implementation from rust_watch_location_expression.
2020-06-17 09:25:11 +01:00
Andrew Burgess 7e56227dff gdb: Convert language la_collect_symbol_completion_matches field to a method
This commit changes the
language_data::la_collect_symbol_completion_matches function pointer
member variable into a member function of language_defn.

There should be no user visible changes after this commit.

gdb/ChangeLog:

	* ada-lang.c (ada_collect_symbol_completion_matches): Rename to
	ada_language::collect_symbol_completion_matches.
	(ada_language_data): Delete la_collect_symbol_completion_matches
	initializer.
	(ada_language::collect_symbol_completion_matches): New member
	function, implementation from
	ada_collect_symbol_completion_matches.
	* c-lang.c (c_language_data): Delete
	la_collect_symbol_completion_matches initializer.
	(cplus_language_data): Likewise.
	(asm_language_data): Likewise.
	(minimal_language_data): Likewise.
	* d-lang.c (d_language_data): Likewise.
	* f-lang.c (f_collect_symbol_completion_matches): Rename to
	f_language::collect_symbol_completion_matches.
	(f_language_data): Delete la_collect_symbol_completion_matches
	initializer.
	(f_language::collect_symbol_completion_matches) New member
	function, implementation from f_collect_symbol_completion_matches.
	* go-lang.c (go_language_data): Delete
	la_collect_symbol_completion_matches initializer.
	* language.c (unknown_language_data): Likewise.
	(auto_language_data): Likewise.
	* language.h (language_data): Delete
	la_collect_symbol_completion_matches field.
	(language_defn::collect_symbol_completion_matches): New member
	function.
	* m2-lang.c (m2_language_data): Delete
	la_collect_symbol_completion_matches initializer.
	* objc-lang.c (objc_language_data): Likewise.
	* opencl-lang.c (opencl_language_data): Likewise.
	* p-lang.c (pascal_language_data): Likewise.
	* rust-lang.c (rust_language_data): Likewise.
	* symtab.c (default_collect_symbol_completion_matches): Delete.
	(collect_symbol_completion_matches): Update call to
	collect_symbol_completion_matches.
	(collect_symbol_completion_matches_type): Likewise.
	* symtab.h (default_collect_symbol_completion_matches): Delete
	declaration.
2020-06-17 09:25:10 +01:00
Andrew Burgess 53fc67f8b2 gdb: Convert language la_word_break_characters field to a method
This commit changes the language_data::la_word_break_characters
function pointer member variable into a member function of
language_defn.

There should be no user visible changes after this commit.

gdb/ChangeLog:

	* ada-lang.c (ada_get_gdb_completer_word_break_characters): Delete.
	(ada_language_data): Delete la_word_break_characters initializer.
	(ada_language::word_break_characters): New member function.
	* c-lang.c (c_language_data): Delete la_word_break_characters
	initializer.
	(cplus_language_data): Likewise.
	(asm_language_data): Likewise.
	(minimal_language_data): Likewise.
	* completer.c: Update global comment.
	(advance_to_expression_complete_word_point): Update call to
	word_break_characters.
	(complete_files_symbols): Likewise.
	(complete_line_internal_1): Likewise.
	(default_completer_handle_brkchars): Likewise.
	(skip_quoted_chars): Likewise.
	* d-lang.c (d_language_data): Delete la_word_break_characters
	initializer.
	* f-lang.c (f_word_break_characters): Delete.
	(f_language_data): Delete la_word_break_characters initializer.
	(f_language::word_break_characters): New member function.
	* go-lang.c (go_language_data): Delete la_word_break_characters
	initializer.
	* language.c (unknown_language_data): Likewise.
	(auto_language_data): Likewise.
	* language.h (default_word_break_characters): Move declaration to
	earlier in the file.
	(language_data): Delete la_word_break_characters field.
	(language_defn::word_break_characters): New member function.
	* m2-lang.c (m2_language_data): Delete la_word_break_characters
	initializer.
	* objc-lang.c (objc_language_data): Likewise.
	* opencl-lang.c (opencl_language_data): Likewise.
	* p-lang.c (pascal_language_data): Likewise.
	* rust-lang.c (rust_language_data): Likewise.
2020-06-17 09:25:10 +01:00
Andrew Burgess c9debfb97e gdb: Convert language la_get_symbol_name_matcher field to a method
This commit changes the language_data::la_get_symbol_name_matcher
function pointer member variable into a member function of
language_defn.

There should be no user visible changes after this commit.

Before this commit access to the la_get_symbol_name_matcher function
pointer was through the get_symbol_name_matcher function, which looked
something like this (is pseudo-code):

  <return-type>
  get_symbol_name_matcher (language_defn *lang, <other args>)
  {
    if (current_language == ada)
      current_language->la_get_symbol_name_matcher (<other args>);
    else
      lang->la_get_symbol_name_matcher (<other args>);
  }

In this commit I moved the get_symbol_name_matcher as a non-virtual
function in the language_defn base class, I then add a new virtual
method that is only used from within get_symbol_name_matcher, this can
then be overridden by specific languages as needed.  So we now have:

  class language_defn
  {
    <return-type> get_symbol_name_matcher (<args>)
    {
      if (current_language == ada)
        return current_language->get_symbol_name_matcher_inner (<args>);
      else
        return this->get_symbol_name_matcher_inner (<args>);
    }

    virtual <return-type> get_symbol_name_matcher_inner (<args>)
    {
        ....
    }
  }

gdb/ChangeLog:

	* ada-lang.c (ada_get_symbol_name_matcher): Update header comment.
	(ada_language_data): Delete la_get_symbol_name_matcher
	initializer.
	(language_defn::get_symbol_name_matcher_inner): New member
	function.
	* c-lang.c (c_language_data): Delete la_get_symbol_name_matcher
	initializer.
	(cplus_language_data): Likewise.
	(cplus_language::get_symbol_name_matcher_inner): New member
	function.
	(asm_language_data): Delete la_get_symbol_name_matcher initializer.
	(minimal_language_data): Likewise.
	* cp-support.h (cp_get_symbol_name_matcher): Update header comment.
	* d-lang.c (d_language_data): Delete la_get_symbol_name_matcher
	initializer.
	* dictionary.c (iter_match_first_hashed): Update call to
	get_symbol_name_matcher.
	(iter_match_next_hashed): Likewise.
	(iter_match_next_linear): Likewise.
	* dwarf2/read.c (dw2_expand_symtabs_matching_symbol): Likewise.
	* f-lang.c (f_language_data): Delete la_get_symbol_name_matcher
	initializer.
	(f_language::get_symbol_name_matcher_inner): New member function.
	* go-lang.c (go_language_data): Delete la_get_symbol_name_matcher
	initializer.
	* language.c (default_symbol_name_matcher): Update header comment,
	make static.
	(language_defn::get_symbol_name_matcher): New definition.
	(language_defn::get_symbol_name_matcher_inner): Likewise.
	(get_symbol_name_matcher): Delete.
	(unknown_language_data): Delete la_get_symbol_name_matcher
	initializer.
	(auto_language_data): Likewise.
	* language.h (language_data): Delete la_get_symbol_name_matcher
	field.
	(language_defn::get_symbol_name_matcher): New member function.
	(language_defn::get_symbol_name_matcher_inner): Likewise.
	(default_symbol_name_matcher): Delete declaration.
	* linespec.c (find_methods): Update call to
	get_symbol_name_matcher.
	* m2-lang.c (m2_language_data): Delete la_get_symbol_name_matcher
	initializer.
	* minsyms.c (lookup_minimal_symbol): Update call to
	get_symbol_name_matcher.
	(iterate_over_minimal_symbols): Likewise.
	* objc-lang.c (objc_language_data): Delete
	la_get_symbol_name_matcher initializer.
	* opencl-lang.c (opencl_language_data): Likewise.
	* p-lang.c (pascal_language_data): Likewise.
	* psymtab.c (psymbol_name_matches): Update call to
	get_symbol_name_matcher.
	* rust-lang.c (rust_language_data): Delete
	la_get_symbol_name_matcher initializer.
	* symtab.c (symbol_matches_search_name): Update call to
	get_symbol_name_matcher.
	(compare_symbol_name): Likewise.
2020-06-17 09:25:09 +01:00
Andrew Burgess 9a49ad8c52 gdb: Convert language la_compute_program field to a method
This commit changes the language_data::la_compute_program function
pointer member variable into a member function of language_defn.

There should be no user visible changes after this commit.

gdb/ChangeLog:

	* ada-lang.c (ada_language_data): Delete la_compute_program
	initializer.
	* c-lang.c (c_language_data): Likewise.
	(c_language::compute_program): New member function.
	(cplus_language_data): Delete la_compute_program initializer.
	(cplus_language::compute_program): New member function.
	(asm_language_data): Delete la_compute_program initializer.
	(minimal_language_data): Likewise.
	* c-lang.h (c_compute_program): Update comment.
	(cplus_compute_program): Likewise.
	* compile/compile-c-support.c (c_compute_program): Likewise.
	(cplus_compute_program): Likewise.
	* compile/compile.c (compile_to_object): Update call to
	la_compute_program.
	* d-lang.c (d_language_data): Delete la_compute_program
	initializer.
	* f-lang.c (f_language_data): Likewise.
	* go-lang.c (go_language_data): Likewise.
	* language.c (unknown_language_data): Likewise.
	(auto_language_data): Likewise.
	* language.h (language_data): Delete la_compute_program field.
	(language_defn::compute_program): New member function.
	* m2-lang.c (m2_language_data): Delete la_compute_program
	initializer.
	* objc-lang.c (objc_language_data): Likewise.
	* opencl-lang.c (opencl_language_data): Likewise.
	* p-lang.c (pascal_language_data): Likewise.
	* rust-lang.c (rust_language_data): Likewise.
2020-06-17 09:25:09 +01:00
Andrew Burgess eff93b4d48 gdb: Convert language la_class_name_from_physname field to a method
This commit changes the language_data::la_class_name_from_physname function
pointer member variable into a member function of language_defn.

There should be no user visible changes after this commit.

gdb/ChangeLog:

	* ada-lang.c (ada_language_data) Delete
	la_class_name_from_physname initializer.
	* c-lang.c (c_language_data): Likewise.
	(cplus_language_data): Likewise.
	(cplus_language::class_name_from_physname): New member function.
	(asm_language_data): Delete la_class_name_from_physname
	initializer.
	(minimal_language_data): Likewise.
	* d-lang.c (d_language_data): Likewise.
	* dwarf2/read.c (guess_partial_die_structure_name): Update to call
	method on language_defn class.
	(guess_full_die_structure_name): Likewise.
	* f-lang.c (f_language_data): Delete la_class_name_from_physname
	initializer.
	* go-lang.c (go_language_data): Likewise.
	* language.c (language_class_name_from_physname): Delete.
	(unk_lang_class_name): Delete.
	(unknown_language_data): Delete la_class_name_from_physname
	initializer.
	(auto_language_data): Likewise.
	* language.h (language_data): Delete la_class_name_from_physname
	field.
	(language_defn::class_name_from_physname): New function.
	(language_class_name_from_physname): Delete declaration.
	* m2-lang.c (m2_language_data): Delete la_class_name_from_physname
	initializer.
	* objc-lang.c (objc_language_data): Likewise.
	* opencl-lang.c (opencl_language_data): Likewise.
	* p-lang.c (pascal_language_data): Likewise.
	* rust-lang.c (rust_language_data): Likewise.
2020-06-17 09:25:09 +01:00
Tom Tromey de54374205 Use macros for TUI window names
Christian pointed out that tui-layout.c hard-codes various window
names.  This patch changes the code to use the macros from tui-data.h
instead.  For each window, I searched for uses of the name; but I only
found any in tui-layout.c.  This also adds a new macro to account for
the "status" window.

gdb/ChangeLog
2020-06-16  Tom Tromey  <tom@tromey.com>

	* tui/tui-data.h (STATUS_NAME): New macro.
	* tui/tui-layout.c (tui_remove_some_windows)
	(initialize_known_windows, tui_register_window)
	(tui_layout_split::remove_windows, initialize_layouts)
	(tui_new_layout_command): Don't use hard-coded window names.
2020-06-16 18:02:20 -06:00
Tom Tromey a350efd4fb Fix crash when exiting TUI with gdb -tui
PR tui/25348 points out that, when "gdb -tui" is used, then exiting
the TUI will cause a crash.

This happens because tui_setup_io stashes some readline variables --
but because this happens before readline is initialized, some of these
are NULL.  Then, when exiting the TUI, the NULL values are "restored",
causing a crash in readline.

This patch fixes the problem by ensuring that readline is initialized
first.  Back in commit 11061048d ("Give a name to the TUI SingleKey
keymap"), a call to rl_initialize was removed from
tui_initialize_readline; this patch resurrects the call, but moves it
to the end of the function, so as not to remove the ability to modify
the SingleKey map from .inputrc.

gdb/ChangeLog
2020-06-16  Tom Tromey  <tom@tromey.com>

	PR tui/25348:
	* tui/tui.c (tui_ensure_readline_initialized): Rename from
	tui_initialize_readline.  Only run once.  Call rl_initialize.
	* tui/tui.h (tui_ensure_readline_initialized): Rename from
	tui_initialize_readline.
	* tui/tui-io.c (tui_setup_io): Call
	tui_ensure_readline_initialized.
	* tui/tui-interp.c (tui_interp::init): Update.
2020-06-16 18:02:20 -06:00
Tom Tromey 39ec04904f Fix C-x 1 from gdb prompt
Pedro pointed out on irc that C-x 1 from the gdb prompt will cause a
crash.  This happened because of a bug in remove_windows -- it would
always remove all the windows from the layout.  This patch fixes this
bug, and also arranges to have C-x 1 preserve the status window.

gdb/ChangeLog
2020-06-16  Tom Tromey  <tom@tromey.com>

	* tui/tui-layout.c (tui_layout_split::remove_windows): Fix logic.
	Also preserve the status window.
2020-06-16 18:02:20 -06:00
Tom Tromey d2d1ea20ae Fix crash when TUI window creation fails
If a TUI window is written in Python, and if the window construction
function fails, then gdb will crash.  This patch fixes the crash.

gdb/ChangeLog
2020-06-16  Tom Tromey  <tom@tromey.com>

	* python/py-tui.c (tui_py_window::~tui_py_window): Handle case
	where m_window==nullptr.

gdb/testsuite/ChangeLog
2020-06-16  Tom Tromey  <tom@tromey.com>

	* gdb.python/tui-window.py (failwin): New function.  Register it
	as a TUI window type.
	* gdb.python/tui-window.exp: Create new "fail" layout.  Test it.
2020-06-16 17:48:38 -06:00
Tom Tromey 6692031743 Change target_read_string API
This simplifies the target_read_string API a bit.

Note that some code was using safe_strerror on the error codes
returned by target_read_string.  It seems to me that this is incorrect
(if it was ever correct, it must have been quite a long time ago).

gdb/ChangeLog
2020-06-15  Tom Tromey  <tromey@adacore.com>

	* windows-nat.c (windows_nat::handle_output_debug_string):
	Update.
	(windows_nat::handle_ms_vc_exception): Update.
	* target.h (target_read_string): Change API.
	* target.c (target_read_string): Change API.
	* solib-svr4.c (open_symbol_file_object, svr4_read_so_list):
	Update.
	* solib-frv.c (frv_current_sos): Update.
	* solib-dsbt.c (dsbt_current_sos): Update.
	* solib-darwin.c (darwin_current_sos): Update.
	* linux-thread-db.c (inferior_has_bug): Update.
	* expprint.c (print_subexp_standard): Update.
	* ada-lang.c (ada_main_name, ada_tag_name_from_tsd)
	(ada_exception_message_1): Update.
2020-06-15 06:28:10 -06:00
Tom Tromey a5d871ddaf Remove a use of target_read_string
linux-tdep.c:dump_mapping_p uses target_read_string, but in a way that
does not really make sense.  It's better to use target_read_memory
here.

gdb/ChangeLog
2020-06-15  Tom Tromey  <tromey@adacore.com>

	* linux-tdep.c (dump_mapping_p): Use target_read_memory.
2020-06-15 06:28:10 -06:00
Tom Tromey 670e35fad9 Rewrite target_read_string
This rewrites target_read_string in terms of read_string.

gdb/ChangeLog
2020-06-15  Tom Tromey  <tromey@adacore.com>

	* valprint.c (read_string): Update comment.
	* target.c (MIN): Remove.
	(target_read_string): Rewrite.
2020-06-15 06:28:09 -06:00
Tom Tromey f5272a3bb3 Remove read_memory_string
read_memory_string is redundant and only called in a couple of spots.
This patch removes it in favor of target_read_string.

gdb/ChangeLog
2020-06-15  Tom Tromey  <tromey@adacore.com>

	* corefile.c (read_memory_string): Remove.
	* ada-valprint.c (ada_value_print_ptr): Update.
	* ada-lang.h (ada_tag_name): Change return type.
	* ada-lang.c (type_from_tag): Update.
	(ada_tag_name_from_tsd): Change return type.  Use
	target_read_string.
	(ada_tag_name): Likewise.
	* gdbcore.h (read_memory_string): Don't declare.
2020-06-15 06:28:09 -06:00
Hannes Domani 2c074f4902 Handle Windows drives in rbreak paths
Fixes this testsuite fail on Windows:
FAIL: gdb.base/fullpath-expand.exp: rbreak XXX/fullpath-expand-func.c:func

If the found colon is actually part of a Windows drive, look for another.

gdb/ChangeLog:

2020-06-14  Hannes Domani  <ssbssa@yahoo.de>

	* symtab.c (rbreak_command): Ignore Windows drive colon.
2020-06-14 17:38:23 +02:00
Simon Marchi 6a17d503c4 gdb: mention removed GDBserver host support in NEWS
gdb/ChangeLog:

	* NEWS: Mention removed GDBserver host support.

Change-Id: Ib9e212e525d12ac7f3f9b5c056adc5bf9c4d52cd
2020-06-12 16:06:46 -04:00
Nelson Chu 453c733fcf RISC-V: Update the rebuild-csr-xml.sh.
We add new arguments defined and aborted verisons for DECLARE_CSR to
support privileged versions controling in binutils.  Therefore, the
rebuild-csr-xml.sh should be updated, too.

	gdb/
	* features/riscv/rebuild-csr-xml.sh: Updated.
2020-06-12 09:44:02 +08:00
Tom Tromey 2b4e6a3f4b Fix hex floating point lexing
PR gdb/18318 notes that gdb will sometimes incorrectly handle hex
floating point input.  This turns out to be a bug in the C lexer; the
'p' was not being correctly recognized, and so the exponent was not
always passed to the floating point "from_string" method.

Tested by the buildbot "Fedora-x86_64-m64" builder.

gdb/ChangeLog
2020-06-11  Tom Tromey  <tom@tromey.com>

	PR gdb/18318:
	* c-exp.y (lex_one_token): Handle 'p' like 'e'.

gdb/testsuite/ChangeLog
2020-06-11  Tom Tromey  <tom@tromey.com>

	PR gdb/18318:
	* gdb.base/printcmds.exp (test_float_accepted): Add more hex
	floating point tests.
2020-06-11 10:34:31 -06:00
Jonny Grant 4412332f4b gdb: add mailing list and IRC information to --help
A few user-vibisble changes to the --help output:

 * Remove unnecessary quotes around bug url.
 * Mention the mailing list and IRC channel as places where users can
   ask GDB-related questions.
 * Add empty lines between items in the footer, to improve readability.
 * Remove unnecessary new line at the end of output.

2020-06-09  Jonny Grant  <jg@jguk.org>
2020-06-09  Simon Marchi  <simon.marchi@polymtl.ca>

	* main.c (captured_main_1): Don't print new line after help.
	(print_gdb_help): add mailing list and IRC channel information
	to --help.  Add new lines between items in the footer.  Remove
	quotes around bug url.

Signed-off-by: Jonathan Grant <jg@jguk.org>
Change-Id: Ibd0746a348d558fb35b5cd7e366f107742806565
2020-06-11 10:30:36 -04:00
Keith Seitz 2f33032a93 Compute proper length for dynamic types of TYPE_CODE_TYPEDEF
This patch fixes gdb/21356 in which we hit an assertion in
value_contents_bits_eq:

(gdb) p container_object2
(gdb) p container_object2
$1 = {_container_member2 = 15, _vla_struct_object2 = {_some_member = 0,
    _vla_field = {
../../src/gdb/value.c:829: internal-error: \
  int value_contents_bits_eq(const value*, int, const value*, int, int): \
  Assertion `offset1 + length \
             <= TYPE_LENGTH (val1->enclosing_type) * TARGET_CHAR_BIT' failed.

This is happening because TYPE_LENGTH (val1->enclosing_type) is erroneously
based on enclosing_type, which is a typedef, instead of the actual underlying
type.

This can be traced back to resolve_dynamic_struct, where the size of the
type is computed:
...
        TYPE_FIELD_TYPE (resolved_type, i)
          = resolve_dynamic_type_internal (TYPE_FIELD_TYPE (resolved_type, i),
                                           &pinfo, 0);
        gdb_assert (TYPE_FIELD_LOC_KIND (resolved_type, i)
                    == FIELD_LOC_KIND_BITPOS);

        new_bit_length = TYPE_FIELD_BITPOS (resolved_type, i);
        if (TYPE_FIELD_BITSIZE (resolved_type, i) != 0)
          new_bit_length += TYPE_FIELD_BITSIZE (resolved_type, i);
        else
          new_bit_length += (TYPE_LENGTH (TYPE_FIELD_TYPE (resolved_type, i))
                             * TARGET_CHAR_BIT);
...

In this function, resolved_type is TYPE_CODE_TYPEDEF which is not what we
want to use to calculate the size of the actual field.

This patch fixes this and the similar problem in resolve_dynamic_union.

gdb/ChangeLog:
2020-06-11  Keith Seitz  <keiths@redhat.com>

	PR gdb/21356
	* gdbtypes.c (resolve_dynamic_union, resolve_dynamic_struct):
	Resolve typedefs for type length calculations.

gdb/testsuite/ChangeLog:
2020-06-11  Keith Seitz  <keiths@redhat.com>

	PR gdb/21356
	* gdb.base/vla-datatypes.c (vla_factory): Add typedef for struct
	vla_struct.
	Add new struct vla_typedef and union vla_typedef_union and
	corresponding instantiation objects.
	Initialize new objects.
	* gdb.base/vla-datatypes.exp: Add tests for vla_typedef_struct_object
	and vla_typedef_union_object.
	Fixup type for vla_struct_object.
2020-06-11 14:34:44 +02:00
Simon Marchi ec16513e31 gdb: fix whitespaces in ChangeLog
Replace 8 spaces with tabs.

Change-Id: I60f2df3a2866f75f0307077bf6cb1fa3918f8180
2020-06-10 23:00:20 -04:00
Tom de Vries 7ab9679411 [gdb/symtab] Enable ada .gdb_index
Currently the .gdb_index is not enabled for ada executables (PR24713).

Fix this by adding the required support in write_psymbols, similar to how that
is done for .debug_names in debug_names::insert.

Tested on x86_64-linux, with native and target board cc-with-gdb-index.

gdb/ChangeLog:

2020-06-10  Tom de Vries  <tdevries@suse.de>

	PR ada/24713
	* dwarf2/index-write.c (struct mapped_symtab): Add m_string_obstack.
	(write_psymbols): Enable .gdb_index for ada.
	* dwarf2/read.c: Remove comment stating .gdb_index is unsupported for
	ada.

gdb/testsuite/ChangeLog:

2020-06-10  Tom de Vries  <tdevries@suse.de>

	* gdb.ada/ptype_union.exp: Remove PR24713 workaround.
2020-06-10 14:46:53 +02:00
Tom de Vries e5f3ece2ab [gdb/symtab] Fix name lookup in dw2_map_matching_symbols
In commit 9a0bacfb08 "[gdb/symtab] Handle .gdb_index in ada language mode", a
missing part of dw2_map_matching_symbols was added, containing a call to
dw2_expand_symtabs_matching_symbol.

However, the callback passed to that call has one problem: the callback has an
argument "offset_type namei", which is ignored.  Instead, match_name is passed
as argument to dw2_symtab_iter_init, where a name lookup is done, which may or
may not yield the same value as namei.

Fix this by creating a new version of dw2_symtab_iter_init that takes a
"offset_type namei" argument instead of "const char *name", and passing namei.

Tested on x86_64-linux, with native and target board cc-with-gdb-index.

gdb/ChangeLog:

2020-06-10  Tom de Vries  <tdevries@suse.de>

	* dwarf2/read.c (dw2_symtab_iter_init_common): Factor out of ...
	(dw2_symtab_iter_init): ... here.  Add variant with "offset_type
	namei" instead of "const char *name" argument.
	(dw2_map_matching_symbols): Use "offset_type namei" variant of
	dw2_symtab_iter_init.
2020-06-10 14:46:53 +02:00
Simon Marchi 940da03e32 gdb: remove TYPE_FIELD_TYPE macro
Remove the `TYPE_FIELD_TYPE` macro, changing all the call sites to use
`type::field` and `field::type` directly.

gdb/ChangeLog:

	* gdbtypes.h (TYPE_FIELD_TYPE): Remove.  Change all call sites
	to use type::field and field::type instead.

Change-Id: Ifda6226a25c811cfd334a756a9fbc5c0afdddff3
2020-06-08 15:26:31 -04:00
Simon Marchi b6cdac4b80 gdb: remove FIELD_TYPE macro
Remove the `FIELD_TYPE` macro, changing all the call sites to use
`field::type` directly.

gdb/ChangeLog:

	* gdbtypes.h (FIELD_TYPE): Remove.  Change all call sites
	to use field::type instead.

Change-Id: I7673fedaa276e485189c87991a9043495da22ef5
2020-06-08 15:26:06 -04:00
Simon Marchi 5d14b6e5d6 gdb: add field::type / field::set_type
Add the `type` and `set_type` methods on `struct field`, in order to
remoremove the `FIELD_TYPE` macro.  In this patch, the `FIELD_TYPE`
macro is changed to use `field::type`, so all the call sites that are
useused to set the field's type are changed to use `field::set_type`.
The next patch will remove `FIELD_TYPE` completely.

Note that because of the name clash between the existing field named
`type` and the new method, I renamed the field `m_type`.  It is not
private per-se, because we can't make `struct field` a non-POD yet, but
it should be considered private anyway (not accessed outside `struct
field`).

gdb/ChangeLog:

	* gdbtypes.h (struct field) <type, set_type>: New methods.
	Rename `type` field to...
	<m_type>: ... this.  Change references throughout to use type or
	set_type methods.
	(FIELD_TYPE): Use field::type.  Change call sites that modify
	the field's type to use field::set_type instead.

Change-Id: Ie21f866e3b7f8a51ea49b722d07d272a724459a0
2020-06-08 15:26:04 -04:00
Simon Marchi 3d967001ec gdb: remove TYPE_INDEX_TYPE macro
Remove `TYPE_INDEX_TYPE` macro, changing all the call sites to use
`type::index_type` directly.

gdb/ChangeLog:

	* gdbtypes.h (TYPE_INDEX_TYPE): Remove.  Change all call sites
	to use type::index_type instead.

Change-Id: I56715df0bdec89463cda6bd341dac0e01b2faf84
2020-06-08 15:26:01 -04:00
Simon Marchi 262abc0d67 gdb: add type::index_type / type::set_index_type
Add the `index_type` and `set_index_type` methods on `struct type`, in
order to remove the `TYPE_INDEX_TYPE` macro.  In this patch, the
`TYPE_INDEX_TYPE` macro is changed to use `type::index_type`, so all the
call sites that are used to set the type's index type are changed to use
`type::set_index_type`.  The next patch will remove `TYPE_INDEX_TYPE`
completely.

gdb/ChangeLog:

	* gdbtypes.h (struct type) <index_type, set_index_type>: New
	methods.
	(TYPE_INDEX_TYPE): Use type::index_type.
	* gdbtypes.c (create_array_type_with_stride): Likewise.

Change-Id: I93bdca9de9f3e143d2ccea59310c63745315e18d
2020-06-08 15:25:50 -04:00
Tom Tromey 82836c928f Remove unused parameter from generic_val_print_float
generic_val_print_float has an "embedded_offset" parameter, but it can
only ever be 0.  I believe it is a leftover from the val_print
removal.  This patch removes this parameter.

gdb/ChangeLog
2020-06-07  Tom Tromey  <tom@tromey.com>

	* valprint.c (generic_val_print_float): Remove "embedded_offset"
	parameter.
	(generic_value_print): Update.
2020-06-07 08:22:46 -06:00
Andrew Burgess 940dace9cf Revert "gdb/python: Avoid use after free in py-tui.c"
This reverts commit 982a38f60b.

I missed that the title being assigned too was a std::string, and so
there is no leak.
2020-06-05 21:12:55 +01:00
Andrew Burgess 982a38f60b gdb/python: Avoid use after free in py-tui.c
When setting the window title of a tui frame we do this:

  gdb::unique_xmalloc_ptr<char> value
    = python_string_to_host_string (<python-object>);
  ...
  win->window->title = value.get ();

The problem here is that 'get ()' only borrows the pointer from value,
when value goes out of scope the pointer will be freed.  As a result,
the tui frame will be left with a pointer to undefined memory
contents.

Instead we should be using 'value.release ()' to take ownership of the
pointer from value.

gdb/ChangeLog:

	* python/py-tui.c (gdbpy_tui_set_title): Use release, not get, to
	avoid use after free.
2020-06-05 19:21:20 +01:00
Tom de Vries 82f06518c4 [gdb/NEWS] Fix typos
Fix a few typos in gdb/NEWS.

gdb/ChangeLog:

2020-06-05  Tom de Vries  <tdevries@suse.de>

	* NEWS: Fix typos.
2020-06-05 12:24:20 +02:00
Simon Marchi f8c4185131 gdb: really share partial symtabs when using .gdb_index or .debug_names
Fix/follow-up to commit 17ee85fc2a ("Share DWARF partial symtabs").

In the non-index case, where GDB builds partial symbols from scratch,
two objfiles around the same BFD correctly share partial symtabs.  The
first objfile, which has to do all the work, saves a reference to the
created partial symtabs in the shared per_bfd object (at the end of
dwarf2_build_psymtabs).  The second objfile, when it reaches
dwarf2_build_psymtabs, sees that there are already partial symtabs built
for this BFD and just uses it.

However, that commit missed implementing the same sharing for cases
where GDB uses .gdb_index or .debug_names to build the partial symtabs.

This patch fixes it by having the first objfile to use the BFD set
per_bfd->partial_symtabs at the end of dwarf2_read_gdb_index /
dwarf2_read_debug_names.  For the subsequent objfiles using that BFD,
the partial symtabs are then picked up in dwarf2_initialize_objfile.

This patch adds a test that mimics how the issue was originally
triggered:

  1. Load the test file twice, such that the second objfile re-uses the
     per_bfd object created for the first objfile.
  2. Run to some point where in the backtrace there is a frame for a
     function that's in a CU that's not yet read in.
  3. Check that this frame's information is complete in the "backtrace"
     output.

Step 2 requires an address -> symbol lookup which uses the addrmap at
objfile->partial_symtabs->psymtabs_addrmap.  If the
objfile->partial_symtabs link is not properly setup (as is the case
before this patch), the symbol for that frame won't be found and we'll
get a frame with incomplete information.

The test fails without the fix when using boards "cc-with-gdb-index" and
"cc-with-debug-names".

gdb/ChangeLog:

	* dwarf2/read.c (dwarf2_read_gdb_index): Save partial_symtabs in
	the per_bfd object.
	(dwarf2_read_debug_names): Likewise.
	(dwarf2_initialize_objfile): Use partial_symtabs from per_bfd
	object when re-using a per_bfd object with an index.

gdb/testsuite/ChangeLog:

	* gdb.dwarf2/share-psymtabs-bt.exp: New file.
	* gdb.dwarf2/share-psymtabs-bt.c: New file.
	* gdb.dwarf2/share-psymtabs-bt-2.c: New file.

Change-Id: Ibb26210e2dfc03b80ba9fa56b875ba4cc58c0352
2020-06-04 13:58:48 -04:00