aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2025-02-19gdb/dwarf: std::unordered_{set,map} -> gdb::unordered_{set,map} throughoutSimon Marchi8-35/+27
No behavior changes expected. Change-Id: I16ff6c67058362c65cc8edb05d1948e48be6b2e1 Approved-By: Tom Tromey <tom@tromey.com>
2025-02-19gdb/remote: don't error if qGetTIBAddr is unsupportedQwinci1-4/+2
This change makes it possible to debug PE executables run in e.g. Qemu without needing to set osabi to none, it breaks backtrace and commands like finish if frame pointers are not present but SEH unwind info is. Approved-By: Tom Tromey <tom@tromey.com>
2025-02-19gdb: LoongArch: Extend the maximum number of hardware watchpointsHui Li2-3/+3
The maximum number of load/store watchpoints and fetch instruction watchpoints is 14 each according to LoongArch Reference Manual [1], so extend the maximum number of hardware watchpoints from 8 to 14. A new struct user_watch_state_v2 was added into uapi in the related kernel commit 531936dee53e ("LoongArch: Extend the maximum number of watchpoints") [2], but there may be no struct user_watch_state_v2 in the system header in time. Modify the struct loongarch_user_watch_state in GDB which is same with the uapi struct user_watch_state_v2. As far as I can tell, the only users for this struct in the userspace are GDB and LLDB, there are no any problems of software compatibility between the application and kernel according to the analysis. The compatibility problem has been considered while developing and testing. When the applications in the userspace get watchpoint state, the length will be specified which is no bigger than the sizeof struct user_watch_state or user_watch_state_v2, the actual length is assigned as the minimal value of the application and kernel in the generic code of ptrace: kernel/ptrace.c: ptrace_regset(): kiov->iov_len = min(kiov->iov_len, (__kernel_size_t) (regset->n * regset->size)); if (req == PTRACE_GETREGSET) return copy_regset_to_user(task, view, regset_no, 0, kiov->iov_len, kiov->iov_base); else return copy_regset_from_user(task, view, regset_no, 0, kiov->iov_len, kiov->iov_base); For example, there are four kind of combinations, all of them work well. (1) "older kernel + older app", the actual length is 8+(8+8+4+4)*8=200; (2) "newer kernel + newer app", the actual length is 8+(8+8+4+4)*14=344; (3) "older kernel + newer app", the actual length is 8+(8+8+4+4)*8=200; (4) "newer kernel + older app", the actual length is 8+(8+8+4+4)*8=200. BTW, LLDB also made this change in the related commit ff79d83caeee ("[LLDB][LoongArch] Extend the maximum number of watchpoints") [3] [1] https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html#control-and-status-registers-related-to-watchpoints [2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=531936dee53e [3] https://github.com/llvm/llvm-project/commit/ff79d83caeee Signed-off-by: Hui Li <lihui@loongson.cn> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
2025-02-19bintuils/dwarf.c indentation fixesAlan Modra1-62/+59
plus a few other formatting fixes.
2025-02-19binutils/dwarf.c debug_information leakAlan Modra1-5/+3
It is possible with fuzzed files to have num_debug_info_entries zero after allocating space for debug_information, leading to multiple allocations. * dwarf.c (process_debug_info): Don't test num_debug_info_entries to determine whether debug_information has been allocated, test alloc_num_debug_info_entries.
2025-02-19gdbserver, remote: introduce "id_str" in the "qXfer:threads:read" XMLTankut Baris Aktemur6-3/+61
GDB prints the target id of a thread in various places such as the output of the "info threads" command in the "Target Id" column or when switching to a thread. A target can define what to print for a given ptid by overriding the `pid_to_str` method. The remote target is a gateway behind which one of many various targets could be running. The remote target converts a given ptid to a string in a uniform way, without consulting the low target at the server-side. In this patch we introduce a new attribute in the XML that is sent in response to the "qXfer:threads:read" RSP packet, so that a low target at the server side, if it wishes, can specify what to print as the target id of a thread. Note that the existing "name" attribute or the "extra" text provided in the XML are not sufficient for the server-side low target to achieve the goal. Those attributes, when present, are simply appended to the target id by GDB. Reviewed-By: Eli Zaretskii <eliz@gnu.org> Reviewed-By: Thiago Jung Bauermann <thiago.bauermann@linaro.org> Approved-By: Simon Marchi <simon.marchi@efficios.com>
2025-02-19Automatic date update in version.inGDB Administrator1-1/+1
2025-02-19PR32715, ld-elf/pr29072 fail with --disable-default-execstackAlan Modra1-4/+6
--disable-default-stack is an alias for --enable-default-execstack=no. The existing check only looked for the latter config option. PR 32715 * testsuite/ld-elf/elf.exp (target_defaults_to_execstack): Look in config.h for result of --enable-default-execstack.
2025-02-19PR32716, objdump -i memory leakAlan Modra1-0/+1
PR binutils/32716 * bucomm.c (display_info): Free arg.info.
2025-02-18PR32703, Null pointer dereference in bfd/linker.cAlan Modra2-2/+12
NULL is a possible return from bfd_section_already_linked_table_lookup if out-of-memory. PR 32703 * linker.c (_bfd_generic_section_already_linked): Catch bfd_section_already_linked_table_lookup failure. * coffgen.c (_bfd_coff_section_already_linked): Likewise.
2025-02-18testsuite, mi: prevent buffer overflow in get_mi_thread_listTankut Baris Aktemur1-25/+26
If there is a large number of threads in the input program, the expect buffer in `get_mi_thread_list` would become full. Prevent this by consuming the buffer in small pieces. Regression-tested using the gdb.mi tests. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2025-02-18[gdb/testsuite] Don't start gdb in gdb.base/gstack.expTom de Vries1-2/+2
In test-case gdb.base/gstack.exp we start a gdb implicitly using prepare_for_testing. The gdb is not really used, but its spawn_id (available in variable gdb_spawn_id) is used in a gdb_test_multiple, which is used to interact with the gstack process. Usually, a running gdb is cleaned up at test-case exit in gdb_finish, which calls gdb_exit, which by default calls gdb_default_exit, which does 'send_gdb "quit\n"'. However, this sends a quit to the host process expect is currently talking to, defined by board_info(host,fileid), and after spawning gstack that's gstack, not gdb. Fix this by: - using build_executable instead of prepare_for_testing to not spawn an unused gdb, and - changing the gdb_test_multiple into a gdb_expect, eliminating the implicit use of gdb_spawn_id. Tested on x86_64-linux. Reviewed-By: Keith Seitz <keiths@redhat.com> PR testsuite/32709 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32709
2025-02-18[gdb] Fix some typosTom de Vries5-7/+7
Fix typos: ... overriden -> overridden reate -> create ... Tested on x86_64-linux. I
2025-02-18ld: Add tests for PR ld/32690H.J. Lu4-0/+3456
Without commit 230a788eb28a64d628e623068c44add2a24aa5d3 Author: Alan Modra <amodra@gmail.com> Date: Tue Feb 18 08:54:06 2025 +1030 PR32690, assertion failure in lang_size_relro_segment this test triggers the linker error: .../ld: internal error .../ld/ldlang.c 6618 collect2: error: ld returned 1 exit status with GCC 10 or above on x86-64. PR ld/32690 * testsuite/ld-elf/elf.exp: Run PR ld/32690 tests. * testsuite/ld-elf/pr32690.h: New file. * testsuite/ld-elf/pr32690a.c: Likewise. * testsuite/ld-elf/pr32690b.c: Likewise. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-02-18Re: bfd_set_section_alignment errors.Alan Modra1-5/+4
Fix another one for aarch64.
2025-02-18Use bfd_link_align_section in a few more placesAlan Modra8-27/+16
Some of these aren't relevant to the relro bug. Some are. They all matter if early estimation of section layout needs to be good. PR ld/32690 * elf32-bfin.c (bfin_adjust_dynamic_symbol), * elf32-hppa.c (elf32_hppa_late_size_sections), * elf32-microblaze.c (microblaze_elf_adjust_dynamic_symbol), * elf32-nds32.c (nds32_elf_adjust_dynamic_symbol), * elf64-ppc.c (size_global_entry_stubs), * elflink.c (_bfd_elf_tls_setup), * elfxx-mips.c (mips_elf_add_la25_intro), (mips_elf_add_la25_trampoline), (_bfd_mips_elf_adjust_dynamic_symbol), * elfxx-x86.c (_bfd_x86_elf_late_size_sections): Use bfd_link_align_section to ensure correct output section alignment.
2025-02-18Automatic date update in version.inGDB Administrator1-1/+1
2025-02-18bfd_set_section_alignment errorsAlan Modra2-42/+25
I noticed when making the change from "einfo" to "fatal" that the alignment error in _bfd_elf_link_create_gnu_property_sec lacked a %P, and then decided that a bfd_set_section_alignment that can't happen does not merit a separate error message. elfxx-x86.c had copied the same code, so fix that too. In fact, every bfd_set_section_alignment call in elfxx-x86.c will always return true absent some future programming error. This patch makes those that accompany making a section lose their "failed to align " error and share the "failed to create" error. Those that are changing alignment of a section created elsewhere now abort on bfd_set_section_alignment returning false.
2025-02-18PR 32603, more ld -w misbehaviourAlan Modra34-103/+102
Commit 8d97c1a53f3d claimed to replace all einfo calls using %F with a call to fatal. It did so only for the ld/ directory. This patch adds a "fatal" to linker callbacks, and replaces those calls in bfd/ too.
2025-02-18PR32690, assertion failure in lang_size_relro_segmentAlan Modra3-7/+46
This introduces a new function which should be used whenever the linker needs to increase section alignment after mapping input to output sections. PR ld/32690 * linker.c (bfd_link_align_section): New function. * elflink.c (_bfd_elf_adjust_dynamic_copy): Use it. * bfd-in2.h: Regenerate.
2025-02-17gdb/dwarf: make maybe_queue_comp_unit return boolSimon Marchi1-2/+2
Change-Id: I9a6bf27b72f7efb1cc4cea5345db14969e794bdb
2025-02-17gdb/dwarf: remove spurious spaceSimon Marchi1-1/+1
Change-Id: I420280721cb734a2e061743309bf9b25d2179f8f
2025-02-17gdb: remove unused include in symfile-debug.cSimon Marchi1-1/+0
This is reported as unused by clangd. Change-Id: Ida5a93b632cd4477fb91df1ab0edf66f12a28f64
2025-02-17gdb: remove unused include in objfiles.hSimon Marchi1-1/+0
clangd reports this include as unused. Change-Id: I6a4224d8aa581fea2336da124c89ade09f573af3
2025-02-17testsuite, mi: fix indentation in get_mi_thread_listTankut Baris Aktemur1-29/+29
The `get_mi_thread_list` procedure's body is incorrectly indented. Fix it. There is one line that was already long. Consider it an exception and don't bother breaking it.
2025-02-17Automatic date update in version.inGDB Administrator1-1/+1
2025-02-16gdb: fix color_option_def compile error (clang)Andrew Oates1-1/+1
color_option_def was added in commit 6447969d0 ("Add an option with a color type."), but not used. The color_option_def constructor passes the wrong number of arguments to the option_def constructor. Since color_option_def is a template and never actually instantiated, GCC does not fail to compile this. clang generates an error (see below). This passes nullptr to the extra_literals_ option_def ctor argument, which matches what filename_option_def above it does. clang's generated error: ../../gdb/cli/cli-option.h:343:7: error: no matching constructor for initialization of 'option_def' : option_def (long_option_, var_color, ^ ~~~~~~~~~~~~~~~~~~~~~~~~ ../../gdb/cli/cli-option.h:50:13: note: candidate constructor not viable: requires 8 arguments, but 7 were provided constexpr option_def (const char *name_, ^ ../../gdb/cli/cli-option.h:37:8: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 7 were provided struct option_def ^ ../../gdb/cli/cli-option.h:37:8: note: candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 7 were provided Approved-By: Tom de Vries <tdevries@suse.de>
2025-02-16Automatic date update in version.inGDB Administrator1-1/+1
2025-02-16score-elf gas SEGVAlan Modra4-2/+18
Commit 3fb6f5457e5b typoed an array subscript. * config/tc-score7.c (s7_gen_reloc): Correct array subscript. * testsuite/gas/score/pr32700.d, * testsuite/gas/score/pr32700.s: New test. * testsuite/gas/score/relax.exp: Run it.
2025-02-16PR32698, potential null pointer dereference in tekhex.cAlan Modra1-24/+20
PR 32698 * tekhex.c (find_chunk): Remove unnecessary casts. (insert_byte): Check and return status from find_chunk. (move_section_contents): Likewise. (tekhex_get_section_contents, tekhex_set_arch_mach): Return status from move_section_contents. (first_phase): Check and return status from first_phase.
2025-02-16riscv disassembler leakAlan Modra1-1/+4
Commit 3f61a38b5e81 moved the disassembler subset_list from a static variable to disassembler private_data. It is now malloc'd in riscv_init_disasm_info so should be freed when disassemble_free_target runs. * riscv-dis.c (disassemble_free_riscv): Free subset_list.
2025-02-15MIPS objdump: Add `eabi32` and `eabi64` ABI optionsAnghelo Carvajal6-0/+114
Extend gpr and fpr register names with names suitable for both EABIs. Heavily inspired by the EABI documenation written by Eric Christopher, which can be read at https://sourceware.org/legacy-ml/binutils/2003-06/msg00436.html 2025-02-15 Anghelo Carvajal <angheloalf95@gmail.com> * mips-dis.c (mips_fpr_names_eabi32): New variable. (mips_fpr_names_eabi64): New variable. (mips_abi_choices): Add "eabi32" and "eabi64" options. Signed-off-by: Anghelo Carvajal <angheloalf95@gmail.com>
2025-02-15MIPS/GAS/testsuite: Reuse n64 GPR disassembly for n32Maciej W. Rozycki1-39/+1
The MIPS ABI register names are the same between n64 and n32, so remove duplication and use n64 GPR disassembly output for the n32 test as well. The tests were developed long before we gained output reuse support.
2025-02-15MIPS/GAS: Fix comment about "img" vendor configurationsMaciej W. Rozycki2-2/+2
Adjust a comment about "img" vendor configurations to comply with the GNU coding standards.
2025-02-15MIPS/GAS: Set default CPU to MIPS64r6 for 64-bit "img" configurationsMaciej W. Rozycki3-2/+9
Fix broken commit 070961b377b3 ("MIPS: Set r6 as default arch if vendor is img") that sets up GAS in an inconsistent way where "img" vendor has been used with a 64-bit configuration, such as `mips64-img-linux-gnu'. In that case GAS is set up to use a 64-bit ABI by default combined with the MIPS32r6 CPU, which is 32-bit. Consequently GAS always fails to assemble even trivial input, producing a message such as: Assembler messages: Error: -march=mips32r6 is not compatible with the selected ABI .../gas/testsuite/gas/all/nop.s:2: Error: `gp=32' used with a 64-bit ABI unless the defaults have been suitably overridden either for the ABI or the CPU. Set the default CPU to MIPS64r6 for 64-bit "img" vendor configurations then and adjust the GAS testsuite accordingly, removing 1048 FAIL and 3 ERROR regression test results for the `mips64-img-linux-gnu' and `mips64el-img-linux-gnu' targets each.
2025-02-15MIPS/GAS/testsuite: Support negated targets for default architectureMaciej W. Rozycki1-5/+13
Add support for giving negated targets in the list of targets passed to `mips_arch_create' for the purpose of setting the default architecture. This is so that a subset of targets can be excluded from matching within a broader set of targets.
2025-02-15alpha, ld: remove -taso optionIvan Kokshaysky4-38/+3
The -taso switch was quite useful 25 years ago for porting 32-bit code with broken integer-pointer casting. Not anymore. The EF_ALPHA_32BIT Linux support is going to be dropped in kernel v6.14 [1], NetBSD and OpenBSD never had it, so there is no point in keeping the -taso option around. Also remove alpha special case that uses -taso from gdb.base/dump.exp in gdb testsuite. [1] https://lore.kernel.org/all/87jzb2tdb7.fsf_-_@email.froward.int.ebiederm.org Signed-off-by: Ivan Kokshaysky <ink@unseen.parts> Reviewed-By: Maciej W. Rozycki <macro@orcam.me.uk> Approved-By: Andrew Burgess <aburgess@redhat.com>
2025-02-15Automatic date update in version.inGDB Administrator1-1/+1
2025-02-14gdb/testsuite: clean ups in gdb.python/py-source-styling.expAndrew Burgess1-8/+8
The top comment in gdb.python/py-source-styling.exp was completely wrong, clearly a cut&paste job from elsewhere. Write a comment that actually reflects what the test does. I've also moved the allow_python_tests check earlier in the file. And I changed some 'return -1' into just 'return'. I'm not aware that the '-1' adds any value. I also folded a 'pass $gdb_test_name' into the preceding gdb_assert, which I think is neater. There is no change in what is actually being tested after this commit. Approved-By: Tom Tromey <tom@tromey.com>
2025-02-14gdb/tui: use maybe_update for source centring in an extra caseAndrew Burgess3-1/+89
I noticed that, with recent versions of GDB, when the TUI is enabled before the inferior is started, the source code display is not as helpful as it used to be. Here's a simple test program being displayed using GDB 15.2, at this point the inferior has not started, all I've done is 'tui enable': ┌─hello.c────────────────────────────────────────────────┐ │ 10 return 0; │ │ 11 } │ │ 12 │ │ 13 /* The main function. */ │ │ 14 │ │ 15 int │ │ 16 main () │ │ 17 { │ │ 18 printf ("Hello World\n"); │ │ 19 call_me ( 0, 1, 2, 3, 4, 5, 6, 7 ); │ │ 20 return 0; │ │ 21 } │ │ │ │ │ └────────────────────────────────────────────────────────┘ Compare this to GDB 16.2: ┌─hello.c────────────────────────────────────────────────┐ │ 17 { │ │ 18 printf ("Hello World\n"); │ │ 19 call_me ( 0, 1, 2, 3, 4, 5, 6, 7 ); │ │ 20 return 0; │ │ 21 } │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ └────────────────────────────────────────────────────────┘ I think the new layout is not as good because it is missing the context of the function name. The new behaviour started with the commit: commit 49e607f511c1fab82a0116990a72d1915c74bb4a Author: Stephan Rohr <stephan.rohr@intel.com> Date: Sat Aug 3 02:07:42 2024 -0700 gdb: adjust the default place of 'list' to main's prologue I don't think the new behaviour is really a problem with that commit, rather, when using 'tui enable' before the inferior has started GDB ends up calling tui_source_window_base::rerender(), and then passes through the code path which calls update_source_window_with_addr(). When using 'tui enable' after the inferior has started, GDB again calls tui_source_window_base::rerender(), but this time has a frame, and so takes the second code path, which centres the selected source line, and then calls update_source_window. The point is that the update_source_window_with_addr() path doesn't include the logic to centre the source line. Before the above commit this was fine as GDB's default location would be prior to main, and so we got the "good" TUI output. After the above commit the default location is now main's prologue, and without the centring logic, the first line shown is main's prologue. I propose fixing this by having update_source_window_with_addr() call maybe_update(). This will first check if the requested line is already visible, and if not, show the requested line with centring applied. After this commit, the 'tui enable' state is now: ┌─hello.c─────────────────────────────────────────────────────┐ │ 11 } │ │ 12 │ │ 13 /* The main function. */ │ │ 14 │ │ 15 int │ │ 16 main () │ │ 17 { │ │ 18 printf ("Hello World\n"); │ │ 19 call_me ( 0, 1, 2, 3, 4, 5, 6, 7 ); │ │ 20 return 0; │ │ 21 } │ │ │ │ │ │ │ └─────────────────────────────────────────────────────────────┘ It's not identical to the old behaviour, but that was never the objective, we do however, see the context around main's prologue, which will usually be enough to see the function name and return type, which I think is useful. Approved-By: Tom Tromey <tom@tromey.com>
2025-02-14gdb/tui: update maybe_update to take gdbarchAndrew Burgess6-12/+11
This is a refactor to setup for the next commit. The maybe_update function currently takes a frame_info_ptr&, however, it only uses this to get the frame's gdbarch. In the next commit I want to call maybe_update when I have a gdbarch, but no frame_info_ptr& (the inferior hasn't even started). So, update maybe_update to take the gdbarch, and update the callers to pass that through. Most callers already have the gdbarch to hand, but in one place I do need to extract this from the frame_info_ptr&. There should be no user visible changes after this commit. Approved-By: Tom Tromey <tom@tromey.com>
2025-02-14Handle DW_FORM_data4 in read-debug-names.cTom Tromey1-3/+17
The recent .debug_names patches caused the writer to emit DW_FORM_data4. Unfortunately the reader did not handle this form. This patch updates the reader to handle a few DW_FORM_data* forms. The complaint that is there went unnoticed -- I only found this when debugging a failure in another series. More evidence, IMO, that complaints should be removed. I think the reason the failure itself went unnoticed is that the symbol table code in gdb often works by accident, and in particular in small programs like the ones in the test suite, it's often the case that a CU will be expanded for some other reason, causing the test to pass without really touching the index code. The aforementioned series is aimed at fixing this. It would probably be good to unify the abbrev/form code to some degree, but it's mildly a pain as some forms don't make sense here and because we recently discovered other issues with gdb's DW_FORM_data* handling. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2025-02-14gdbserver: use `gdb::unordered_map`Simon Marchi3-7/+6
Replace the few uses of `std::unordered_map` in gdbserver with `gdb::unordered_map`. The only one of these that is likely to ever see a lot of elements is probably `process_info::m_ptid_thread_map`. It was added precisely to improve performance when there are a lot of threads, so I guess using `gdb::unordered_map` here won't hurt. I changed the others too, since it's easy. Change-Id: Ibc4ede5245551fdd7717cb349a012d05726f4363 Reviewed-By: Stephan Rohr <stephan.rohr@intel.com>
2025-02-14gdb/dwarf: unique_ptr cleanupSimon Marchi14-55/+67
Throughout gdb/dwarf2, use `*_up` typedefs. Add a few missing typedefs, and move some so they are, ideally, just after the corresponding class. Change-Id: Iab5cd8fc2e9989d4bd8d4868586703c2312f254f Approved-By: Tom Tromey <tom@tromey.com>
2025-02-14gdb/dwarf: rename cooked_index_worker subclassesSimon Marchi2-10/+10
Rename them to include "worker" in the name. Otherwise, it's easy to be confused and think that they are sub-classes of "cooked_index". Change-Id: I625ef076f9485f3873db530493f60a53d02c1991 Approved-By: Tom Tromey <tom@tromey.com>
2025-02-14gdb/dwarf: use term "shard" instead of "index"Simon Marchi2-10/+11
A bit more changes as in 8e745eac7db3 ("gdb/dwarf: rename cooked_index::m_vector to m_shards"). I think it's clearer if the term "index" is reserved for the whole thing, while "shard" or "index shard" are used for the parts. Change-Id: I457bb0016a70f3f9918f4a3c3977262a7801705b Approved-By: Tom Tromey <tom@tromey.com>
2025-02-14gdb/python/dap: prefix internal attributes with underscoreSimon Marchi7-118/+116
I'm currently reading the DAP code, and I think this would help. This is pretty much standard Python style, we do it as some places but not others. I think it helps readability, by saying that this attribute isn't mean to be accessed outside the class. A similar pass could be done for internal methods, I haven't done that. Change-Id: I8e8789b39adafe62d14404d19f7fc75e2a364e01 Approved-By: Tom Tromey <tom@tromey.com>
2025-02-14gdb: only update m_last_subfile after writing a line table entryAndrew Burgess3-3/+264
While working on another patch which changes how we parse the line DWARF line tables I noticed what I think is a minor bug in how we process the line tables. What I noticed is that my new line table parser was adding more END markers into the parsed table than GDB's current approach. This difference was observed when processing the debug information for libstdc++. Here is the line table from the new test, this is a reasonable reproduction of the problem case that I observed in the actual debug line table: Contents of the .debug_line section: dw2-skipped-line-entries-1.c: File name Line number Starting address View Stmt dw2-skipped-line-entries-1.c 101 0x40110a x /tmp/dw2-skipped-line-entries-2.c: dw2-skipped-line-entries-2.c 201 0x401114 x /tmp/dw2-skipped-line-entries-3.c: dw2-skipped-line-entries-3.c 301 0x40111e x /tmp/dw2-skipped-line-entries-1.c: dw2-skipped-line-entries-1.c 102 0x401128 x dw2-skipped-line-entries-1.c 103 0x401128 x dw2-skipped-line-entries-1.c 104 0x401128 x /tmp/dw2-skipped-line-entries-2.c: dw2-skipped-line-entries-2.c 211 0x401128 /tmp/dw2-skipped-line-entries-3.c: dw2-skipped-line-entries-3.c 311 0x401132 /tmp/dw2-skipped-line-entries-1.c: dw2-skipped-line-entries-1.c 104 0x40113c dw2-skipped-line-entries-1.c 105 0x401146 x dw2-skipped-line-entries-1.c - 0x401150 The problem is caused by the entry for line 211. Notice that this entry is at the same address as the previous entries. Further, the entry for 211 is a non-statement entry, while the previous entries are statement entries. As the entry for line 211 is a non-statement entry, and the previous entries at that address are statement entries in a different symtab, it is thought that it is better to prefer the earlier entries (in dw2-skipped-line-entries-1.c), and so the entry for line 211 will be discarded. As GDB parses the line table it switches between the 3 symtabs (based on source filename) adding the relevant entries to each symtab. Additionally, as GDB switches symtabs, it adds an END entry to the previous symtab. The problem then is that, for the line 211 entry, this is the only entry in dw2-skipped-line-entries-2.c before we switch symtab again. But the line 211 entry is discarded. This means that GDB switches from dw2-skipped-line-entries-1.c to dw2-skipped-line-entries-2.c, and then on to dw2-skipped-line-entries-3.c without ever adding an entry to dw2-skipped-line-entries-2.c. And here then is the bug. GDB updates its idea of the previous symtab not when an entry is written into a symtab, but every time we change symtab. In this case, when we switch to dw2-skipped-line-entries-3.c we add the END marker to dw2-skipped-line-entries-2.c, even though no entries were written to dw2-skipped-line-entries-2.c. At the same time, no END marker is ever written into dw2-skipped-line-entries-1.c as the dw2-skipped-line-entries-2.c entry (for line 211) was discarded. Here is the 'maint info line-table' for dw2-skipped-line-entries-1.c before this patch: INDEX LINE REL-ADDRESS UNREL-ADDRESS IS-STMT PROLOGUE-END EPILOGUE-BEGIN 0 101 0x000000000040110a 0x000000000040110a Y 1 END 0x0000000000401114 0x0000000000401114 Y 2 102 0x0000000000401128 0x0000000000401128 Y 3 103 0x0000000000401128 0x0000000000401128 Y 4 104 0x0000000000401128 0x0000000000401128 Y 5 104 0x000000000040113c 0x000000000040113c 6 105 0x0000000000401146 0x0000000000401146 Y 7 END 0x0000000000401150 0x0000000000401150 Y And after this patch: INDEX LINE REL-ADDRESS UNREL-ADDRESS IS-STMT PROLOGUE-END EPILOGUE-BEGIN 0 101 0x000000000040110a 0x000000000040110a Y 1 END 0x0000000000401114 0x0000000000401114 Y 2 102 0x0000000000401128 0x0000000000401128 Y 3 103 0x0000000000401128 0x0000000000401128 Y 4 104 0x0000000000401128 0x0000000000401128 Y 5 END 0x0000000000401132 0x0000000000401132 Y 6 104 0x000000000040113c 0x000000000040113c 7 105 0x0000000000401146 0x0000000000401146 Y 8 END 0x0000000000401150 0x0000000000401150 Y Notice that we gained an extra entry, the END marker that was added at position #5 in the table. Now, does this matter? I cannot find any bugs that trigger because of this behaviour. So why fix it? First, the current behaviour is inconsistent, as we switch symtabs, we usually get an END marker in the previous symtab. But occasionally we don't. I don't like things that are inconsistent for no good reason. And second, as I said, I want to change the line table parsing. To do this I want to check that my new parser creates an identical table to the current parser. But my new parser naturally "fixes" this inconsistency, so I have two choices, do extra work to make my new parser bug-compatible with the current one, or fix the current one. I'd prefer to just fix the current line table parser. There's a test that includes the above example and checks that the END markers are put in the correct place. But as I said, I've not been able to trigger any negative behaviour from the current solution, so there's no test that exposes any broken behaviour. Approved-By: Tom Tromey <tom@tromey.com>
2025-02-14x86: drop redundant i.operands checks from output_disp()Jan Beulich1-3/+0
The opcode space, major opcode, and - where applicable - opcode extension checks fully qualify the insns we're after; operand matching has been done far earlier, so wrong operand counts cannot occur here.
2025-02-14x86: drop redundant checks from ISA-used version determinationJan Beulich1-2/+0
All F16C and all FMA insns are VEX-encoded; there's no need to check for their Cpu* attributes.