aboutsummaryrefslogtreecommitdiff
path: root/gdb
AgeCommit message (Collapse)AuthorFilesLines
2024-01-10[gdb] Fix assertion failure for checkpoint delete 0Tom de Vries2-0/+25
When doing "checkpoint delete 0" we run into an assertion failure: ... +delete checkpoint 0 inferior.c:406: internal-error: find_inferior_pid: Assertion `pid != 0' failed. ... Fix this by handling the "pptid == null_ptid" case in delete_checkpoint_command. Tested on x86_64-linux. Approved-By: Kevin Buettner <kevinb@redhat.com> PR gdb/31209 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31209
2024-01-10[gdb] Fix info checkpointsTom de Vries2-5/+18
Consider test-case gdb.base/checkpoint.exp. At some point, it issues an info checkpoints command: ... (gdb) info checkpoints^M * 0 process 30570 (main process) at 0x0^M 1 process 30573 at 0x4008bb, file checkpoint.c, line 49^M 2 process 30574 at 0x4008bb, file checkpoint.c, line 49^M 3 process 30575 at 0x4008bb, file checkpoint.c, line 49^M 4 process 30576 at 0x4008bb, file checkpoint.c, line 49^M 5 process 30577 at 0x4008bb, file checkpoint.c, line 49^M 6 process 30578 at 0x4008bb, file checkpoint.c, line 49^M 7 process 30579 at 0x4008bb, file checkpoint.c, line 49^M 8 process 30580 at 0x4008bb, file checkpoint.c, line 49^M 9 process 30582 at 0x4008bb, file checkpoint.c, line 49^M 10 process 30583 at 0x4008bb, file checkpoint.c, line 49^M ... According to the docs, each of these (0-10) is a checkpoint. But the pc address (as well as the file name and line number) is missing for checkpoint 0. Fix this by sampling the pc value for the current process in info_checkpoints_command, such that we have instead: ... * 0 process 30570 (main process) at 0x4008bb, file checkpoint.c, line 49^M ... Tested on x86_64-linux. Approved-By: Kevin Buettner <kevinb@redhat.com> PR gdb/31211 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31211
2024-01-10[gdb] Make variable printed bool in info_checkpoints_commandTom de Vries1-3/+4
While reading info_checkpoints_command, I noticed variable printed: ... const fork_info *printed = NULL; ... for (const fork_info &fi : fork_list) { if (requested > 0 && fi.num != requested) continue; printed = &fi; ... } if (printed == NULL) ... has pointer type, but is just used as bool. Make this explicit by changing the variable type to bool. Tested on x86_64-linux. Approved-By: Kevin Buettner <kevinb@redhat.com>
2024-01-10gdb/symtab: Eliminate deferred_entryTom de Vries3-31/+68
Currently cooked_index entry creation is either: - done immediately if the parent_entry is known, or - deferred if the parent_entry is not yet known, and done later while resolving the deferred entries. Instead, create all cooked_index entries immediately, and keep track of which entries have a parent_entry that needs resolving later using the new IS_PARENT_DEFERRED flag. Tested on x86_64-linux. Approved-By: Tom Tromey <tom@tromey.com>
2024-01-10gdb/symtab: Make cooked_index_entry::parent_entry privateTom de Vries3-16/+29
Make cooked_index_entry::parent_entry private, and add member functions to access it. Tested on x86_64-linux and ppc64le-linux. Tested-By: Alexandra Petlanova Hajkova <ahajkova@redhat.com> Approved-By: Tom Tromey <tom@tromey.com>
2024-01-10gdb/symtab: Allow changing of added cooked_index entriesTom de Vries2-11/+11
Make cooked_index_storage::add and cooked_index_entry::add return a "cooked_index_entry *" instead of a "const cooked_index_entry *". Tested on x86_64-linux and ppc64le-linux. Tested-By: Alexandra Petlanova Hajkova <ahajkova@redhat.com> Approved-By: Tom Tromey <tom@tromey.com>
2024-01-09Fix ASAN failure in DWO codeTom Tromey1-8/+23
Simon pointed out that my recent change to the DWO code caused a failure in ASAN testing. The bug here was I updated the code to use a different search type in the hash table; but then did not change the search code to use htab_find_slot_with_hash. Note that this bug would not be possible with my type-safe hash table series, hint, hint. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2024-01-09Fix thread-less buildTom Tromey1-4/+4
A user pointed out that the recent background DWARF reader series broke the build when --disable-threading is in use. This patch fixes the problem. I am checking it in. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31223
2024-01-09Use unrelocated_addr in dwarf2_base_index_functions::find_per_cuTom Tromey4-12/+14
dwarf2_base_index_functions::find_per_cu is documented as using an unrelocated address. This patch changes the interface to use the unrelocated_addr type, just to be a bit more type-safe. Regression tested on x86-64 Fedora 38.
2024-01-08Back out some parallel_for_each featuresTom Tromey1-47/+0
Now that the DWARF reader does not use parallel_for_each, we can remove some of the features that were added just for it: return values and task sizing. The thread_pool typed tasks feature could also be removed, but I haven't done so here. This one seemed less intrusive and perhaps more likely to be needed at some point.
2024-01-08Avoid language-based lookups in startup pathTom Tromey2-3/+5
The previous patches are nearly enough to enable background DWARF reading. However, this hack in language_defn::get_symbol_name_matcher causes an early computation of current_language: /* If currently in Ada mode, and the lookup name is wrapped in '<...>', hijack all symbol name comparisons using the Ada matcher, which handles the verbatim matching. */ if (current_language->la_language == language_ada && lookup_name.ada ().verbatim_p ()) return current_language->get_symbol_name_matcher_inner (lookup_name); I considered various options here -- reversing the order of the checks, or promoting the verbatim mode to not be a purely Ada feature -- but in the end found that the few calls to this during startup could be handled more directly. In the JIT code, and in create_exception_master_breakpoint_hook, gdb is really looking for a certain kind of symbol (text or data) using a linkage name. Changing the lookup here is clearer and probably more efficient as well. In create_std_terminate_master_breakpoint, the lookup can't really be done by linkage name (it would require relying on a certain mangling scheme, and also may trip over versioned symbols) -- but we know that this spot is C++-specific, and so the language ought to be temporarily set to C++ here. After this patch, the "file" case is much faster: (gdb) file /tmp/gdb 2023-10-23 13:16:54.456 - command started Reading symbols from /tmp/gdb... 2023-10-23 13:16:54.520 - command finished Command execution time: 0.225906 (cpu), 0.064313 (wall)
2024-01-08Optimize lookup_minimal_symbol_textTom Tromey1-28/+41
lookup_minimal_symbol_text always loops over all objfiles, even when an objfile is passed in as an argument. This patch changes the function to loop over the minimal number of objfiles in the latter situation.
2024-01-08Lazy language settingTom Tromey5-18/+73
When gdb starts up with a symbol file, it uses the program's "main" to decide the "static context" and the initial language. With background DWARF reading, this means that gdb has to wait for a significant amount of DWARF to be read synchronously. This patch introduces lazy language setting. The idea here is that in many cases, the prompt can show up early, making gdb feel more responsive.
2024-01-08Change current_language to be a macroTom Tromey2-5/+18
This changes the 'current_language' global to be a macro that wraps a function call. This change will let a subsequent patch introduce lazy language setting.
2024-01-08Remove two quick_symbol_functions methodsTom Tromey6-86/+16
quick_symbol_functions::read_partial_symbols is no longer implemented, so both it and quick_symbol_functions::can_lazily_read_symbols can be removed. This allows for other functions to be removed as well. Note that SYMFILE_NO_READ is now pretty much dead. I haven't removed it here -- but could if that's desirable. I tend to think that this functionality would be better implemented in the core; but whenever I dive into the non-DWARF readers it is pretty depressing.
2024-01-08Simplify the public DWARF APITom Tromey6-50/+43
dwarf2_has_info and dwarf2_initialize_objfile are only separate because the DWARF reader implemented lazy psymtab reading. However, now that this is gone, we can simplify the public DWARF API again.
2024-01-08Do more DWARF reading in the backgroundTom Tromey13-306/+666
This patch rearranges the DWARF reader so that more work is done in the background. This is PR symtab/29942. The idea here is that there is only a small amount of work that must be done on the main thread when scanning DWARF -- before the main scan, the only part is mapping the section data. Currently, the DWARF reader uses the quick_symbol_functions "lazy" functionality to defer even starting to read. This patch instead changes the reader to start reading immediately, but doing more in worker tasks. Before this patch, "file" on my machine: (gdb) file /tmp/gdb 2023-10-23 12:29:56.885 - command started Reading symbols from /tmp/gdb... 2023-10-23 12:29:58.047 - command finished Command execution time: 5.867228 (cpu), 1.162444 (wall) After the patch, more work is done in the background and so this takes a bit less time: (gdb) file /tmp/gdb 2023-10-23 13:25:51.391 - command started Reading symbols from /tmp/gdb... 2023-10-23 13:25:51.712 - command finished Command execution time: 1.894500 (cpu), 0.320306 (wall) I think this could be further sped up by using the shared library load map to avoid objfile loops like the one in expand_symtab_containing_pc -- it seems like the correct objfile could be chosen more directly. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29942 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30174
2024-01-08Change how cooked index waits for threadsTom Tromey2-3/+2
This changes the cooked index code to wait for threads in its public-facing API. That is, the waits are done in cooked_index now, and never in the cooked_index_shard. Centralizing this decision makes it easier to wait for other events here as well.
2024-01-08Add "maint set dwarf synchronous"Tom Tromey3-0/+49
For testing, it's sometimes convenient to be able to request that DWARF reading be done synchronously. This patch adds a new "maint" setting for this purpose. Reviewed-By: Eli Zaretskii <eliz@gnu.org>
2024-01-08Move cooked_index_storage to cooked-index.hTom Tromey2-94/+111
This moves cooked_index_storage to cooked-index.h. This is needed by a subsequent patch.
2024-01-08Add quick_symbol_functions::compute_main_nameTom Tromey4-0/+26
This adds a new compute_main_name method to quick_symbol_functions. Currently there are no implementations of this, but a subsequent patch will add one.
2024-01-08Add deferred_warnings parameter to read_addrmap_from_arangesTom Tromey5-45/+65
When DWARF reading is done in the background, read_addrmap_from_aranges will be called from a worker thread. Because warnings can't be emitted from these threads, this patch adds a new deferred_warnings parameter to the function, letting the caller control exactly how the warnings are emitted.
2024-01-08Refactor complaint thread-safety approachTom Tromey5-36/+60
This patch changes the way complaint works in a background thread. The new approach requires installing a complaint interceptor in each worker, and then the resulting complaints are treated as one of the results of the computation. This change is needed for a subsequent patch, where installing a complaint interceptor around a parallel-for is no longer a viable approach.
2024-01-08Add thread-safety to gdb's BFD wrappersTom Tromey4-4/+65
This changes gdb to ensure that gdb's BFD cache is guarded by a lock. This avoids any races when multiple threads might open a BFD (and thus use the BFD cache) at the same time. Currently, this change is not needed because the the main thread waits for some DWARF scanning to be completed before returning. The only locking that's required is when opening DWO files, and there's a local lock to this end in dwarf2/read.c. However, in the coming patches, the DWARF reader will begin its work earlier, in the background. This means there is the potential for the DWARF reader and other code on the main thread to both attempt to open BFDs at the same time.
2024-01-08Add a couple of bfd_cache_close callsTom Tromey1-0/+4
This adds a couple of calls to bfd_cache_close at points where a BFD isn't actively needed by gdb. Normally at these points, all the needed section data is already mapped, so we can simply close the file descriptor. This is harmless at worst, because if this is needed after all, the BFD file descriptor cache will reopen it.
2024-01-08Pre-read DWZ section dataTom Tromey6-67/+56
This changes the DWZ code to pre-read the section data and somewhat simplify the DWZ API. This makes it easier to add the bfd_cache_close call to the new dwarf2_read_dwz_file function -- after this is done, there shouldn't be a reason to keep the BFD's file descriptor open.
2024-01-08Don't use objfile::intern in DWO codeTom Tromey1-10/+21
The DWO code in the DWARF reader currently uses objfile::intern. This accesses a shared data structure and so would be racy when used from multiple threads. I don't believe this can happen right now, but background reading could provoke this, and in any case it's better to avoid this, just to be sure. This patch changes this code to just use a std::string. A new type is introduced to do hash table lookups, to avoid unnecessary copies.
2024-01-08MAINTAINERS: Update my email addressJoseph Myers1-1/+1
2024-01-08[gdb/testsuite] Add missing -no-prompt-anchor in ↵Tom de Vries1-1/+1
gdb.base/vfork-follow-parent.exp When running test-case gdb.base/vfork-follow-parent.exp it passes fine, but when running it with "taskset -c 0" I run into: ... (gdb) inferior 1^M [Switching to inferior 1 [process 26606] (vfork-follow-parent-exit)]^M [Switching to thread 1.1 (process 26606)]^M (gdb) Reading symbols from vfork-follow-parent-exit...^M FAIL: $exp: exec_file=vfork-follow-parent-exit: target-non-stop=on: \ non-stop=off: resolution_method=schedule-multiple: inferior 1 (timeout) ... Fix this by using -no-prompt-anchor. Tested on x86_64-linux. PR testsuite/31166 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31166
2024-01-08[gdb/testsuite] Make gdb.base/solib-search.exp more robustTom de Vries2-0/+6
On aarch64-linux, with gcc 13.2.1, I run into: ... (gdb) backtrace^M #0 break_here () at solib-search.c:30^M #1 0x0000fffff7f20194 in lib2_func4 () at solib-search-lib2.c:50^M #2 0x0000fffff7f70194 in lib1_func3 () at solib-search-lib1.c:50^M #3 0x0000fffff7f20174 in lib2_func2 () at solib-search-lib2.c:30^M #4 0x0000fffff7f70174 in lib1_func1 () at solib-search-lib1.c:30^M #5 0x00000000004101b4 in main () at solib-search.c:23^M (gdb) PASS: gdb.base/solib-search.exp: \ backtrace (with wrong libs) (data collection) FAIL: gdb.base/solib-search.exp: backtrace (with wrong libs) ... The FAIL is generated by this code in the test-case: ... if { $expect_fail } { # If the backtrace output is correct the test isn't sufficiently # testing what it should. if { $count == $total_expected } { set fail 1 } ... The test-case: - builds two versions of two shared libs, a "right" and "wrong" version, the difference being an additional dummy function (called spacer function), - uses the "right" version to generate a core file, - uses the "wrong" version to interpret the core file, and - generates a backtrace. The intent is that the backtrace is incorrect due to using the "wrong" version, but actually it's correct. This is because the spacer functions aren't large enough. Fix this by increasing the size of the spacer functions by adding a dummy loop, after which we have, as expected, an incorrect backtrace: ... (gdb) backtrace^M #0 break_here () at solib-search.c:30^M #1 0x0000fffff7f201c0 in ?? ()^M #2 0x0000fffff7f20174 in lib2_func2 () at solib-search-lib2.c:30^M #3 0x0000fffff7f20174 in lib2_func2 () at solib-search-lib2.c:30^M #4 0x0000fffff7f70174 in lib1_func1 () at solib-search-lib1.c:30^M #5 0x00000000004101b4 in main () at solib-search.c:23^M (gdb) PASS: gdb.base/solib-search.exp: \ backtrace (with wrong libs) (data collection) PASS: gdb.base/solib-search.exp: backtrace (with wrong libs) ... Tested on aarch64-linux.
2024-01-04[gdb/testsuite] Handle PAC markerTom de Vries7-11/+54
On aarch64-linux, I run into: ... FAIL: gdb.base/annota1.exp: backtrace from shlibrary (timeout) ... due to the PAC marker showing up: ... ^Z^Zframe-address^M 0x000000000041025c [PAC]^M ^Z^Zframe-address-end^M ... In the docs the marker is documented as follows: ... When GDB is debugging the AArch64 architecture, and the program is using the v8.3-A feature Pointer Authentication (PAC), then whenever the link register $lr is pointing to an PAC function its value will be masked. When GDB prints a backtrace, any addresses that required unmasking will be postfixed with the marker [PAC]. When using the MI, this is printed as part of the addr_flags field. ... Update the test-case to allow the PAC marker. Likewise in a few other test-cases. While we're at it, rewrite the affected pattern pat_begin in annota1.exp into a more readable form. Likewise for the corresponding pat_end. Tested on aarch64-linux. Approved-By: Luis Machado <luis.machado@arm.com> PR testsuite/31202 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31202
2024-01-04gdb: improve error reporting from expression parserAndrew Burgess3-1/+17
This commits changes how errors are reported from the expression parser. Previously, parser errors were reported like this: (gdb) p a1 +}= 432 A syntax error in expression, near `}= 432'. (gdb) p a1 + A syntax error in expression, near `'. The first case is fine, a user can figure out what's going wrong, but the second case is a little confusing; as the error occurred at the end of the expression GDB just reports the empty string to the user. After this commit the first case is unchanged, but the second case now reports like this: (gdb) p a1 + A syntax error in expression, near the end of `a1 +'. Which I think is clearer. There is a possible issue if the expression being parsed is very long, GDB will repeat the whole expression. But this issue already exists in the standard case; if the error occurs early in a long expression GDB will repeat everything after the syntax error. So I've not worried about this case in my new code either, which keeps things simpler. I did consider trying to have multi-line errors here, in the style that gcc produces, with some kind of '~~~~~^' marker on the second line to indicate where the error occurred; but I rejected this due to the places in GDB where we catch an error and repackage the message within some longer string, I don't think multi-line error messages would work well in that case. At a minimum it would require some significant work in order to make all our error handling multi-line aware. I've added a couple of extra tests in gdb.base/exprs.exp. Approved-By: John Baldwin <jhb@FreeBSD.org>
2024-01-04gdb: merge error handling from different expression parsersAndrew Burgess9-25/+23
Many (all?) of the expression parsers implement yyerror to handle parser errors, and all of these functions are basically identical. This commit adds a new parser_state::parse_error() function, which implements the common error handling code, this function can then be called from all the different yyerror functions. The benefit of this is that (in a future commit) I can improve the error output, and all the expression parsers will benefit. This commit is pure refactoring though, and so, there should be no user visible changes after this commit. Approved-By: John Baldwin <jhb@FreeBSD.org>
2024-01-04gdb: don't try to style content in error callsAndrew Burgess1-4/+2
While working on a later commit in this series I realised that the error() function doesn't support output styling. Due to the way that output from error() calls is passed around within the exception object and often combined with other output, it's not immediately obvious to me if we should be trying to support styling in this context or not. On inspection, I found one place in GDB where we apparently try to apply styling within the error() output (in procfs.c). I suspect this error() call might not be tested. Rather than try to implement styling in the error() output, right now I'm proposing to just remove the attempt to style error() output. This doesn't mean that someone shouldn't add error() styling in the future, but right now, I'm not planning to do that, I just wanted to fix this in passing. Approved-By: John Baldwin <jhb@FreeBSD.org>
2024-01-02Fix GDB reverse-step and reverse-next command behaviorCarl Love5-34/+201
Currently GDB when executing in reverse over multiple statements in a single line of source code, GDB stops in the middle of the line. Thus requiring multiple commands to reach the previous line. GDB should stop at the first instruction of the line, not in the middle of the line. The following description of the incorrect behavior was taken from an earlier message by Pedro Alves <pedro@palves.net>: https://sourceware.org/pipermail/gdb-patches/2023-January/196110.html --------------------------------- The source line looks like: func1 (); func2 (); in the test case: (gdb) list 1 1 void func1 () 2 { 3 } 4 5 void func2 () 6 { 7 } 8 9 int main () 10 { 11 func1 (); func2 (); 12 } compiled with: $ gcc reverse.c -o reverse -g3 -O0 $ gcc -v ... gcc version 11.3.0 (Ubuntu 11.3.0-1ubuntu1~22.04) Now let's debug it with target record, using current gdb git master (f3d8ae90b236), $ gdb ~/reverse GNU gdb (GDB) 14.0.50.20230124-git ... Reading symbols from /home/pedro/reverse... (gdb) start Temporary breakpoint 1 at 0x1147: file reverse.c, line 11. Starting program: /home/pedro/reverse [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Temporary breakpoint 1, main () at reverse.c:11 11 func1 (); func2 (); (gdb) record (gdb) disassemble /s Dump of assembler code for function main: reverse.c: 10 { 0x000055555555513f <+0>: endbr64 0x0000555555555143 <+4>: push %rbp 0x0000555555555144 <+5>: mov %rsp,%rbp 11 func1 (); func2 (); => 0x0000555555555147 <+8>: mov $0x0,%eax 0x000055555555514c <+13>: call 0x555555555129 <func1> 0x0000555555555151 <+18>: mov $0x0,%eax 0x0000555555555156 <+23>: call 0x555555555134 <func2> 0x000055555555515b <+28>: mov $0x0,%eax 12 } 0x0000555555555160 <+33>: pop %rbp 0x0000555555555161 <+34>: ret End of assembler dump. (gdb) n 12 } So far so good, a "next" stepped over the whole of line 11 and stopped at line 12. Let's confirm where we are now: (gdb) disassemble /s Dump of assembler code for function main: reverse.c: 10 { 0x000055555555513f <+0>: endbr64 0x0000555555555143 <+4>: push %rbp 0x0000555555555144 <+5>: mov %rsp,%rbp 11 func1 (); func2 (); 0x0000555555555147 <+8>: mov $0x0,%eax 0x000055555555514c <+13>: call 0x555555555129 <func1> 0x0000555555555151 <+18>: mov $0x0,%eax 0x0000555555555156 <+23>: call 0x555555555134 <func2> 0x000055555555515b <+28>: mov $0x0,%eax 12 } => 0x0000555555555160 <+33>: pop %rbp 0x0000555555555161 <+34>: ret End of assembler dump. Good, we're at the first instruction of line 12. Now let's undo the "next", with "reverse-next": (gdb) reverse-next 11 func1 (); func2 (); Seemingly stopped at line 11. Let's see exactly where: (gdb) disassemble /s Dump of assembler code for function main: reverse.c: 10 { 0x000055555555513f <+0>: endbr64 0x0000555555555143 <+4>: push %rbp 0x0000555555555144 <+5>: mov %rsp,%rbp 11 func1 (); func2 (); 0x0000555555555147 <+8>: mov $0x0,%eax 0x000055555555514c <+13>: call 0x555555555129 <func1> => 0x0000555555555151 <+18>: mov $0x0,%eax 0x0000555555555156 <+23>: call 0x555555555134 <func2> 0x000055555555515b <+28>: mov $0x0,%eax 12 } 0x0000555555555160 <+33>: pop %rbp 0x0000555555555161 <+34>: ret End of assembler dump. (gdb) And lo, we stopped in the middle of line 11! That is a bug, we should have stepped back all the way to the beginning of the line. The "reverse-next" should have fully undone the prior "next" command. -------------------- This patch fixes the incorrect GDB behavior by ensuring that GDB stops at the first instruction in the line. The test case gdb.reverse/func-map-to-same-line.exp is added to testsuite to verify this fix when the line table information is and is not available.
2024-01-02PowerPC and aarch64: Fix reverse stepping failureCarl Love5-0/+335
When running GDB's testsuite on aarch64-linux/Ubuntu 20.04 (also spotted on the ppc backend), there are failures in gdb.reverse/solib-precsave.exp and gdb.reverse/solib-reverse.exp. The failure happens around the following code: 38 b[1] = shr2(17); /* middle part two */ 40 b[0] = 6; b[1] = 9; /* generic statement, end part two */ 42 shr1 ("message 1\n"); /* shr1 one */ Normal execution: - step from line 38 will land on line 40. - step from line 40 will land on line 42. Reverse execution: - step from line 42 will land on line 40. - step from line 40 will land on line 40. - step from line 40 will land on line 38. The problem here is that line 40 contains two contiguous but distinct PC ranges in the line table, like so: Line 40 - [0x7ec ~ 0x7f4] Line 40 - [0x7f4 ~ 0x7fc] The two distinct ranges are generated because GCC started outputting source column information, which GDB doesn't take into account at the moment. When stepping forward from line 40, we skip both of these ranges and land on line 42. When stepping backward from line 42, we stop at the start PC of the second (or first, going backwards) range of line 40. Since we've reached ecs->event_thread->control.step_range_start, we stop stepping backwards. The above issues were fixed by introducing a new function that looks for adjacent PC ranges for the same line, until we notice a line change. Then we take that as the start PC of the range. The new start PC for the range is used for the control.step_range_start when setting up a step range. The test case gdb.reverse/map-to-same-line.exp is added to test the fix for the above reverse step issues. Patch has been tested on PowerPC, X86 and AArch64 with no regressions.
2024-01-02Add gdb_compile options column-info and no-column-infoCarl Love1-0/+34
This patch adds two new options to gdb_compile to specify if the compile should or should not generate the line table information. The options are supported on clang and gcc version 7 and newer. Patch has been tested on PowerPC with both gcc and clang.
2024-01-02gdb/dwarf2: Add support for DW_LNS_set_epilogue_begin in line-tableGuinevere Larsen13-13/+328
This commit adds a mechanism for GDB to detect the linetable opcode DW_LNS_set_epilogue_begin. This opcode is set by compilers to indicate that a certain instruction marks the point where the frame is destroyed. While the standard allows for multiple points marked with epilogue_begin in the same function, for performance reasons, the function that searches for the epilogue address will only find the last address that sets this flag for a given block. This commit also changes amd64_stack_frame_destroyed_p_1 to attempt to use the epilogue begin directly, and only if an epilogue can't be found will it attempt heuristics based on the current instruction. Finally, this commit also changes the dwarf assembler to be able to emit epilogue-begin instructions, to make it easier to test this patch Approved-By: Tom Tromey <tom@tromey.com>
2023-12-31Run 'black' on tui-window.pyTom Tromey1-2/+4
Mark pointed out that a recent patch of mine caused the buildbot to complain about the formatting of some Python test code. This patch re-runs 'black' to fix the problem.
2023-12-31[gdb/testsuite] Fix typo in gdb.base/catch-syscall.expTom de Vries1-1/+1
On aarch64-linux with a gdb build without libexpat, I run into: ... (gdb) PASS: gdb.base/catch-syscall.exp: determine pipe syscall: \ catch syscall 59 continue Continuing. Catchpoint 5 (call to syscall 59), 0x0000fffff7e04578 in pipe () from \ /lib64/libc.so.6 (gdb) FAIL: gdb.base/catch-syscall.exp: determine pipe syscall: continue ... In the test-case, this pattern handles either the syscall name or number for the pipe syscall: ... -re -wrap "Catchpoint $decimal \\(call to syscall (pipe|$SYS_pipe)\\).*" { ... but the pattern for the pipe2 syscall mistakenly uses SYS_pipe instead of SYS_pipe2: ... -re -wrap "Catchpoint $decimal \\(call to syscall (pipe2|$SYS_pipe)\\).*" { ... and consequently doesn't handle the pipe2 syscall number. Fix the typo by using SYS_pipe2 instead. Tested on aarch64-linux.
2023-12-30Add keywords to TuiWindow.writeTom Tromey2-4/+8
The gdb docs promise that methods with more than two or more arguments will accept keywords. However, I found that TuiWindow.write didn't allow them. This patch adds the missing support.
2023-12-30[gdb/testsuite] Fix gdb.base/gdb-index-err.exp for root userTom de Vries1-1/+7
When running test-case gdb.base/gdb-index-err.exp in a container as root user, I run into: ... FAIL: gdb.base/gdb-index-err.exp: flag=: \ try to write index to a non-writable directory FAIL: gdb.base/gdb-index-err.exp: flag=-dwarf-5: \ try to write index to a non-writable directory ... The test-case creates a directory without write permissions: ... $ ls -ald private dr-xr-xr-x 2 root root 4096 Dec 29 06:26 private/ ... but apparently the root user is still able to write in it. Fix this by making the test unsupported for the root user. Tested on x86_64-linux. Reviewed-By: Lancelot SIX <lancelot.six@amd.com> PR testsuite/31197 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31197
2023-12-30MAINTAINERS: Update my email addressJoseph Myers1-1/+1
There will be another update in January.
2023-12-29dwarf, fortran: add support for DW_TAG_entry_pointNils-Christian Kempke8-5/+479
Fortran provides additional entry points for subroutines and functions. These entry points may use only a subset (or a different set) of the parameters of the original subroutine. The entry points may be described via the DWARF tag DW_TAG_entry_point. This commit adds support for parsing the DW_TAG_entry_point DWARF tag. Currently, between ifx/ifort/gfortran, only ifort is actually emitting this tag. Both, ifx and gfortran use the DW_TAG_subprogram tag as workaround/alternative. Thus, this patch really only adds more ifort support. Even so, some of the attached tests still fail for ifort, due to some wrong line info generated for the entry points in ifort. After this patch it is possible to set a breakpoint in gdb with the ifort compiled example at the entry points 'foo' and 'foobar', which was not possible before. As gcc and ifx do not emit the tag I also added a test to gdb.dwarf2 which uses some underlying c compiled code and adds some Fortran style DWARF to it emitting the DW_TAG_entry_point. Before this patch it was not possible to actually define breakpoint at the entry point tags. For gfortran there actually exists a bug on bugzilla, asking for the use of DW_TAG_entry_point over DW_TAG_subprogram: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=37134 This patch was originally posted here https://sourceware.org/legacy-ml/gdb-patches/2017-07/msg00317.html but its review/pinging got lost after a while. I reworked it to fit the current GDB. Co-authored-by: Bernhard Heckel <bernhard.heckel@intel.com> Co-authored-by: Tim Wiederhake <tim.wiederhake@intel.com> Approved-by: Tom Tromey <tom@tromey.com>
2023-12-29gdb, dwarf: add assert to dwarf2_get_pc_boundsNils-Christian Kempke1-0/+1
In dwarf2_get_pc_bounds we were writing unchecked to *lowpc. This commit adds a gdb_assert to first check that lowpc != nullptr. Approved-by: Tom Tromey <tom@tromey.com>
2023-12-29gdb, dwarf: move part of dwarf2_get_pc_bounds into separate functionNils-Christian Kempke1-21/+50
This commit is in preparation of the next commit. There, we will add a second variation to retrieve the pc bounds for DIEs tagged with DW_TAG_entry_point. Instead of dwarf_get_pc_bounds_ranges_or_highlow_pc we will call a separate method for entry points. As the validity checks at the endo f dwarf2_get_pc_bounds are the same for both variants, we introduced the new dwarf_get_pc_bounds_ranges_or_highlow_pc method, outsourcing part of dwarf2_get_pc_bounds. This commit should have no functional impact on GDB. Approved-by: Tom Tromey <tom@tromey.com>
2023-12-24gdb: make value::allocate_register_lazy store id of next non-inline frameSimon Marchi4-25/+21
Some spots loop on the frame chain to find the first next non-inline frame, and pass that as the "next frame" to value::allocate_register_lazy / value::allocate_register. This is necessary if the value is used in the process of computing the id of "this frame". If the frame next to "this frame" is inlined into "this frame", then you that next frame won't have a computed id yet. You have to go past that to find the next non-inline frame, which will have a computed id. In other cases, it's fine to store the id of an inline frame as the "next frame id" in a register struct value. When trying to unwind a register from it, it will just call inline_frame_prev_register, which will forward the request to the next next frame, until we hit the next physical frame. I think it would make things simpler to just never store the id of an inline frame as the next frame id of register struct values, and go with the first next non-inline frame directly. This way, we don't have to wonder which code paths have to skip inline frames when creating register values and which don't. So, change value::allocate_register_lazy to do that work, and remove the loops for the callers that did it. Change-Id: Ic88115dac49dc14e3053c95f92050062b24b7310
2023-12-24gdb: remove VALUE_REGNUM, add value::regnumSimon Marchi7-36/+26
Remove VALUE_REGNUM, replace it with a method on struct value. Set `m_location.reg.regnum` directly from value::allocate_register_lazy, which is fine because allocate_register_lazy is a static creation function for struct value. Change-Id: Id632502357da971617d9dce1e2eab9b56dbcf52d
2023-12-24gdb: remove VALUE_NEXT_FRAME_ID, add value::next_frame_idSimon Marchi4-36/+21
Remove VALUE_NEXT_FRAME_ID, replace it with a method on struct value. Set `m_location.reg.next_frame_id` directly from value::allocate_register_lazy, which is fine because allocate_register_lazy is a static creation function for struct value. Change-Id: Ic9f0f239c166a88dccfee836f9f51871e67548e6
2023-12-24gdb: implement address_from_register using value_from_registerSimon Marchi1-37/+4
As explained in the comment removed by the previous commit "gdb: pass non-nullptr frame to gdbarch_value_from_register in address_from_register", address_from_register copies some implementation bits from value_from_register: /* This routine may be called during early unwinding, at a time where the ID of FRAME is not yet known. Calling value_from_register would therefore abort in get_frame_id. However, since we only need a temporary value that is never used as lvalue, we actually do not really need to set its VALUE_NEXT_FRAME_ID. Therefore, we re-implement the core of value_from_register, but use the null_frame_id. */ This is no longer relevant, since we now create a value with a valid next frame id, so change address_from_register to use value_from_register. Change-Id: I189bd96f28735ed9f47750ffd73764c459ec6f43