Age | Commit message (Collapse) | Author | Files | Lines |
|
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
|
|
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.
|
|
Test-case gdb.base/dbx.exp overrides:
- the GDBFLAGS variable
- the gdb_file_cmd proc
There's code at the end of the test-case to restore both, but that's not
guaranteed to be executed.
Fix this by:
- using save_vars to restore GDBFLAGS
- using a new proc with_override to restore gdb_file_cmd
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-06-11 Tom de Vries <tdevries@suse.de>
* lib/gdb.exp (with_override): New proc, factored out of ...
* gdb.base/dbx.exp: ... here. Use with_override and save_vars.
|
|
Replace 8 spaces with tabs.
Change-Id: I60f2df3a2866f75f0307077bf6cb1fa3918f8180
|
|
gdb/doc/ChangeLog:
* gdb.texinfo: Remove broken links Previous and Up from
contents.
Signed-off-by: Jonny Grant <jg@jguk.org>
Change-Id: Iad7323580a3c0c7f00eab1264d66f39e8d156e38
|
|
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.
|
|
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.
|
|
Fix:
DUPLICATE: gdb.base/index-cache.exp: test_cache_disabled: no files were created
DUPLICATE: gdb.base/index-cache.exp: test_cache_disabled: check index-cache stats
We use `proc_with_prefix` for test_cache_disabled, but we call it twice. So we
need an additional prefix to identify the specific call. This patch adds that.
gdb/testsuite/ChangeLog:
* gdb.base/index-cache.exp (test_cache_disabled): Add test_prefix
parameter, update callers.
Change-Id: Idf382fd380c77a654e8a7aa236af50b65c96b1d2
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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.
|
|
This reverts commit 982a38f60b0ece9385556cff45567e06710478cb.
I missed that the title being assigned too was a std::string, and so
there is no leak.
|
|
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.
|
|
Fix a few typos in gdb/NEWS.
gdb/ChangeLog:
2020-06-05 Tom de Vries <tdevries@suse.de>
* NEWS: Fix typos.
|
|
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
|
|
In gdb_file_cmd, perror is called with error message strings using $arg and
$GDB, both of which contain path names, which makes comparison of gdb.sum
files more difficult.
Fix this by using:
- [file tail $arg] instead of $arg
- GDB instead of $GDB.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-06-04 Tom de Vries <tdevries@suse.de>
* lib/gdb.exp (gdb_file_cmd): Avoid path names in error messages.
|
|
Consider a gdb_load patch to call the gdb_file_cmd twice:
...
proc gdb_load { arg } {
if { $arg != "" } {
+ set res [gdb_file_cmd $arg]
+ if { $res != 0 } {
+ return $res
+ }
return [gdb_file_cmd $arg]
}
return 0
}
...
When running test-case gdb.base/index-cache.exp, we run into:
...
ERROR: Couldn't load outputs/gdb.base/index-cache/index-cache, other program \
already loaded (timeout).
FAIL: gdb.base/index-cache.exp: test_cache_enabled_miss: check index-cache \
stats (GDB internal error)
ERROR: Couldn't load outputs/gdb.base/index-cache/index-cache, other program \
already loaded (timeout).
...
The first timeout in more detail:
...
(gdb) file outputs/gdb.base/index-cache/index-cache^M
Load new symbol table from "index-cache"? (y or n) y^M
Reading symbols from index-cache...^M
src/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.^M
A problem internal to GDB has been detected,^M
further debugging may prove unreliable.^M
Quit this debugging session? (y or n) ERROR: Couldn't load index-cache, \
other program already loaded (timeout).
...
Proc gdb_file_cmd has a gdb_expect handling the result of the file command,
and if the result is a "Load new symbol table from index-cache? (y or n) "
prompt, it sends a "y" and enters in a nested gdb_expect to handle the
result.
The first gdb_expect contains code to handle "A problem internal to GDB has
been detected", but the second one doesn't, which causes the timeout.
Fix this by removing the nested gdb_expect, and using exp_continue instead,
such that we have instead:
...
ERROR: Couldn't load outputs/gdb.base/index-cache/index-cache -- with new \
symbol table into gdb (GDB internal error).
ERROR: Couldn't load outputs/gdb.base/index-cache/index-cache -- with new \
symbol table into gdb (GDB internal error).
...
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-06-04 Tom de Vries <tdevries@suse.de>
* lib/gdb.exp (gdb_file_cmd): Replace incomplete gdb_expect by
exp_continue.
|
|
When building gdb using this patch:
...
static void
file_command (const char *arg, int from_tty)
{
+ gdb_assert (0);
...
and running the testsuite, we run into:
...
Running src/gdb/testsuite/gdb.ada/O2_float_param.exp ...
PASS: gdb.ada/O2_float_param.exp: compilation foo.adb
FAIL: gdb.ada/O2_float_param.exp: (outputs/gdb.ada/O2_float_param/foo) \
(GDB internal error)
PATH: gdb.ada/O2_float_param.exp: (outputs/gdb.ada/O2_float_param/foo) \
(GDB internal error)
FAIL: gdb.ada/O2_float_param.exp: frame
...
The FAIL detecting the GDB internal error is generated by this clause in
gdb_file_cmd:
...
-re "A problem internal to GDB has been detected" {
fail "($arg) (GDB internal error)"
gdb_internal_error_resync
return -1
}
...
The fail message has no text outside parenthesis, and could be considered
empty. Also, it's the only clause in the gdb_expect that uses fail, the
rest uses perror.
Fix this by replacing the fail by perror, such that we have:
...
Running src/gdb/testsuite/gdb.ada/O2_float_param.exp ...
PASS: gdb.ada/O2_float_param.exp: compilation foo.adb
ERROR: Couldn't load outputs/gdb.ada/O2_float_param/foo into \
gdb (GDB internal error).
UNRESOLVED: gdb.ada/O2_float_param.exp: frame
...
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-06-04 Tom de Vries <tdevries@suse.de>
* lib/gdb.exp (gdb_file_cmd): Use perror instead of fail.
|
|
Consider the test-case contained in this patch.
With -readnow, we have two breakpoint locations:
...
$ gdb -readnow -batch breakpoint-locs -ex "b N1::C1::baz" -ex "info break"
Breakpoint 1 at 0x4004cb: N1::C1::baz. (2 locations)
Num Type Disp Enb Address What
1 breakpoint keep y <MULTIPLE>
1.1 y 0x00000000004004cb in N1::C1::baz() \
at breakpoint-locs.h:6
1.2 y 0x00000000004004f0 in N1::C1::baz() \
at breakpoint-locs.h:6
...
But without -readnow, we have instead only one breakpoint location:
...
$ gdb -batch breakpoint-locs -ex "b N1::C1::baz" -ex "info break"
Breakpoint 1 at 0x4004f0: file breakpoint-locs.h, line 6.
Num Type Disp Enb Address What
1 breakpoint keep y 0x00000000004004f0 in N1::C1::baz() \
at breakpoint-locs.h:6
...
The relevant dwarf is this bit:
...
<0><d2>: Abbrev Number: 1 (DW_TAG_compile_unit)
<d8> DW_AT_name : breakpoint-locs.cc
<1><f4>: Abbrev Number: 2 (DW_TAG_namespace)
<f5> DW_AT_name : N1
<2><fe>: Abbrev Number: 3 (DW_TAG_class_type)
<ff> DW_AT_name : C1
<3><109>: Abbrev Number: 4 (DW_TAG_subprogram)
<10a> DW_AT_name : baz
<110> DW_AT_linkage_name: _ZN2N12C13bazEv
<2><116>: Abbrev Number: 5 (DW_TAG_subprogram)
<117> DW_AT_name : foo
<11d> DW_AT_linkage_name: _ZN2N13fooEv
<1><146>: Abbrev Number: 8 (DW_TAG_subprogram)
<147> DW_AT_specification: <0x116>
<14b> DW_AT_low_pc : 0x4004c7
<153> DW_AT_high_pc : 0x10
<2><161>: Abbrev Number: 9 (DW_TAG_inlined_subroutine)
<162> DW_AT_abstract_origin: <0x194>
<166> DW_AT_low_pc : 0x4004cb
<16e> DW_AT_high_pc : 0x9
<1><194>: Abbrev Number: 12 (DW_TAG_subprogram)
<195> DW_AT_specification: <0x109>
<199> DW_AT_inline : 3 (declared as inline and inlined)
...
The missing breakpoint location is specified by DIE 0x161, which is ignored by
the partial DIE reader because it's a child of a DW_TAG_subprogram DIE (at
0x146, for foo).
Fix this by not ignoring the DIE during partial DIE reading.
Tested on x86_64-linux.
gdb/ChangeLog:
2020-06-03 Tom de Vries <tdevries@suse.de>
PR symtab/26046
* dwarf2/read.c (scan_partial_symbols): Recurse into DW_TAG_subprogram
children for C++.
(load_partial_dies): Don't skip DW_TAG_inlined_subroutine child of
DW_TAG_subprogram.
gdb/testsuite/ChangeLog:
2020-06-03 Tom de Vries <tdevries@suse.de>
PR symtab/26046
* gdb.cp/breakpoint-locs-2.cc: New test.
* gdb.cp/breakpoint-locs.cc: New test.
* gdb.cp/breakpoint-locs.exp: New file.
* gdb.cp/breakpoint-locs.h: New test.
|
|
When running the gdb/jit-*.exp tests with runtest -v, I get:
...
ERROR: internal buffer is full.
UNRESOLVED: gdb.base/jit-elf-so.exp: one_jit_test-1: maintenance print objfiles
ERROR: internal buffer is full.
UNRESOLVED: gdb.base/jit-elf-so.exp: one_jit_test-2: maintenance print objfiles
ERROR: internal buffer is full.
UNRESOLVED: gdb.base/jit-elf.exp: one_jit_test-1: maintenance print objfiles
ERROR: internal buffer is full.
UNRESOLVED: gdb.base/jit-elf.exp: one_jit_test-2: maintenance print objfiles
ERROR: internal buffer is full.
UNRESOLVED: gdb.base/jit-elf.exp: attach: one_jit_test-2: maintenance print objfiles
ERROR: internal buffer is full.
UNRESOLVED: gdb.base/jit-elf.exp: PIE: one_jit_test-1: maintenance print objfiles
FAIL: gdb.base/jit-reader.exp: jit-reader-load
FAIL: gdb.base/jit-reader.exp: with jit-reader: before mangling: bt works
FAIL: gdb.base/jit-reader.exp: with jit-reader: after mangling: bt works
FAIL: gdb.base/jit-reader.exp: with jit-reader again: jit-reader-load
FAIL: gdb.base/jit-reader.exp: with jit-reader again: bt
...
This is the consequence of the use of global verbose in these tests, which is
used to change the actual test, rather than be more verbose about it.
Fix this by defining a global test_verbose in each test, and using that
instead.
Tested on x86_64-linux using runtest -v.
gdb/testsuite/ChangeLog:
2020-06-03 Tom de Vries <tdevries@suse.de>
PR testsuite/25609
* gdb.base/jit-elf-so.exp: Don't modify testing behaviour based on
value of global verbose.
* gdb.base/jit-elf.exp: Same.
* gdb.base/jit-reader.exp: Same.
|
|
This commit changes the language_data::skip_trampoline 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 skip_trampoline
initializer.
* c-lang.c (c_language_data): Likewise.
(cplus_language_data): Likewise.
(cplus_language::skip_trampoline): New member function.
(asm_language_data): Delete skip_trampoline initializer.
(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_trampoline): Delete function.
(skip_language_trampoline): Update.
(unknown_language_data): Delete skip_trampoline initializer.
(auto_language_data): Likewise.
* language.h (language_data): Delete skip_trampoline field.
(language_defn::skip_trampoline): New function.
* m2-lang.c (m2_language_data): Delete skip_trampoline
initializer.
* objc-lang.c (objc_skip_trampoline): Delete function, move
implementation to objc_language::skip_trampoline.
(objc_language_data): Delete skip_trampoline initializer.
(objc_language::skip_trampoline): New member function with
implementation from objc_skip_trampoline.
* opencl-lang.c (opencl_language_data): Delete skip_trampoline
initializer.
* p-lang.c (pascal_language_data): Likewise.
* rust-lang.c (rust_language_data): Likewise.
|
|
This commit changes the language_data::la_demangle function pointer
member variable into a member function of language_defn.
The only slightly "weird" change in this commit is in f-lang.c, where
I have given the Fortran language a demangle method that is identical
to the default language_defn::demangle. The only reason for this is
to give me somewhere to copy the comment that was previously embedded
within the f_language_data structure.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* ada-lang.c (ada_language_data): Delete la_demangle initializer.
(ada_language::demangle): New member function.
* c-lang.c (c_language_data): Delete la_demangle initializer.
(cplus_language_data): Delete la_demangle initializer.
(cplus_language::demangle): New member function.
(asm_language_data): Delete la_demangle initializer.
(minimal_language_data): Delete la_demangle initializer.
* d-lang.c (d_language_data): Delete la_demangle initializer.
(d_language::demangle): New member function.
* f-lang.c (f_language_data): Delete la_demangle initializer.
(f_language::demangle): New member function.
* go-lang.c (go_language_data): Delete la_demangle initializer.
(go_language::demangle): New member function.
* language.c (language_demangle): Update.
(unk_lang_demangle): Delete.
(unknown_language_data): Delete la_demangle initializer.
(unknown_language::demangle): New member function.
(auto_language_data): Delete la_demangle initializer.
(auto_language::demangle): New member function.
* language.h (language_data): Delete la_demangle field.
(language_defn::demangle): New function.
* m2-lang.c (m2_language_data): Delete la_demangle initializer.
* objc-lang.c (objc_language_data): Delete la_demangle
initializer.
(objc_language::demangle): New member function.
* opencl-lang.c (opencl_language_data): Delete la_demangle
initializer.
* p-lang.c (pascal_language_data): Likewise.
* rust-lang.c (rust_language_data): Likewise.
(rust_language::demangle): New member functi
|
|
This commit changes the language_data::la_print_type 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_print_type
initializer.
(ada_language::print_type): New member function.
* c-lang.c (c_language_data): Delete la_print_type initializer.
(c_language::print_type): New member function.
(cplus_language_data): Delete la_print_type initializer.
(cplus_language::print_type): New member function.
(asm_language_data): Delete la_print_type initializer.
(asm_language::print_type): New member function.
(minimal_language_data): Delete la_print_type initializer.
(minimal_language::print_type): New member function.
* d-lang.c (d_language_data): Delete la_print_type initializer.
(d_language::print_type): New member function.
* f-lang.c (f_language_data): Delete la_print_type initializer.
(f_language::print_type): New member function.
* go-lang.c (go_language_data): Delete la_print_type initializer.
(go_language::print_type): New member function.
* language.c (unk_lang_print_type): Delete.
(unknown_language_data): Delete la_print_type initializer.
(unknown_language::print_type): New member function.
(auto_language_data): Delete la_print_type initializer.
(auto_language::print_type): New member function.
* language.h (language_data): Delete la_print_type field.
(language_defn::print_type): New function.
(LA_PRINT_TYPE): Update.
* m2-lang.c (m2_language_data): Delete la_print_type initializer.
(m2_language::print_type): New member function.
* objc-lang.c (objc_language_data): Delete la_print_type
initializer.
(objc_language::print_type): New member function.
* opencl-lang.c (opencl_print_type): Delete, implementation moved
to opencl_language::print_type.
(opencl_language_data): Delete la_print_type initializer.
(opencl_language::print_type): New member function, implementation
from opencl_print_type.
* p-lang.c (pascal_language_data): Delete la_print_type
initializer.
(pascal_language::print_type): New member function.
* rust-lang.c (rust_print_type): Delete, implementation moved to
rust_language::print_type.
(rust_language_data): Delete la_print_type initializer.
(rust_language::print_type): New member function, implementation
from rust_print_type.
|
|
This commit changes the language_data::la_sniff_from_mangled_name
function pointer member variable into a member function of
language_defn.
Previously the la_sniff_from_mangled_name pointer was NULL for some
languages, however, all uses of this function pointer were through the
function language_sniff_from_mangled_name which provided a default
implementation.
This default implementation now becomes the implementation in the base
class language_defn, which is then overridden as required in various
language sub-classes.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* ada-lang.c (ada_sniff_from_mangled_name): Delete function,
implementation moves to...
(ada_language::sniff_from_mangled_name): ...here. Update return
type.
(ada_language_data): Delete la_sniff_from_mangled_name
initializer.
* c-lang.c (c_language_data): Likewise.
(cplus_language_data): Likewise.
(cplus_language::sniff_from_mangled_name): New member function,
implementation taken from gdb_sniff_from_mangled_name.
(asm_language_data): Delete la_sniff_from_mangled_name
initializer.
(minimal_language_data): Likewise.
* cp-support.c (gdb_sniff_from_mangled_name): Delete,
implementation moves to cplus_language::sniff_from_mangled_name.
* cp-support.h (gdb_sniff_from_mangled_name): Delete declaration.
* d-lang.c (d_sniff_from_mangled_name): Delete, implementation
moves to...
(d_language::sniff_from_mangled_name): ...here.
(d_language_data): Delete la_sniff_from_mangled_name initializer.
* f-lang.c (f_language_data): Likewise.
* go-lang.c (go_sniff_from_mangled_name): Delete, implementation
moves to...
(go_language::sniff_from_mangled_name): ...here.
(go_language_data): Delete la_sniff_from_mangled_name initializer.
* language.c (language_sniff_from_mangled_name): Delete.
(unknown_language_data): Delete la_sniff_from_mangled_name
initializer.
(auto_language_data): Likewise.
* language.h (language_data): Delete la_sniff_from_mangled_name
field.
(language_defn::sniff_from_mangled_name): New function.
(language_sniff_from_mangled_name): Delete declaration.
* m2-lang.c (m2_language_data): Delete la_sniff_from_mangled_name
field.
* objc-lang.c (objc_sniff_from_mangled_name): Delete,
implementation moves to...
(objc_language::sniff_from_mangled_name): ...here.
(objc_language_data): Delete la_sniff_from_mangled_name initializer.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
* rust-lang.c (rust_sniff_from_mangled_name): Delete,
implementation moves to...
(rust_language::sniff_from_mangled_name): ...here.
(rust_language_data): Delete la_sniff_from_mangled_name
initializer.
* symtab.c (symbol_find_demangled_name): Call
sniff_from_mangled_name member function.
|
|
This commit changes the language_data::la_search_name_hash
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_search_name_hash
initializer.
* c-lang.c (c_language_data): Likewise.
(cplus_language_data): Likewise.
(cplus_language::search_name_hash): New member function.
(asm_language_data): Delete la_search_name_hash initializer.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
* dictionary.c (default_search_name_hash): Rename to...
(language_defn::search_name_hash): ...this.
* f-lang.c (f_language_data): Likewise.
(f_language::search_name_hash): New member function.
* go-lang.c (go_language_data): Delete la_search_name_hash
initializer.
* language.c (unknown_language_data): Likewise.
(auto_language_data): Likewise.
* language.h (struct language_data): Delete la_search_name_hash
field.
(language_defn::search_name_hash): Declare new member function.
(default_search_name_hash): Delete declaration.
* m2-lang.c (m2_language_data): Delete la_search_name_hash
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 (search_name_hash): Update call.
|
|
This commit changes the language_data::la_get_compile_instance
function pointer member variable into a member function of
language_defn. Unlike previous commits converting fields of
language_data to member function in language_defn, this field is NULL
for some languages. As a result I had to change the API slightly so
that the base language_defn class provides an implementation.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* ada-lang.c (ada_language_data): Delete la_get_compile_instance
initializer.
* c-lang.c (class compile_instance): Declare.
(c_language_data): Delete la_get_compile_instance initializer.
(c_language::get_compile_instance): New member function.
(cplus_language_data): Delete la_get_compile_instance initializer.
(cplus_language::get_compile_instance): New member function.
(asm_language_data): Delete la_get_compile_instance initializer.
(minimal_language_data): Likewise.
* c-lang.h (c_get_compile_context): Update comment.
(cplus_get_compile_context): Update comment.
* compile/compile.c (compile_to_object): Update calls, don't rely
on function pointer being NULL.
* d-lang.c (d_language_data): Delete la_get_compile_instance
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_get_compile_instance field.
(language_defn::get_compile_instance): New member function.
* m2-lang.c (m2_language_data): Delete la_get_compile_instance
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.
|
|
This commit changes the language_data::la_iterate_over_symbols
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_add_all_symbols): Update comment.
(ada_iterate_over_symbols): Delete, move implementation to...
(ada_language::iterate_over_symbols): ...here, a new member
function, rewrite to use range based for loop.
(ada_language_data): Delete la_iterate_over_symbols initializer.
* c-lang.c (c_language_data): Likewise.
(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 (unknown_language_data): Likewise.
(auto_language_data): Likewise.
* language.h (language_data): Delete la_iterate_over_symbols field.
(language_defn::iterate_over_symbols): New member function.
(LA_ITERATE_OVER_SYMBOLS): Update.
* linespec.c (iterate_over_all_matching_symtabs): Update.
* m2-lang.c (m2_language_data): Delete la_iterate_over_symbols
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.
|
|
This commit changes the language_data::la_lookup_transparent_type
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_lookup_transparent_type initializer.
* c-lang.c (c_language_data): Likewise.
(cplus_language_data): Likewise.
(cplus_language::lookup_transparent_type): New member function.
(asm_language_data): Delete la_lookup_transparent_type
initializer.
(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 (unknown_language_data): Likewise.
(auto_language_data): Likewise.
* language.h (struct language_data): Delete
la_lookup_transparent_type field.
(language_defn::lookup_transparent_type): New member function.
* m2-lang.c (m2_language_data): Delete la_lookup_transparent_type
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 (symbol_matches_domain): Update call.
|
|
This commit changes the language_data::la_language_arch_info 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_arch_info): Delete function, move
implementation to...
(ada_language::language_arch_info): ...here, a new member
function.
(ada_language_data): Delete la_language_arch_info.
* c-lang.c (c_language_data): Likewise.
(c_language::language_arch_info): New member function.
(cplus_language_arch_info): Delete function, move
implementation to...
(cplus_language::language_arch_info): ...here, a new member
function.
(cplus_language_data): Delete la_language_arch_info.
(asm_language_data): Likewise.
(asm_language::language_arch_info): New member function.
(minimal_language_data): Delete la_language_arch_info.
(minimal_language::language_arch_info): New member function.
* d-lang.c (d_language_arch_info): Delete function, move
implementation to...
(d_language::language_arch_info): ...here, a new member
function.
(d_language_data): Delete la_language_arch_info.
* f-lang.c (f_language_arch_info): Delete function, move
implementation to...
(f_language::language_arch_info): ...here, a new member
function.
(f_language_data): Delete la_language_arch_info.
* go-lang.c (go_language_arch_info): Delete function, move
implementation to...
(go_language::language_arch_info): ...here, a new member
function.
(go_language_data): Delete la_language_arch_info.
* language.c (unknown_language_data): Likewise.
(unknown_language::language_arch_info): New member function.
(auto_language_data): Delete la_language_arch_info.
(auto_language::language_arch_info): New member function.
(language_gdbarch_post_init): Update call to
la_language_arch_info.
* language.h (language_data): Delete la_language_arch_info
function pointer.
(language_defn::language_arch_info): New function.
* m2-lang.c (m2_language_arch_info): Delete function, move
implementation to...
(m2_language::language_arch_info): ...here, a new member
function.
(m2_language_data): Delete la_language_arch_info.
* objc-lang.c (objc_language_arch_info): Delete function, move
implementation to...
(objc_language::language_arch_info): ...here, a new member
function.
(objc_language_data): Delete la_language_arch_info.
* opencl-lang.c (opencl_language_arch_info): Delete function, move
implementation to...
(opencl_language::language_arch_info): ...here, a new member
function.
(opencl_language_data): Delete la_language_arch_info.
* p-lang.c (pascal_language_arch_info): Delete function, move
implementation to...
(pascal_language::language_arch_info): ...here, a new member
function.
(pascal_language_data): Delete la_language_arch_info.
* rust-lang.c (rust_language_arch_info): Delete function, move
implementation to...
(rust_language::language_arch_info): ...here, a new member
function.
(rust_language_data): Delete la_language_arch_info.
|
|
This commit changes the language_data::la_pass_by_reference function
pointer member variable into a member function of language_defn.
The interesting thing in this commit is that I have removed the
default_pass_by_reference function entirely. This function only ever
returned a language_pass_by_ref_info struct in its default state, so
all uses of this function can be replaced by just default
initialisation of a language_pass_by_ref_info variable.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* ada-lang.c (ada_language_data): Delete la_pass_by_reference
initializer.
* c-lang.c (c_language_data): Likewise.
(cplus_language_data): Likewise.
(cplus_language::pass_by_reference_info): New method.
(asm_language_data): Delete la_pass_by_reference initializer.
(minimal_language_data): Likewise.
* cp-abi.c (cp_pass_by_reference): Remove use of
default_pass_by_reference.
* d-lang.c (d_language_data): Likewise.
* f-lang.c (f_language_data): Likewise.
* gnu-v3-abi.c (gnuv3_pass_by_reference): Remove use of
default_pass_by_reference.
* go-lang.c (go_language_data): Likewise.
* language.c (language_pass_by_reference): Update.
(default_pass_by_reference): Delete.
(unknown_language_data): Delete la_pass_by_reference
initializer.
(auto_language_data): Likewise.
* language.h (struct language_data): Delete la_pass_by_reference
field.
(language_defn::pass_by_reference_info): New member function.
(default_pass_by_reference): Delete declaration.
* m2-lang.c (m2_language_data): Delete la_pass_by_reference
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.
|
|
This commit changes the language_data::la_read_var_value function
pointer member variable into a member function of language_defn.
An interesting aspect of this change is that the implementation of
language_defn::read_var_value is actually in findvar.c. This is
partly historical, the new language_defn::read_var_value is a rename
of default_read_var_value, which was already in that file, but also,
that is the file that contains the helper functions needed by the
read_var_value method, so it makes sens that the method implementation
should continue to live there (I think).
There should be no user visible changes after this commit.
gdb/ChangeLog:
* ada-lang.c (ada_read_var_value): Delete function, move
implementation to...
(ada_language::read_var_value): ...here.
(ada_language_data): Delete la_read_var_value initializer.
* c-lang.c (c_language_data): Likewise.
(cplus_language_data): Likewise.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
* f-lang.c (f_language_data): Likewise.
* findvar.c (default_read_var_value): Rename to...
(language_defn::read_var_value): ...this.
* findvar.c (read_var_value): Update header comment, and change to
call member function instead of function pointer.
* go-lang.c (go_language_data): Likewise.
* language.c (unknown_language_data): Delete la_read_var_value
initializer.
(auto_language_data): Likewise.
* language.h (struct language_data): Delete la_read_var_value
field.
(language_defn::read_var_value): New member function.
(default_read_var_value): Delete declaration.
* m2-lang.c (m2_language_data): Delete la_read_var_value
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.
* value.h (default_read_var_value): Delete declaration.
|
|
This commit changes the language_data::la_print_array_index 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_print_array_index): Delete function, move
implementation to...
(ada_language::print_array_index): ...here.
(ada_language_data): Delete la_print_array_index initializer.
* c-lang.c (c_language_data): Likewise.
(cplus_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 (default_print_array_index): Delete function, move
implementation to...
(language_defn::print_array_index): ...here.
(unknown_language_data): Delete la_print_array_index initializer.
(auto_language_data): Likewise.
* language.h (struct language_data): Delete la_print_array_index
field.
(language_defn::print_array_index): New member function.
(LA_PRINT_ARRAY_INDEX): Update.
(default_print_array_index): Delete declaration.
* m2-lang.c (m2_language_data): Delete la_print_array_index
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.
|
|
This commit converts all languages to sub-classes of a language_defn
base class.
The motivation for this change is to make it easier to add new methods
onto languages without having to update all of the individual language
structures. In the future it might be possible to move more things,
like expression parsing, into the language class(es) for better
encapsulation, however I have no plans to tackle this in the short
term.
This commit sets up a strategy for transitioning from the current
language system, where each language is an instance of the
language_defn structure, to the class hierarchy system.
The plan is to rename the existing language_defn into language_data,
and make this a base class for the new language_defn class, something
like this:
struct language_data
{
... old language_defn fields here ...
};
struct language_defn : public language_data
{
language_defn (const language_data d)
: language_data (d)
{ .... }
};
Then each existing language, for example ada_language_defn can be
converted into an instance of language_data, and passed into the
constructor of a new language class, something like this:
language_data ada_language_data =
{
... old ada_language_defn values here ...
};
struct ada_language : public language_defn
{
ada_language (ada_language_data)
{ .... }
};
What this means is that immediately after the conversion nothing much
changes. Every language is now its own class, but all the old
language fields still exist and can be accessed in the same way.
In later commits I will convert function pointers from the old
language_defn structure into real class methods on language_defn, with
overrides on sub-classes where needed.
At this point I imagine that those fields of the old language_defn
structure that contained only data will probably remain as data fields
within the new language_data base structure, it is only the methods
that I plan to change initially.
I tweaked how we manage the list of languages a bit, each language is
now registered as it is created, and this resulted in a small number
of changes in language.c.
Most of the changes in the *-lang.c files are identical.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* gdb/ada-lang.c (ada_language_defn): Convert to...
(ada_language_data): ...this.
(class ada_language): New class.
(ada_language_defn): New static global.
* gdb/c-lang.c (c_language_defn): Convert to...
(c_language_data): ...this.
(class c_language): New class.
(c_language_defn): New static global.
(cplus_language_defn): Convert to...
(cplus_language_data): ...this.
(class cplus_language): New class.
(cplus_language_defn): New static global.
(asm_language_defn): Convert to...
(asm_language_data): ...this.
(class asm_language): New class.
(asm_language_defn): New static global.
(minimal_language_defn): Convert to...
(minimal_language_data): ...this.
(class minimal_language): New class.
(minimal_language_defn): New static global.
* gdb/d-lang.c (d_language_defn): Convert to...
(d_language_data): ...this.
(class d_language): New class.
(d_language_defn): New static global.
* gdb/f-lang.c (f_language_defn): Convert to...
(f_language_data): ...this.
(class f_language): New class.
(f_language_defn): New static global.
* gdb/go-lang.c (go_language_defn): Convert to...
(go_language_data): ...this.
(class go_language): New class.
(go_language_defn): New static global.
* gdb/language.c (unknown_language_defn): Remove declaration.
(current_language): Initialize to nullptr, real initialization is
moved to _initialize_language.
(languages): Delete global.
(language_defn::languages): Define.
(set_language_command): Use language_defn::languages.
(set_language): Likewise.
(range_error): Likewise.
(language_enum): Likewise.
(language_def): Likewise.
(add_set_language_command): Use language_def::languages for the
language list, and language_def to lookup language pointers.
(skip_language_trampoline): Use language_defn::languages.
(unknown_language_defn): Convert to...
(unknown_language_data): ...this.
(class unknown_language): New class.
(unknown_language_defn): New static global.
(auto_language_defn): Convert to...
(auto_language_data): ...this.
(class auto_language): New class.
(auto_language_defn): New static global.
(language_gdbarch_post_init): Use language_defn::languages.
(_initialize_language): Initialize current_language.
* gdb/language.h (struct language_defn): Rename to...
(struct language_data): ...this.
(struct language_defn): New.
(auto_language_defn): Delete.
(unknown_language_defn): Delete.
(minimal_language_defn): Delete.
(ada_language_defn): Delete.
(asm_language_defn): Delete.
(c_language_defn): Delete.
(cplus_language_defn): Delete.
(d_language_defn): Delete.
(f_language_defn): Delete.
(go_language_defn): Delete.
(m2_language_defn): Delete.
(objc_language_defn): Delete.
(opencl_language_defn): Delete.
(pascal_language_defn): Delete.
(rust_language_defn): Delete.
* gdb/m2-lang.c (m2_language_defn): Convert to...
(m2_language_data): ...this.
(class m2_language): New class.
(m2_language_defn): New static global.
* gdb/objc-lang.c (objc_language_defn): Convert to...
(objc_language_data): ...this.
(class objc_language): New class.
(objc_language_defn): New static global.
* gdb/opencl-lang.c (opencl_language_defn): Convert to...
(opencl_language_data): ...this.
(class opencl_language): New class.
(opencl_language_defn): New static global.
* gdb/p-lang.c (pascal_language_defn): Convert to...
(pascal_language_data): ...this.
(class pascal_language): New class.
(pascal_language_defn): New static global.
* gdb/rust-exp.y (rust_lex_tests): Use language_def to find
language pointer, update comment format.
* gdb/rust-lang.c (rust_language_defn): Convert to...
(rust_language_data): ...this.
(class rust_language): New class.
(rust_language_defn): New static global.
|
|
Consider a gdb_load patch to call the gdb_file_cmd twice:
...
proc gdb_load { arg } {
if { $arg != "" } {
+ set res [gdb_file_cmd $arg]
+ if { $res != 0 } {
+ return $res
+ }
return [gdb_file_cmd $arg]
}
return 0
}
...
With this patch, I run into:
...
(gdb) kill^M
The program is not being run.^M
(gdb) ^M</outputs/gdb.dwarf2/multidictionary/multidictionary^M
<.dwarf2/multidictionary/multidictionary"? (y or n)
ERROR: Couldn't load outputs/gdb.dwarf2/multidictionary/multidictionary \
into gdb (timeout).
p 1^M
Please answer y or n.^M
<.dwarf2/multidictionary/multidictionary"? (y or n) n^M
Not confirmed.^M
(gdb) UNRESOLVED: gdb.dwarf2/multidictionary.exp: GDB is alive \
(got interactive prompt)
...
The problem is that the second file command results in a prompt, which is
normally handled by gdb_file_cmd, but not recognized because the initial part
of the prompt is scrolled out.
This in turn is caused by using gdb_spawn_with_cmdline_opts without a
subsequent "set width 0".
Fix this by avoiding gdb_spawn_with_cmdline_opts, and forcing -readline by
temporarily modifying GDBFLAGS instead.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-06-02 Tom de Vries <tdevries@suse.de>
* gdb.dwarf2/multidictionary.exp: Don't use
gdb_spawn_with_cmdline_opts.
|
|
After the is-stmt support commit:
commit 8c95582da858ac981f689a6f599acacb8c5c490f
Date: Mon Dec 30 21:04:51 2019 +0000
gdb: Add support for tracking the DWARF line table is-stmt field
A regression was observed where a breakpoint could no longer be placed
in some cases.
Consider a line table like this:
File 1: test.c
File 2: test.h
| Addr | File | Line | Stmt |
|------|------|------|------|
| 1 | 1 | 16 | Y |
| 2 | 1 | 17 | Y |
| 3 | 2 | 21 | Y |
| 4 | 2 | 22 | Y |
| 4 | 1 | 18 | N |
| 5 | 2 | 23 | N |
| 6 | 1 | 24 | Y |
| 7 | 1 | END | Y |
|------|------|------|------|
Before the is-stmt patch GDB would ignore any non-stmt lines, so GDB
built two line table structures:
File 1 File 2
------ ------
| Addr | Line | | Addr | Line |
|------|------| |------|------|
| 1 | 16 | | 3 | 21 |
| 2 | 17 | | 4 | 22 |
| 3 | END | | 6 | END |
| 6 | 24 | |------|------|
| 7 | END |
|------|------|
After the is-stmt patch GDB now records non-stmt lines, so the
generated line table structures look like this:
File 1 File 2
------ ------
| Addr | Line | Stmt | | Addr | Line | Stmt |
|------|------|------| |------|------|------|
| 1 | 16 | Y | | 3 | 21 | Y |
| 2 | 17 | Y | | 4 | 22 | Y |
| 3 | END | Y | | 4 | END | Y |
| 4 | 18 | N | | 5 | 23 | N |
| 5 | END | Y | | 6 | END | Y |
| 6 | 24 | Y | |------|------|------|
| 7 | END | Y |
|------|------|------|
The problem is that in 'File 2', end END marker at address 4 causes
the previous line table entry to be discarded, so we actually end up
with this:
File 2
------
| Addr | Line | Stmt |
|------|------|------|
| 3 | 21 | Y |
| 4 | END | Y |
| 5 | 23 | N |
| 6 | END | Y |
|------|------|------|
When a user tries to place a breakpoint in file 2 at line 22, this is
no longer possible.
The solution I propose here is that we ignore line table entries that
would trigger a change of file if:
1. The new line being added is at the same address as the previous
line, and
2. We have previously seen an is-stmt line at the current address.
The result of this is that GDB switches file, and knows that some line
entry (or entries) are going to be discarded, prefer to keep is-stmt
lines and discard non-stmt lines.
After this commit the lines tables are now:
File 1 File 2
------ ------
| Addr | Line | Stmt | | Addr | Line | Stmt |
|------|------|------| |------|------|------|
| 1 | 16 | Y | | 3 | 21 | Y |
| 2 | 17 | Y | | 4 | 22 | Y |
| 3 | END | Y | | 5 | 23 | N |
| 5 | END | Y | | 6 | END | Y |
| 6 | 24 | Y | |------|------|------|
| 7 | END | Y |
|------|------|------|
We've lost the non-stmt entry for file 1, line 18, but retained the
is-stmt entry for file 2, line 22. The user can now place a
breakpoint at that location.
One problem that came from this commit was the test
gdb.cp/step-and-next-inline.exp, which broke in several places. After
looking at this test again I think that in some cases this test was
only ever passing by pure luck. The debug GCC is producing for this
test is pretty broken. I raised this GCC bug:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94474
for this and disabled one entire half of the test. There are still
some cases in here that do pass, and if/when GCC is fixed it would be
great to enable this test again.
gdb/ChangeLog:
* dwarf2/read.c (class lnp_state_machine) <m_last_address>: New
member variable.
<m_stmt_at_address>: New member variable.
(lnp_state_machine::record_line): Don't record some lines, update
tracking of is_stmt at the same address.
(lnp_state_machine::lnp_state_machine): Initialise new member
variables.
gdb/testsuite/ChangeLog:
* gdb.cp/step-and-next-inline.exp (do_test): Skip all tests in the
use_header case.
* gdb.dwarf2/dw2-inline-header-1.exp: New file.
* gdb.dwarf2/dw2-inline-header-2.exp: New file.
* gdb.dwarf2/dw2-inline-header-3.exp: New file.
* gdb.dwarf2/dw2-inline-header-lbls.c: New file.
* gdb.dwarf2/dw2-inline-header.c: New file.
* gdb.dwarf2/dw2-inline-header.h: New file.
|
|
We are using -Werror=missing-declarations, and the _S.h files generated
by mig do not currently include a declaration for the server routine.
gnu-nat.c used to have its own external declarations, but better just
share them between gnu-nat.c and the _S.c files.
Fixes
exc_request_S.c:177:24: error: no previous declaration for ‘exc_server’ [-Werror=missing-declarations]
177 | mig_external boolean_t exc_server
gdb/ChangeLog:
* config/i386/i386gnu.mn [%_S.o %_U.o] (COMPILE.post): Add
"-include gnu-nat-mig.h".
* gnu-nat-mig.h: New file.
* gnu-nat.c: Include "gnu-nat-mig.h".
(exc_server, msg_reply_server, notify_server,
process_reply_server): Remove declarations.
|
|
This allows to have the process_stratum_target object at hand for future use in
the gdb API, and only use gnu_target from external calls.
gdb/Changelog:
* gnu-nat.h (inf_validate_procs, inf_suspend, inf_set_traced,
steal_exc_port, proc_get_state, inf_clear_wait, inf_cleanup,
inf_startup, inf_update_suspends, inf_set_pid, inf_steal_exc_ports,
inf_validate_procinfo, inf_validate_task_sc, inf_restore_exc_ports,
inf_set_threads_resume_sc, inf_set_threads_resume_sc_for_signal_thread,
inf_resume, inf_set_step_thread, inf_detach, inf_attach, inf_signal,
inf_continue, make_proc, proc_abort, _proc_free, proc_update_sc,
proc_get_exception_port, proc_set_exception_port, _proc_get_exc_port,
proc_steal_exc_port, proc_restore_exc_port, proc_trace): Move functions
to gnu_nat_target class.
* gnu-nat.c: Likewise.
(inf_update_procs, S_proc_wait_reply, set_task_pause_cmd,
set_task_exc_port_cmd, set_signals_cmd, set_thread_pause_cmd,
set_thread_exc_port_cmd): Call inf_validate_procs through gnu_target
object.
(gnu_nat_target::create_inferior, gnu_nat_target::detach): Pass `this'
instead of `gnu_target'.
|
|
This allows to get full backtrace from signal handlers, otherwise the
backtrace stops at the trampoline that calls the handler.
This needs special knowledge how the trampoline records register context
for the sigreturn call after signal handling.
gdb/ChangeLog:
* i386-gnu-tdep.c: Include "gdbcore.h"
(gnu_sigtramp_code, i386_gnu_sc_reg_offset): New arrays.
(GNU_SIGTRAMP_LEN, GNU_SIGTRAMP_TAIL,
I386_GNU_SIGCONTEXT_THREAD_STATE_OFFSET): New macros
(i386_gnu_sigtramp_start, i386_gnu_sigtramp_p,
i386_gnu_sigcontext_addr): New functions
(i386gnu_init_abi): Register i386_gnu_sigtramp_p,
i386_gnu_sigcontext_addr, and i386_gnu_sc_reg_offset in the gdbarch
tdep.
|
|
This fixes creating inferiors, which was broken since 5b6d1e4fa
('Multi-target support')
gdb/ChangeLog:
* gnu-nat.c (gnu_nat_target::create_inferior): Move push_target call
before fork_inferior call. Avoid calling it if target_is_pushed returns
true.
|
|
Fixes
../../gdb/gnu-nat.c:1110:28: error: cannot convert ‘ptid_t’ to ‘process_stratum_target*’
1110 | thread_change_ptid (inferior_ptid, ptid);
and others related to 5b6d1e4fa ("Multi-target support")
gdb/ChangeLog:
* gnu-nat.h (gnu_target): New variable declaration.
* i386-gnu-nat.c (_initialize_i386gnu_nat): Initialize
gnu_target.
* gnu-nat.c (gnu_target): New variable.
(inf_validate_procs): Pass gnu_target to thread_change_ptid,
add_thread_silent, and add_thread calls.
(gnu_nat_target::create_inferior): Pass gnu_target to
add_thread_silent, thread_change_ptid call.
(gnu_nat_target::detach): Pass gnu_target to detach_inferior
call.
|
|
Fixes
../../gdb/gnu-nat.c:2554:7: error: unused variable ‘res’ [-Werror=unused-variable]
2554 | int res;
../../gdb/gnu-nat.c:2644:20: error: unused variable ‘old_address’ [-Werror=unused-variable]
2644 | vm_address_t old_address = region_address;
gdb/ChangeLog:
* gnu-nat.c (gnu_xfer_auxv): Remove unused `res' variable.
(gnu_nat_target::find_memory_regions): Remove unused
`old_address' variable.
|
|
Fixes
../../gdb/gnu-nat.c:2522:14: error: ‘target_gdbarch’ was not declared in this scope; did you mean ‘target_detach’?
2522 | paddress (target_gdbarch (), memaddr), pulongest (len),
gdb/Changelog:
* gnu-nat.c: Include "gdbarch.h".
|
|
Fixes
process_reply_S.c:104:23: error: function called through a non-compatible type [-Werror]
104 | OutP->RetCode = (*(kern_return_t (*)(mach_port_t, kern_return_t)) S_proc_setmsgport_reply) (In0P->Head.msgh_request_port, In0P-
As the existing comment says, it is in general not safe to drop some
parameters like this, but this is the error handling case, where the
called function does not actually read them, and mig is currently planned
to be used on i386 and x86_64 only, where this is not a problem. As the
existing comment says, fixing it properly would be far from trivial:
we can't just pass 0 for them, as they might not be scalar.
gdb/ChangeLog:
* reply_mig_hack.awk (Error return): Cast function through
void *, to bypass compiler function call check.
|
|
To make sure the *_reply_S.[ch] files get regenerated whenever we change
the awk script.
gdb/ChangeLog:
* config/i386/i386gnu.mn (%_reply_S.c): Add dependency on
$(srcdir)/reply_mig_hack.awk.
|
|
Fixes
../../gdb/gnu-nat.c:96:6: error: conflicting declaration ‘bool gnu_debug_flag’
96 | bool gnu_debug_flag = false;
../../gdb/gnu-nat.c: In function ‘void _initialize_gnu_nat()’:
../../gdb/gnu-nat.c:3511:7: error: cannot
gdb/ChangeLog:
* gnu-nat.h (gnu_debug_flag): Set type to bool.
|
|
gdb/ChangeLog:
* configure.ac (ACX_BUGURL): change bug URL to https.
Signed-off-by: Jonny Grant <jg@jguk.org>
Change-Id: If8d939e50c830e3e452c3e8f7a7aee06d9c96645
|
|
GDB currently crashes with infinite recursion, if you set a breakpoint
on a function inside a namespace that includes a template on its fully
qualified name, and, the template's name is also used as typedef in
the global scope that expands to a name that includes the template
name in its qualified name. For example, from the testcase added by
this commit:
namespace NS1 { namespace NS2 {
template<typename T> struct Templ1
{
T x;
Templ1 (object_p) {}
}} // namespace NS1::NS2
using Templ1 = NS1::NS2::Templ1<unsigned>;
Setting a breakpoint like so:
(gdb) break NS1::NS2::Templ1<int>::Templ1(NS1::NS2::object*)
Results in infinite recursion, with this cycle (started by
cp_canonicalize_string_full) repeating until the stack is exhausted:
...
#1709 0x000000000055533c in inspect_type (info=0x38ff720, ret_comp=0xd83be10, finder=0x0, data=0x0) at /home/pedro/gdb/mygit/src/gdb/cp-support.c:267
#1710 0x0000000000555a6f in replace_typedefs (info=0x38ff720, ret_comp=0xd83be10, finder=0x0, data=0x0) at /home/pedro/gdb/mygit/src/gdb/cp-support.c:475
#1711 0x0000000000555a36 in replace_typedefs (info=0x38ff720, ret_comp=0xd83be70, finder=0x0, data=0x0) at /home/pedro/gdb/mygit/src/gdb/cp-support.c:470
#1712 0x0000000000555800 in replace_typedefs_qualified_name (info=0x38ff720, ret_comp=0xd839470, finder=0x0, data=0x0) at /home/pedro/gdb/mygit/src/gdb/cp-support.c:389
#1713 0x0000000000555a8c in replace_typedefs (info=0x38ff720, ret_comp=0xd839470, finder=0x0, data=0x0) at /home/pedro/gdb/mygit/src/gdb/cp-support.c:479
...
The demangle component tree for that symbol name looks like this:
d_dump tree for NS1::NS2::Templ1<int>::Templ1(NS1::NS2::object*):
typed name
qualified name
name 'NS1'
qualified name
name 'NS2'
qualified name
template <<<<<<<<<<
name 'Templ1'
template argument list
builtin type int
name 'Templ1'
function type
argument list
pointer
qualified name
name 'NS1'
qualified name
name 'NS2'
name 'object'
The recursion starts at replace_typedefs_qualified_name, which doesn't
handle the "template" node, and thus doesn't realize that the template
name actually has the fully qualified name NS1::NS2::Templ1.
replace_typedefs_qualified_name calls into replace_typedefs on the
template node, and that ends up in inspect_type looking up for a
symbol named "Templ1", which finds the global namespace typedef, which
itself expands to NS1::NS2::Templ1. GDB then tries replacing typedefs
in that newly expanded name, which ends up again in
replace_typedefs_qualified_name, trying to expand a fully qualified
name with "NS::NS2::Templ1<unsigned>" in its name, which results in
recursion whenever the template node is reached.
Fix this by teaching replace_typedefs_qualified_name how to handle
template nodes. It needs handling in two places: the first spot
handles the symbol above; the second spot handles a symbol like this,
from the new test:
(gdb) b NS1::NS2::grab_it(NS1::NS2::Templ1<int>*)
d_dump tree for NS1::NS2::grab_it(NS1::NS2::Templ1<int>*):
typed name
qualified name
name 'NS1'
qualified name
name 'NS2'
name 'grab_it'
function type
argument list
pointer
qualified name
name 'NS1'
qualified name
name 'NS2'
template <<<<<<<<
name 'Templ1'
template argument list
builtin type int
What's different in this case is that the template node appears on the
right child node of a qualified name, instead of on the left child.
The testcase includes a test that checks whether template aliases are
correctly replaced by GDB too. That fails with GCC due to GCC PR
95437, which makes GDB not know about a typedef for
"NS1::NS2::AliasTempl<int>". GCC emits a typedef named
"NS1::NS2::AliasTempl" instead, with no template parameter info. The
test passes with Clang (5.0.2 at least). See more details here:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95437
gdb/ChangeLog:
2020-05-30 Pedro Alves <palves@redhat.com>
* cp-support.c (replace_typedefs_template): New.
(replace_typedefs_qualified_name): Handle
DEMANGLE_COMPONENT_TEMPLATE.
gdb/testsuite/ChangeLog:
2020-05-30 Pedro Alves <palves@redhat.com>
* gdb.linespec/cp-replace-typedefs-ns-template.cc: New.
* gdb.linespec/cp-replace-typedefs-ns-template.exp: New.
|