aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2021-04-27Fix timeout with maint print objfilesLuis Machado6-15/+26
I'm seeing timeouts from gdb.rust/traits.exp when we attempt to print things with "maint print objfiles". This happens for two reasons: 1 - GDB does not explicitly split each entry into its own line, but rather relies on the terminal's width to insert line breaks. 2 - When running the GDB testsuite, such width may be unlimited, which will prevent GDB from inserting any line breaks. As a result, the output may be too lengthy and will come in big lines. Tweak the support library to match the patterns line-by-line, which gives us more time to match things. Also fix GDB's output to print one entry per line, regardless of the terminal width. A similar approach was used in another testcase using the same command (commit eaeaf44cfdc9a4096a0dd52fa0606f29d4bfd48e). With the new line breaks, we don't need a particular pattern, so clean up that test as well. gdb/ChangeLog: 2021-04-27 Luis Machado <luis.machado@linaro.org> * psymtab.c (psymbol_functions::dump): Output newline. * symmisc.c (dump_objfile): Likewise. gdb/testsuite/ChangeLog: 2021-04-27 Luis Machado <luis.machado@linaro.org> * gdb.base/maint.exp: Drop a pattern that is not needed. * lib/gdb.exp (readnow): Match line-by-line.
2021-04-27Fix timeout for gdb.xml/tdesc-reload.expLuis Machado2-2/+9
For aarch64, the "info all-registers" output is very verbose. If you run this test using read1, it will timeout before the command output is done being read. Read line-by-line so we don't run into timeouts. gdb/testsuite/ChangeLog: 2021-04-27 Luis Machado <luis.machado@linaro.org> * gdb.xml/tdesc-reload.exp: Pass -lbl.
2021-04-27gdb: do autoload before notifying Python side in new_objfile eventMichael Weghorn11-3/+303
Without any explicit dependencies specified, the observers attached to the 'gdb::observers::new_objfile' observable are always notified in the order in which they have been attached. The new_objfile observer callback to auto-load scripts is attached in '_initialize_auto_load'. The new_objfile observer callback that propagates the new_objfile event to the Python side is attached in 'gdbpy_initialize_inferior', which is called via '_initialize_python'. With '_initialize_python' happening before '_initialize_auto_load', the consequence was that the new_objfile event was emitted on the Python side before autoloaded scripts had been executed when a new objfile was loaded. As a result, trying to access the objfile's pretty printers (defined in the autoloaded script) from a handler for the Python-side 'new_objfile' event would fail. Those would only be initialized later on (when the 'auto_load_new_objfile' callback was called). To make sure that the objfile passed to the Python event handler is properly initialized (including its 'pretty_printers' member), make sure that the 'auto_load_new_objfile' observer is notified before the 'python_new_objfile' one that propagates the event to the Python side. To do this, make use of the mechanism to explicitly specify dependencies between observers (introduced in a preparatory commit). Add a corresponding testcase that involves a test library with an autoloaded Python script and a handler for the Python 'new_objfile' event. (The real world use case where I came across this issue was in an attempt to extend handling for GDB pretty printers for dynamically loaded objfiles in the Qt Creator IDE, s. [1] and [2] for more background.) [1] https://bugreports.qt.io/browse/QTCREATORBUG-25339 [2] https://codereview.qt-project.org/c/qt-creator/qt-creator/+/333857/1 Tested on x86_64-linux (Debian testing). gdb/ChangeLog: * gdb/auto-load.c (_initialize_auto_load): 'Specify token when attaching the 'auto_load_new_objfile' observer, so other observers can specify it as a dependency. * gdb/auto-load.h (struct token): Declare 'auto_load_new_objfile_observer_token' as token to be used for the 'auto_load_new_objfile' observer. * gdb/python/py-inferior.c (gdbpy_initialize_inferior): Make 'python_new_objfile' observer depend on 'auto_load_new_objfile' observer, so it gets notified after the latter. gdb/testsuite/ChangeLog: * gdb.python/libpy-autoloaded-pretty-printers-in-newobjfile-event.so-gdb.py: New test. * gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event-lib.cc: New test. * gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event-lib.h: New test. * gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event-main.cc: New test. * gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event.exp: New test. * gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event.py: New test. Change-Id: I8275b3f4c3bec32e56dd7892f9a59d89544edf89
2021-04-27gdbsupport: allow to specify dependencies between observersMichael Weghorn4-16/+235
Previously, the observers attached to an observable were always notified in the order in which they had been attached. That order is not easily controlled, because observers are typically attached in _initialize_* functions, which are called in an undefined order. However, an observer may require that another observer attached only later is called before itself is. Therefore, extend the 'observable' class to allow explicitly specifying dependencies when attaching observers, by adding the possibility to specify tokens for observers that it depends on. To make sure dependencies are notified before observers depending on them, the vector holding the observers is sorted in a way that dependencies come before observers depending on them. The current implementation for sorting uses the depth-first search algorithm for topological sorting as described at [1]. Extend the observable unit tests to cover this case as well. Check that this works for a few different orders in which the observers are attached. This newly introduced mechanism to explicitly specify dependencies will be used in a follow-up commit. [1] https://en.wikipedia.org/wiki/Topological_sorting#Depth-first_search Tested on x86_64-linux (Debian testing). gdb/ChangeLog: * unittests/observable-selftests.c (dependency_test_counters): New. (observer_token0, observer_token1, observer_token2, observer_token3, observer_token4, observer_token5): New. (struct dependency_observer_data): New struct. (observer_dependency_test_callback): New function. (test_observers): New. (run_dependency_test): New function. (test_dependency): New. (_initialize_observer_selftest): Register dependency test. gdbsupport/ChangeLog: * observable.h (class observable): Extend to allow specifying dependencies between observers, keep vector holding observers sorted so that dependencies are notified before observers depending on them. Change-Id: I5399def1eeb69ca99e28c9f1fdf321d78b530bdb
2021-04-27x86: Add () to silence GCC 5H.J. Lu2-1/+7
Add () to !i.prefix[ADDR_PREFIX] to silence GCC 5: gas/config/tc-i386.c:4152:31: error: logical not is only applied to the left hand side of comparison [-Werror=logical-not-parentheses] && !i.prefix[ADDR_PREFIX] != (flag_code == CODE_32BIT)) ^ * config/tc-i386.c (optimize_encoding): Add () to silence GCC 5.
2021-04-27Reject debuglink sections with no associated filename.Nick Clifton2-0/+10
PR 27779 * dwarf.c (parse_gnu_debuglink): Reject empty names. (parse_gnu_debugaltlink): Likewise.
2021-04-26sim: riscv: switch MIN/MAX to common min/maxMike Frysinger2-7/+9
The common sim-basics.h defines min/max already, so use them.
2021-04-26sim: nltvals: unify common syscall tablesMike Frysinger29-508/+117
Since libgloss provides a default syscall table for arches, use that to provide the default syscall table for ports. Only the exceptions need to be enumerated now with the common logic as the default.
2021-04-26sim: enable hardware support by defaultMike Frysinger96-120/+2659
Force this on for all ports. We have a few common models that can be used, so make them generally available. If the port doesn't use any hardware (the default), then behavior is unchanged.
2021-04-26bfd: add stdlib.h when using abortMike Frysinger2-0/+6
Since this file calls abort() now, we need to include stdlib.h for its prototype.
2021-04-27Automatic date update in version.inGDB Administrator1-1/+1
2021-04-26Fix a bug in the ARM emulator which would not allow 4 byte alignment for ↵Nick Clifton2-1/+10
double word stores. PR 22790 * armemu.c (Handle_Store_Double): Allow 4 byte alignment when running in v6 mode.
2021-04-26Add test case for gdb 10 crashTom Tromey4-0/+209
PR gdb/27743 points out a gdb crash when expanding partial symtabs, where one of the compilation units uses DW_TAG_imported_unit. This crash happens for gdb 10, but not git trunk. This patch pulls over the new test case only. gdb/testsuite/ChangeLog 2021-04-26 Tom Tromey <tromey@adacore.com> PR gdb/27743: * gdb.dwarf2/imported-unit-bp.exp: New file. * gdb.dwarf2/imported-unit-bp-main.c: New file. * gdb.dwarf2/imported-unit-bp-alt.c: New file.
2021-04-26gdb: check result of gdb_fopen_cloexec in dump_binary_fileSimon Marchi4-0/+24
Bug 27773 shows that passing a filename in a non-existent directory to the "dump binary" command leads to a gdb crash. This is because the gdb_fopen_cloexec in dump_binary_file fails (returns nullptr) and the return value is not checked. Fix that by erroring out if gdb_fopen_cloexec fails. gdb/ChangeLog: PR gdb/27773 * cli/cli-dump.c (dump_binary_file): Check result of gdb_fopen_cloexec. gdb/testsuite/ChangeLog: PR gdb/27773 * gdb.base/dump.exp: Test dump to non-existent dir. Change-Id: Iea89a3bf9e6b9dcc31142faa5ae17bc855759328
2021-04-26Fix gdb.arch/aarch64-dbreg-contents.exp FAILLuis Machado2-1/+6
The test checks for a particular ARCH level, but it needs to check for ARCH levels from a minimum and upwards. gdb/testsuite/ChangeLog: 2021-04-26 Luis Machado <luis.machado@linaro.org> * gdb.arch/aarch64-dbreg-contents.c (set_watchpoint): Fix arch level comparison.
2021-04-26x86: correct overflow checking for 16-bit PC-relative relocsJan Beulich9-2/+40
The only insn requiring a truly 16-bit PC-relative relocation outside of 16-bit mode is XBEGIN (with an operand size override). For it, the relocation generated should behave similar to 8- and (for 64-bit) 32-bit PC-relatives ones, i.e. be checked for a signed value to fit the field. This same mode is also correct for 16-bit code. Outside of 16-bit code, branches with operand size overrides act in a truly PC-relative way only when living in the low 32k of address space, as they truncate rIP to 16 bits. This can't be expressed by a PC-relative relocation. Putting in place a new testcase, I'd like to note that the two existing ones (pcrel16 and pcrel16abs) appear to be pretty pointless: They don't expect any error despite supposedly checking for overflow, and in fact there can't possibly be any error for the - former since gas doesn't emit any relocation in the first place there, - latter because the way the relocation gets expressed by gas doesn't allow the linker to notice the overflow; it should be detected by gas if at all, but see above (an error would be reported here for x86-64 afaict, but this test doesn't get re-used there).
2021-04-26x86: add IS_ELF to check whether to resolve @size relocJan Beulich2-1/+7
This may not be strictly needed, as BFD_RELOC_SIZE* shouldn't appear from elsewhere for non-ELF, but let's be on the safe side.
2021-04-26x86: limit 32-bit @size overflow checks to 64-bit objectsJan Beulich2-0/+6
For 32-bit objects the behavior should not be dependent upon the build being a BFD64 one.
2021-04-26x86: optimize LEAJan Beulich16-10/+576
Over the years I've seen a number of instances where people used lea (%reg1), %reg2 or lea symbol, %reg despite the same thing being expressable via MOV. Since additionally LEA often has restrictions towards the ports it can be issued to, while MOV typically gets dealt with simply by register renaming, transform to MOV when possible (without growing opcode size and without altering involved relocation types). Note that for Mach-O the new 64-bit testcases would fail (for BFD_RELOC_X86_64_32S not having a representation), and hence get skipped there.
2021-04-26x86-64: have value properly checked when resolving fixupJan Beulich5-1/+65
Constants not known at the time an individual insn gets assembled and going into a sign-extended field still shouldn't be silently truncated at the time the respective fixup gets resolved.
2021-04-26gdb: fix sparc build failure of linux-natSergei Trofimovich2-2/+7
On sparc build failed as: ``` gdb/sparc-linux-nat.c: In member function 'virtual void sparc_linux_nat_target::fetch_registers(regcache*, int)': gdb/sparc-linux-nat.c:36:37: error: cannot convert 'regcache*' to 'process_stratum_target*' 36 | { sparc_fetch_inferior_registers (regcache, regnum); } | ^~~~~~~~ | | | regcache* ``` The fix adopts gdb/sparc-nat.h API change in d1e93af64a6 ("gdb: set current thread in sparc_{fetch,collect}_inferior_registers"). gdb/ChangeLog: * sparc-linux-nat.c (sparc_linux_nat_target): fix sparc build by passing `process_stratum_target*` parameter.
2021-04-26Automatic date update in version.inGDB Administrator1-1/+1
2021-04-25[PR gdb/22640] ptype: add option to use hexadecimal notationLancelot SIX12-295/+559
This commit adds a flag to the ptype command in order to print the offsets and sizes of struct members using the hexadecimal notation. The 'x' flag ensures use of the hexadecimal notation while the 'd' flag ensures use of the decimal notation. The default is to use decimal notation. Before this patch, gdb only uses decimal notation, as pointed out in PR gdb/22640. Here is an example of this new behavior with hex output turned on: (gdb) ptype /ox struct type_print_options /* offset | size */ type = struct type_print_options { /* 0x0000: 0x0 | 0x0004 */ unsigned int raw : 1; /* 0x0000: 0x1 | 0x0004 */ unsigned int print_methods : 1; /* 0x0000: 0x2 | 0x0004 */ unsigned int print_typedefs : 1; /* 0x0000: 0x3 | 0x0004 */ unsigned int print_offsets : 1; /* 0x0000: 0x4 | 0x0004 */ unsigned int print_in_hex : 1; /* XXX 3-bit hole */ /* XXX 3-byte hole */ /* 0x0004 | 0x0004 */ int print_nested_type_limit; /* 0x0008 | 0x0008 */ typedef_hash_table *local_typedefs; /* 0x0010 | 0x0008 */ typedef_hash_table *global_typedefs; /* 0x0018 | 0x0008 */ ext_lang_type_printers *global_printers; /* total size (bytes): 32 */ } This patch also adds the 'set print type hex' and 'show print type hex' commands in order to set and inspect the default behavior regarding the use of decimal or hexadecimal notation when printing struct sizes and offsets. Tested using on x86_64. gdb/ChangeLog: PR gdb/22640 * typeprint.h (struct type_print_options): Add print_in_hex flag. (struct print_offset_data): Add print_in_hex flag, add a constructor accepting a type_print_options* argument. * typeprint.c (type_print_raw_options, default_ptype_flags): Set default value for print_in_hex. (print_offset_data::indentation): Allow more horizontal space. (print_offset_data::print_offset_data): Add ctor. (print_offset_data::maybe_print_hole, print_offset_data::update): Handle the print_in_hex flag. (whatis_exp): Handle 'x' and 'd' flags. (print_offsets_and_sizes_in_hex): Declare. (set_print_offsets_and_sizes_in_hex): Create. (show_print_offsets_and_sizes_in_hex): Create. (_initialize_typeprint): Update help message for the ptype command, register the 'set print type hex' and 'show print type hex' commands. * c-typeprint.c (c_print_type, c_type_print_base_struct_union) (c_type_print_base): Construct the print_offset_data object using the type_print_optons parameter. * rust-lang.c (rust_language::print_type): Construct the print_offset_data object using the type_print_optons parameter. * NEWS: Mention the new flags of the ptype command. gdb/doc/ChangeLog: PR gdb/22640 * gdb.texinfo (Symbols): Describe the 'x' and 'd' flags of the ptype command, describe 'set print type hex' and 'show print type hex' commands. Update 'ptype/o' examples. gdb/testsuite/ChangeLog: PR gdb/22640 * gdb.base/ptype-offsets.exp: Add tests to verify the behavior of 'ptype/ox' and 'ptype/od'. Check that 'set print type hex' changes the default behavior of 'ptype/o'. Update to take into account new horizontal layout. * gdb.rust/simple.exp: Update ptype test to check new horizontal layout. * gdb.rust/union.exp: Same.
2021-04-25gdb/typeprint.h: reorder struct declarationLancelot SIX2-30/+35
Move the declaration of struct type_print_raw_options before struct print_offset_data to ease upcoming changes. This is a helper commit intended to make it easier to build a print_offset_data object from configurations given by a type_print_raw_options. gdb/ChangeLog: * typeprint.h (struct type_print_options): Move before print_offset_data.
2021-04-25Add engv32.h to SIM_EXTRA_DEPS in sim/crisTom Tromey2-1/+5
A rebuild showed that an earlier change of mine missed a built header file -- cris/engv32.h. This patch fixes the problem. sim/cris/ChangeLog 2021-04-25 Tom Tromey <tom@tromey.com> * Makefile.in (SIM_EXTRA_DEPS): Add engv32.h.
2021-04-25Use htab_t in sim-options.cTom Tromey2-21/+25
This changes sim-options.c to use the libiberty hash table, rather than its own custom hash table. sim/common/ChangeLog 2021-04-25 Tom Tromey <tom@tromey.com> * sim-options.c (compare_strings): New function. (ARG_HASH_SIZE, ARG_HASH): Remove. (dup_arg_p): Use htab_t. (sim_parse_args): Remove assert.
2021-04-25Document the GDB 10.2 release in gdb/ChangeLogJoel Brobecker1-0/+4
gdb/ChangeLog: GDB 10.2 released.
2021-04-25Automatic date update in version.inGDB Administrator1-1/+1
2021-04-24gdbsupport: add observer_debug_printf, OBSERVER_SCOPED_DEBUG_ENTER_EXITSimon Marchi2-4/+32
Switch observer to use the "new" debug printf mechanism and sprinkle a few debug prints. Here's a small example of the output with "infrun" and "observer" debug output enabled: [infrun] proceed: enter [observer] notify: start: observable target_resumed notify() called [observer] notify: start: calling observer mi-interp of observable target_resumed [observer] notify: end: calling observer mi-interp of observable target_resumed [observer] notify: start: calling observer py-inferior of observable target_resumed [observer] notify: end: calling observer py-inferior of observable target_resumed [observer] notify: end: observable target_resumed notify() called ... gdbsupport/ChangeLog: * observable.h (observer_debug_printf, OBSERVER_SCOPED_DEBUG_START_END): New. (class observable) <notify, attach>: Use them. Change-Id: If3ae4b6b65450ca3b7cae56698a87fc526688b86
2021-04-24gdbsupport: allow passing format string to scoped_debug_start_endSimon Marchi2-12/+68
A little thing that bothers me with scoped_debug_start_end is that it's not possible to pass a format string to add context to the messages: the start and end messages are fixed. It was done like this at the time because there's the risk that debug output is not enabled on entry (when the constructor runs) but is enabled on exit (when the destructor runs). For example, a user debugging from a top-gdb may manually enable a debug_foo variable. If debug output is disabled while the constructor runs, we won't render the format string (to minimize overhead) so it won't be available in the destructor. I think it would be nice to be able to use a format string along with scoped_debug_start_end, and I think it's unfortunate that such a narrow use case prevents it. So with this patch, I propose that we allow passing a format string to scoped_debug_start_end, and if the rare situation described above happens, then we just show a "sorry, message not available" kind of message. The following patch makes use of this. gdbsupport/ChangeLog: * common-debug.h (struct scoped_debug_start_end) <scoped_debug_start_end>: Change start_msg/end_msg for start_prefix/end_prefix. Add format string parameter and make variadic. <~scoped_debug_start_end>: Adjust. <m_end_msg>: Rename to... <m_end_prefix>: ... this. <m_with_format>: New. <m_msg>: New. (scoped_debug_start_end): Make variadic. (scoped_debug_enter_exit): Adjust. Change-Id: I9427ce8877a246a46694b3a1fec3837dc6954d6e
2021-04-24gdbsupport, gdb: give names to observersSimon Marchi47-149/+219
Give a name to each observer, this will help produce more meaningful debug message. gdbsupport/ChangeLog: * observable.h (class observable) <struct observer> <observer>: Add name parameter. <name>: New field. <attach>: Add name parameter, update all callers. Change-Id: Ie0cc4664925215b8d2b09e026011b7803549fba0
2021-04-24gdbsupport: introduce struct observerSimon Marchi2-6/+22
Instead of using a pair. This allows keeping more data per observer in a structured way, and using field names is clearer than first/second. gdbsupport/ChangeLog: * observable.h (class observable) <struct observer>: New. <detach, notify>: Update. <m_observers>: Change type to vector of observers. Change-Id: Iadf7d1fa25049cfb089e6b1b429ddebc548825ab
2021-04-24sim: dv-cfi: fix printf formatMike Frysinger2-1/+5
Use the existing PRI constants to select the right format rather than assume signed_cell is always %u. Fixes building for riscv64.
2021-04-24sim: options: increase max option countMike Frysinger2-1/+9
As we turn on more modules by default for all ports, the number of options has been increasing. The sim-options module has a limit on the number of options it can support, and if it's exceeded, it likes to go into an infinite loop. Increase the ceiling and add an assert so we abort right away instead of hanging. This will be needed to turn on hw support for v850 as it will then exceed the current limit.
2021-04-23sim: simplify hardware m4 macroMike Frysinger30-89/+78
Every port using this sets the 1st arg to yes and the 2nd arg to "". These are the defaults we probably want anyways in order to unify the codebase, so move them to the macro and only allow ports to declare extra hardware models.
2021-04-24Automatic date update in version.inGDB Administrator1-1/+1
2021-04-23gdbsupport, gdb: change observer_debug to boolSimon Marchi4-7/+15
gdb/ChangeLog: * observable.c (observer_debug): Change to bool. gdbsupport/ChangeLog: * observable.h (observer_debug): Change to bool. Change-Id: I58634235a20740a66eacb1c83bae3cf3304ae1fd
2021-04-23ld: Properly create a symbolic link to tmpdir/ldscriptsH.J. Lu2-1/+9
Don't create a symbolic link to tmpdir/ldscripts if it exists. PR ld/27771 * testsuite/ld-bootstrap/bootstrap.exp: Create a symbolic link to tmpdir/ldscripts only if it doesn't exist.
2021-04-23gdbsupport: include preprocessor.h in common-debug.hSimon Marchi2-0/+6
While doing some changes, some code failed to compile because it used the scoped_debug_start_end macro, but couldn't find the CONCAT macro. Fix that by making common-debug.h include preprocessor.h, the header file that provides CONCAT. gdbsupport/ChangeLog: * common-debug.h: Include preprocessor.h. Change-Id: Ibf863a932a18cba9a57b4bd72df538ef52d39127
2021-04-23Fix type of .persistent.bss sectionEric Botcazou6-2/+22
The change implementing the .persistent family of sections broke the existing support for the .persistent.bss section in the compiler: int a __attribute__ ((section (".persistent.bss"))); t.s: Assembler messages: t.s:4: Warning: setting incorrect section type for .persistent.bss The compiler encodes it as @nobits but the assembler expects @progbits. The assembler is incorrect and should treat the section like the compiler. bfd/ * elf.c (special_sections_p): Add .persistent.bss. gas/ * testsuite/gas/elf/section25.d: Run it everywhere. * testsuite/gas/elf/section26.d: Likewise. * testsuite/gas/elf/section26.s: Add test for .persistent.bss.
2021-04-23Allow .seh_pushframe to take an optional [code] parameterJ?r?me Gardou2-1/+25
* config/obj-coff-seh.c (obj_coff_seh_pushframe): Allow an optional "code" argument.
2021-04-23opcodes: xtensa: display loaded literal valueMax Filippov2-1/+24
Display literal value loaded with l32r opcode as a part of disassembly. This significantly simplifies reading of disassembly output. 2020-04-23 Max Filippov <jcmvbkbc@gmail.com> opcodes/ * xtensa-dis.c (print_xtensa_operand): For PC-relative operand of l32r fetch and display referenced literal value.
2021-04-23opcodes: xtensa: improve literal outputMax Filippov2-0/+6
Output literals as 4-byte words, not as separate bytes. 2021-04-23 Max Filippov <jcmvbkbc@gmail.com> opcodes/ * xtensa-dis.c (print_insn_xtensa): Set info->bytes_per_chunk to 4 for literal disassembly.
2021-04-23gdb: remove some caching from the dwarf readerAndrew Burgess5-52/+53
While working on some changes to 'info sources' I ran into a situation where I was seeing the same source files reported twice in the output of the 'info sources' command when using either .gdb_index or the .debug_name index. I traced the problem back to some caching in dwarf2_base_index_functions::map_symbol_filenames; when called GDB caches the set of filenames, but, filesnames are not removed as the index entries are expanded into full symtabs. As a result we can end up seeing filenames reported both from a full symtab _and_ from a (stale) previously cached index entry. Now, obviously, when seeing a problem like this the "correct" fix is to remove the stale entries from the cache, however, I ran a few experiments to see why this wasn't really hitting us anywhere, and, as far as I can tell, ::map_symbol_filenames is only called from three places: 1. The mi command -file-list-exec-source-files, 2. The 'info sources' command, and 3. Filename completion However, the result of this "bug" is that we will see duplicate filenames, and readline's completion mechanism already removes duplicates, so for case #3 we will never see any problems. Cases #1 and #2 are basically the same, and in each case, to see a problem we need to ensure we craft the test in a particular way, start up ensuring we have some unexpected symtabs, then run one of the commands to populate the cache, then expand one of the symtabs, and list the sources again. At this point you'll see duplicate entries in the results. Hardly surprising we haven't randomly hit this situation in testing. So, considering that use cases #1 and #2 are certainly not "high performance" code (i.e. I don't think these justify the need for caching) this leaves use case #3. Does this use justify the need for caching? Well the psymbol_functions::map_symbol_filenames function doesn't seem to do any extra caching, and within dwarf2_base_index_functions::map_symbol_filenames, the only expensive bit appears to be the call to dw2_get_file_names, and this already does its own caching via this_cu->v.quick->file_names. The upshot of all this analysis was that I'm not convinced the need for the additional caching is justified, and so, I propose that to fix the bug in GDB, I just remove the extra caching (for now). If we later find that the caching _was_ useful, then we can reintroduce it, but add it back such that it doesn't reintroduce this bug. As I was changing dwarf2_base_index_functions::map_symbol_filenames I replaced the use of htab_up with std::unordered_set. Tested using target_boards cc-with-debug-names and dwarf4-gdb-index. gdb/ChangeLog: * dwarf2/read.c: Add 'unordered_set' include. (dwarf2_base_index_functions::map_symbol_filenames): Replace 'visited' hash table with 'qfn_cache' unordered_set. Remove use of per_Bfd->filenames_cache cache, and use function local filenames_cache instead. Reindent. * dwarf2/read.h (struct dwarf2_per_bfd) <filenames_cache>: Delete. gdb/testsuite/ChangeLog: * gdb.base/info_sources.exp: Add new tests.
2021-04-23x86: TLS desc call relocs target zero-size fieldsJan Beulich3-2/+9
These are marker relocations, so together with their bit size being zero their byte size should be zero as well. This is expressed by a value of 3, not 0.
2021-04-23x86-64: special case LEA when determining signedness of displacementJan Beulich2-8/+24
LEA behavior without a 64-bit destination is independent of address size - in particular LEA with 32-bit addressing and 64-bit destination is the same as LEA with 64-bit addressing and 32-bit destination. IOW checking merely i.prefix[ADDR_PREFIX] is insufficient. This also means wrong relocation types (R_X86_64_32S when R_X86_64_32 is needed) were used so far in such cases. Note that in one case in build_modrm_byte() the 64-bit check came too early altogether, and hence gets dropped in favor of the one included in the new helper. This is benign to non-64-bit code from all I can tell, but the failure to clear disp16 could have been a latent problem.
2021-04-23x86-64: defer 32-bit signed displacement checkJan Beulich2-19/+34
In preparation for extending the conditions here defer this check until operands have been parsed, as certain further attributes will need to be known for determinig applicability of this check to be correct to LEA.
2021-04-23x86: re-order optimize_disp()Jan Beulich2-16/+23
While I can't point out any specific case where things break, it looks wrong to have the consumer of a flag before its producer. Set .disp32 first, then do the possible conversion to signed 32-bit, and finally check whether the value fits in a signed long.
2021-04-23x86: don't truncate values in diagnostics and alikeJan Beulich2-4/+9
Truncating an expression's X_add_number to just "long" can result in confusing output (e.g. an apparently in-range number claimed to be out of range). Use the abstraction that bfd provides for this. Take the opportunity and also insert a missing "of".
2021-04-22gdb: use function_view for iterate_over_bp_locations' callbackSimon Marchi4-6/+13
Use a function_view instead of function pointer + data. Actually, nothing uses the data anyway, but that makes iterate_over_bp_locations more like iterate_over_breakpoints. gdb/ChangeLog: * breakpoint.c (iterate_over_bp_locations): Change callback to function view, remove data parameter. * breakpoint.h (iterate_over_bp_locations): Likewise. * record-full.c (record_full_sync_record_breakpoints): Remove data parameter. Change-Id: I66cdc94a505f67bc640bcc66865fb535ee939a57