aboutsummaryrefslogtreecommitdiff
path: root/gdb
AgeCommit message (Collapse)AuthorFilesLines
2023-03-18Use type allocator for array typesTom Tromey11-82/+82
This changes the array type creation functions to accept a type allocator, and updates all the callers. Note that symbol readers should generally allocate on the relevant objfile, regardless of the placement of the index type of the array, which is what this patch implements. Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
2023-03-18Use type allocator for range typesTom Tromey11-65/+92
This changes the range type creation functions to accept a type allocator, and updates all the callers. Note that symbol readers should generally allocate on the relevant objfile, regardless of the underlying type of the range, which is what this patch implements. Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
2023-03-18Unify arch_pointer_type and init_pointer_typeTom Tromey10-48/+33
This unifies arch_pointer_type and init_pointer_type by using a type allocator. Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
2023-03-18Unify arch_decfloat_type and init_decfloat_typeTom Tromey3-22/+13
This unifies arch_decfloat_type and init_decfloat_type by using a type allocator. Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
2023-03-18Unify arch_float_type and init_float_typeTom Tromey21-95/+97
This unifies arch_float_type and init_float_type by using a type allocator. Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
2023-03-18Unify arch_boolean_type and init_boolean_typeTom Tromey11-44/+29
This unifies arch_boolean_type and init_boolean_type by using a type allocator. Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
2023-03-18Unify arch_character_type and init_character_typeTom Tromey10-44/+28
This unifies arch_character_type and init_character_type by using a type allocator. Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
2023-03-18Unify arch_integer_type and init_integer_typeTom Tromey21-205/+201
This unifies arch_integer_type and init_integer_type by using a type allocator. Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
2023-03-18Remove init_typeTom Tromey6-83/+69
This removes init_type, replacing all uses with the new type allocator. Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
2023-03-18Remove arch_typeTom Tromey16-88/+91
This removes arch_type, replacing all uses with the new type allocator. Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
2023-03-18Reuse existing builtin typesTom Tromey5-11/+5
This changes a few spots to reuse the existing builting "void" type, rather than construct a new one. Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
2023-03-18Remove alloc_typeTom Tromey7-46/+17
This removes alloc_type, replacing all uses with the new type allocator. Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
2023-03-18Remove alloc_type_copyTom Tromey5-39/+26
This removes alloc_type_copy, replacing all uses with the new type allocator. Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
2023-03-18Remove alloc_type_archTom Tromey2-35/+4
This removes alloc_type_arch, replacing all uses with the new type allocator. Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
2023-03-18Introduce type_allocatorTom Tromey2-27/+189
This introduces a new type_allocator class. This class will be used to abstract out the placement of new types, so that type-creation code can be simplified and shared. Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
2023-03-18[gdb/testsuite] Handle unbuffer_output.c for remote hostTom de Vries25-28/+79
Handle $srcdir/lib/unbuffer_output.c using lappend_include_file. Tested on x86_64-linux.
2023-03-18[gdb/testsuite] Handle my-syscalls.h for remote hostTom de Vries2-1/+3
Handle $srcdir/lib/my-syscalls.h using lappend_include_dir. Tested on x86_64-linux.
2023-03-18[gdb/testsuite] Handle attributes.h for remote hostTom de Vries15-25/+81
Handle $srcdir/lib/attributes.h using lappend_include_dir. Tested on x86_64-linux.
2023-03-17Fix line table regressionTom Tromey15-50/+78
Simon pointed out a line table regression, and after a couple of false starts, I was able to reproduce it by hand using his instructions. The bug is that most of the code in do_mixed_source_and_assembly uses unrelocated addresses, but one spot does: pc = low; ... after the text offset has been removed. This patch fixes the problem by introducing a new type to represent unrelocated addresses in the line table. This prevents this sort of bug to some degree (it's still possible to manipulate a CORE_ADDR in a bad way, this is unavoidable). However, this did let the compiler flag a few spots in that function, and now it's not possible to compare an unrelocated address from a line table with an ordinary CORE_ADDR. Regression tested on x86-64 Fedora 36, though note this setup never reproduced the bug in the first place. I also tested it by hand on the disasm-optim test program.
2023-03-17Update the NetBSD system call table to add eventfd(2) and timerfd(2).Frederic Cambus1-0/+4
Generated from sys/sys/syscall.h revision 1.321.
2023-03-17gdb: introduce bp_loc_tracepointSimon Marchi2-1/+9
Since commit cb1e4e32c2d9 ("catch catch/throw/rethrow", breakpoint -> catchpoint), this simple tracing scenario does not work: $ gdb/gdb -nx -q --data-directory=gdb/data-directory ./test Reading symbols from ./test... (gdb) tar rem :1234 Remote debugging using :1234 Reading symbols from /lib64/ld-linux-x86-64.so.2... (No debugging symbols found in /lib64/ld-linux-x86-64.so.2) 0x00007ffff7fe5730 in ?? () from /lib64/ld-linux-x86-64.so.2 (gdb) trace do_something Tracepoint 1 at 0x555555555144: file test.c, line 5. (gdb) tstart (gdb) continue Continuing. Target returns error code '01'. The root cause is that the bp_location::nserted flag does not transfer anymore from an old bp_location to the new matching one. When a shared library gets loaded, GDB computes new breakpoint locations for each breakpoint in update_breakpoint_locations. The new locations are in the breakpoint::loc chain, while the old locations are still in the bp_locations global vector. Later, update_global_location_list is called. It tries to map old locations to new locations, and if necessary transfer some properties, like the inserted flag. Since commit cb1e4e32c2d9, the inserted flag isn't transferred for locations of tracepoints. This is because bl_address_is_meaningful used to be implemented like this: static int breakpoint_address_is_meaningful (struct breakpoint *bpt) { enum bptype type = bpt->type; return (type != bp_watchpoint && type != bp_catchpoint); } and was changed to this: static bool bl_address_is_meaningful (bp_location *loc) { return loc->loc_type != bp_loc_other; } Because locations for tracepoints have the bp_loc_other type, bl_address_is_meaningful started to return false for them, where it returned true before. This made update_global_location_list skip the part where it calls swap_insertion. I think this can be solved by introduced a new bp_loc_tracepoint bp_loc_type. I don't know if it's accurate, but my understanding is that bp_loc_type describes roughly "how do we ask the target to insert that location". bp_loc_software_breakpoint are inserted using target_ops::insert_breakpoint_location. bp_loc_hardware_breakpoint are inserted using target_ops::insert_hw_breakpoint. bp_loc_software_watchpoint and bp_loc_hardware_watchpoint are inserted using target_ops::insert_watchpoint. For all these, the address is meaningful, as we ask the target to insert the point at a specific address. bp_loc_other is a catch-all for "the rest", in practice for catchpoints that don't have a specific address (hence why bl_address_is_meaningful returns false for them). For instance, inserting a signal catchpoint is done by asking the target to report that specific signal. GDB doesn't associate an address to that. But tracepoints do have a meaningful address to thems, so they can't be bp_loc_other, with that logic. They also can't be bp_loc_software_breakpoint, because we don't want GDB to insert breakpoints for them (even though they might be implemented using software breakpoints by the remote side). So, the new bp_loc_tracepoint type describes that the way to insert these locations is with target_ops::download_tracepoint. It makes bl_address_is_meaningful return true for them. And they'll be ignored by insert_bp_location and GDB won't try to insert a memory breakpoint for them. With this, I see a few instances of 'Target returns error code: 01' disappearing from gdb.log, and the results of gdb.trace/*.exp improve a little bit: -# of expected passes 3765 +# of expected passes 3781 -# of unexpected failures 518 +# of unexpected failures 498 Things remain quite broken in that area though. Change-Id: Ic40935c450410f4bfaba397c9ebc7faf97320dd3
2023-03-17PowerPC: fix for gdb.reverse/finish-precsave.exp and ↵Carl Love4-9/+362
gdb.reverse/finish-reverse.exp PPC64 multiple entry points, a normal entry point and an alternate entry point. The alternate entry point is to setup the Table of Contents (TOC) register before continuing at the normal entry point. When the TOC is already valid, the normal entry point is used, this is typically the case. The alternate entry point is typically referred to as the global entry point (GEP) in IBM. The normal entry point is typically referred to as the local entry point (LEP). When GDB is executing the finish command in reverse, the function finish_backward currently sets the break point at the alternate entry point. This issue is if the function, when executing in the forward direction, entered the function via the normal entry point, execution in the reverse direction will never sees the break point at the alternate entry point. In this case, the reverse execution continues until the next break point is encountered thus stopping at the wrong place. This patch adds a new address to struct execution_control_state to hold the address of the alternate entry point (GEP). The finish_backwards function is updated, if the stopping point is between the normal entry point (LEP) and the end of the function, a breakpoint is set at the normal entry point. If the stopping point is between the entry points, a breakpoint is set at the alternate entry point. This ensures that GDB will always stop at the normal entry point. If the function did enter via the alternate entry point, GDB will detect that and continue to execute backwards in the function until the alternate entry point is reached. The patch fixes the behavior of the reverse-finish command on PowerPC to match the behavior of the command on other platforms, specifically X86. The patch does not change the behavior of the command on X86. A new test is added to verify the reverse-finish command on PowerPC correctly stops at the instruction where the function call is made. The patch fixes 11 regression errors in test gdb.reverse/finish-precsave.exp and 11 regression errors in test gdb.reverse/finish-reverse.exp. The patch has been tested on Power 10 and X86 processor with no new regression failures.
2023-03-17Move step_until procedureCarl Love2-55/+41
Procedure step_until from test gdb.reverse/step-indirect-call-thunk.exp is moved to lib/gdb.exp and renamed repeat_cmd_until. The existing procedure gdb_step_until in lib/gdb.exp is simpler variant of the new repeat_cmd_until procedure. The existing procedure gdb_step_until is changed to just call the new repeat_cmd_until procedure with the command set to "step" and an optional CURRENT string. The default CURRENT string is set to "\}" to work with the existing uses of procedure gdb_step_until.
2023-03-17[gdb/testsuite] Fix regexp in gdb.arch/ftrace-insn-reloc.expTom de Vries1-1/+1
With test-case gdb.arch/ftrace-insn-reloc.exp and host board local-remote-host-notty and target board native-gdbserver I run into: ... (gdb) info sharedlibrary^M From To Syms Read Shared Object Library^M $hex $hex Yes /lib64/ld-linux-x86-64.so.2^M $hex $hex Yes /home/remote-host/libinproctrace.so^M $hex $hex Yes /lib64/libm.so.6^M $hex $hex Yes /lib64/libc.so.6^M $hex $hex Yes /lib64/libdl.so.2^M $hex $hex Yes (*) /usr/lib64/libstdc++.so.6^M $hex $hex Yes (*) /lib64/libgcc_s.so.1^M $hex $hex Yes /lib64/libpthread.so.0^M (*): Shared library is missing debugging information.^M (gdb) FAIL: gdb.arch/ftrace-insn-reloc.exp: IPA loaded ... due to trying to match libinproctrace.so using the target path, while the command lists it using the host path. Fix this by making the regexp less strict. Tested on x86_64-linux.
2023-03-17[gdb/testsuite] Handle remote host in gdb_load_shlibTom de Vries2-6/+20
With test-case gdb.arch/ftrace-insn-reloc.exp and host board local-remote-host-notty and target board native-gdbserver I run into: ... (gdb) tstart^M Target returns error code '.In-process agent library not loaded in process. \ Fast and static trace points unavailable.'.^M (gdb) FAIL: gdb.arch/ftrace-insn-reloc.exp: start trace experiment ... Fix this by: - handling remote host in gdb_load_shlib, and - moving the gdb_load_shlib to after the clean_restart, such that the set solib-search-path can take effect. Tested on x86_64-linux.
2023-03-17[gdb/testsuite] Fix gdb.arch/i386-biarch-core.exp for remote hostTom de Vries1-0/+2
Fix test-case gdb.arch/i386-biarch-core.exp using gdb_download_remote host. Tested on x86_64-linux.
2023-03-17[gdb/testsuite] Handle REMOTE_HOST_USERNAME in local-remote-hostTom de Vries2-4/+25
Handle REMOTE_HOST_USERNAME in local-remote-host, similar to how that's done for REMOTE_TARGET_USERNAME in remote-gdbserver-on-localhost. This helps to keep the home dir clean. Since the setup makes $build/gdb/testsuite on build unreadable for the remote host, we run into permission problems for GDB and the data-directory, so fix this (as was done for gdbserver in gdbserver-base.exp) using file normalize. Tested on x86_64-linux.
2023-03-17[gdb/testsuite] Set remotedir by default in some boardsTom de Vries3-16/+77
When doing a gdb_simple_compile, and downloading the resulting exec $obj to target the result $target_obj may be a relative file path, which may give problems when trying to do: ... remote_exec target $target_obj ... Fix/workaround this on some target boards by setting remotedir by default, and add a corresponding test in gdb.testsuite/board-sanity.exp. This doesn't work for host/target board local-remote-host-native, so xfail this. Tested on x86_64-linux.
2023-03-17[gdb/testsuite] Fix have_avx for remote targetTom de Vries1-5/+10
In proc have_avx we compile some source into an exec, resulting in a file $obj on build, and then attempt to execute it on target: ... set result [remote_exec target $obj] ... Fix this by using gdb_remote_download target. Likewise in a few other procs that use "remote_exec target". Tested on x86_64-linux.
2023-03-17[gdb/testsuite] Handle precise-aligned-alloc.c for remote hostTom de Vries5-2/+22
With test-case gdb.arch/i386-sse.exp (and likewise gdb.arch/i386-avx.exp) and host board local-remote-host-notty and target board native-gdbserver I run into: ... gdb compile failed, i386-sse.c:68:10: fatal error: \ ../lib/precise-aligned-alloc.c: No such file or directory #include "../lib/precise-aligned-alloc.c" ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ... Fix this using '#include "precise-aligned-alloc.c"' and making that work with non-remote and remote host. Tested on x86_64-linux.
2023-03-17[gdb/testsuite] Handle remote host in escape_for_hostTom de Vries1-2/+8
With test-case gdb.arch/ftrace-insn-reloc.exp and host board local-remote-host-notty and target board native-gdbserver, I run into: ... FAIL: gdb.arch/ftrace-insn-reloc.exp: IPA loaded ... due to having: ... $ readelf -d ftrace-insn-reloc | grep RUNPATH 0x000000000000001d (RUNPATH) Library runpath: [] ... instead of: ... $ readelf -d ftrace-insn-reloc | grep RUNPATH 0x000000000000001d (RUNPATH) Library runpath: [$ORIGIN] ... Handle this in escape_for_host. Tested on x86_64-linux.
2023-03-17[gdb/testsuite] Add escape_for_hostTom de Vries1-1/+11
In gdb_compile we have: ... lappend new_options "ldflags=-Wl,-rpath,\\\$ORIGIN" ... and we could improve readability by using {} rather than "": ... lappend new_options {ldflags=-Wl,-rpath,\$ORIGIN} ... But rather than manually adding escapes in a string, add a new proc escape_for_host that care of this for us, allowing us to write: ... lappend new_options [escape_for_host {ldflags=-Wl,-rpath,$ORIGIN}] ... Tested on x86_64-linux.
2023-03-17[gdb/testsuite] Declare ada unsupported for remote hostTom de Vries1-0/+4
Currently gdb_ada_compile doesn't support remote host. Make this explicit in allow_ada_tests. Tested on x86_64-linux.
2023-03-17[gdb/testsuite] Fix filename in gdb.debuginfod/crc_mismatch.expTom de Vries1-1/+1
After running test-case gdb.debuginfod/crc_mismatch.exp, I find a dir called '$': ... $ ls $build/gdb/testsuite/ $ config.log gdb.log lib outputs site.exp cache config.status gdb.sum Makefile site.bak temp ... Fix this by removing the stray '$' here: ... set debugfile "$[standard_output_file ${testfile}.debug]" ... Tested on x86_64-linux.
2023-03-16gdb/doc: extended documentation for inferior function callsAndrew Burgess1-0/+32
I noticed that the documentation for inferior function calls doesn't say much about what happens if/when an inferior function call is interrupted, i.e. it doesn't describe what the dummy frame looks like on the stack, or how GDB behaves when the inferior is continued and reaches the dummy frame. This commit aims to add some of this missing information.
2023-03-16Fix build breakage in rs6000-aix-tdep.cTom Tromey2-5/+6
A recent change to rs6000-aix-tdep.c broke the build. This patch fixes it by declaring a few target descriptions in ppc-tdep.h and then not including the various features .c files in rs6000-aix-tdep.c.
2023-03-16gdb/testsuite: Add support for LoongArch in gdb.base/float.expHui Li1-0/+2
The test results on LoongArch as follows: Without this patch: ``` $ make check-gdb TESTS="gdb.base/float.exp" === gdb Summary === # of expected passes 2 # of unexpected failures 1 ``` With this patch: ``` $ make check-gdb TESTS="gdb.base/float.exp" === gdb Summary === # of expected passes 3 ``` Signed-off-by: Hui Li <lihui@loongson.cn> Reviewed-By: Tom Tromey <tom@tromey.com> Approved-By: Simon Marchi <simon.marchi@efficios.com> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
2023-03-16gdb/doc: spring clean the Python unwinders documentationAndrew Burgess1-39/+43
The documentation for the Python Unwinders API could do with some improvement. The 'Unwinder Skeleton Code' has an error: it says 'unwinders' when it should say 'unwinder' in one case. Additionally, by placing the 'Unwinder Skeleton Code' before the section 'Registering an Unwinder' we have skipping including the registration line in the skeleton code. But this is confusion for users (I think) as the skeleton code is almost complete, except for one missing line which the user has to figure out for themselves. By reordering the sections, it is now obvious that the registration should be included in the skeleton code, and the example is therefore almost complete. Additionally, in the example skeleton code the way in which the frame-id was being built (using the current stack point and program counter is (a) not correct, and (b) counter to what is laid out in the 'Unwinder Input' section when describing building a frame-id. I've removed the incorrect code and replaced it with more generic comments indicating what needs to be done. As the actual actions that need to be performed are both architecture specific, and dependent on the function being unwound, it's almost impossible to include more exact code here, but I think what I'm proposing is less misleading than what we had before. I've also added more cross references. Reviewed-By: Eli Zaretskii <eliz@gnu.org>
2023-03-15Fix formatting in gdb/printing.pyTom Tromey1-0/+3
According to black 23, gdb/printing.py was mis-formatted. This patch fixes it.
2023-03-15Enable vector register visibility in core for AIX.Aditya Vidyadhar Kamath1-0/+36
This patch enables AIX folks to see vector register contents while they analyse the core file.
2023-03-15[gdb/testsuite] Fix re-used exec in gdb.arch/ftrace-insn-reloc.expTom de Vries1-4/+2
In test-case gdb.arch/ftrace-insn-reloc.exp we generate two executables with the same name, which is confusing and known to cause trouble. Fix this by making the executable names unique. Tested on x86_64-linux.
2023-03-15[gdb/testsuite] Fix gdb.arch/amd64-stap-special-operands.exp for remote hostTom de Vries1-2/+3
With test-case gdb.arch/amd64-stap-special-operands.exp and host board local-remote-host-notty and target board native-gdbserver I run into: ... (gdb) break -pstap three_arg^M No probe matching objfile=`<any>', provider=`<any>', name=`three_arg'^M Make breakpoint pending on future shared library load? (y or [n]) n^M (gdb) FAIL: gdb.arch/amd64-stap-special-operands.exp: probe: three_arg: \ gdb_breakpoint: set breakpoint at -pstap three_arg ... due to compiling two executables with the same name, and when uploading the second one from host to build, we run into: ... Upload from 127.0.0.1 failed, \ $outputs/gdb.arch/amd64-stap-special-operands/amd64-stap-special-operands: \ Text file busy. ... Fix this by making the executable names unique. Tested on x86_64-linux.
2023-03-15[gdb/testsuite] Fix gdb.arch/i386-pkru.exp for native-gdbserverTom de Vries1-3/+12
With test-case gdb.arch/i386-pkru.exp and target board native-gdbserver we run into: ... FAIL: gdb.arch/i386-pkru.exp: variable after reading pkru ... This looks similar to the the problem for which there's already an xfail, so fix this by extending the xfail matching. Tested on x86_64-linux. Also tested on openSUSE Tumbleweed, where all tests in the test-case pass.
2023-03-15[gdb/testsuite] Unset DEBUGINFOD_URLS on remote hostTom de Vries1-1/+19
When running test-case gdb.arch/i386-pkru.exp with host board local-remote-host-notty and target board native-gdbserver on openSUSE Tumbleweed (with DEBUGINFOD_URLS set), I run into: ... This GDB supports auto-downloading debuginfo from the following URLs:^M <https://debuginfod.opensuse.org/>^M Enable debuginfod for this session? (y or [n]) ^CQuit^M (gdb) FAIL: gdb.arch/i386-pkru.exp: runto: run to main ... The problem is that the unsetenv for DEBUGINFOD_URLS in default_gdb_init: ... # If DEBUGINFOD_URLS is set, gdb will try to download sources and # debug info for f.i. system libraries. Prevent this. unset -nocomplain ::env(DEBUGINFOD_URLS) ... doesn't work on remote host. Fix this by using "set debuginfod enabled off" for remote host. Tested on x86_64-linux.
2023-03-15[gdb/testsuite] Fix gdb.arch/amd64*.exp with local-remote-host-native.expTom de Vries5-14/+35
There's a number of gdb.arch/amd64*.exp test-cases that fail with host+target board local-remote-host-native.exp because of using a .S file, generated from a .c file. If a test-case compiles the .S file when executing on remote host, the .S file is already copied from build to host, such that it's available for the compiler. But that's not the case for the .c file, which is needed by gdb to show a source line: ... (gdb) continue^M Continuing.^M ^M Breakpoint 2, fn2 (y=y@entry=25, x=x@entry=6) at amd64-entry-value-inline.c:32^M 32 in gdb.arch/amd64-entry-value-inline.c^M (gdb) FAIL: gdb.arch/amd64-entry-value-inline.exp: continue to breakpoint: \ break-here ... Fix this by using "gdb_remote_download host <.c file>". Tested on x86_64-linux, with host+target board local-remote-host-native.
2023-03-14Implement DAP variables, scopes, and evaluate requestsTom Tromey7-21/+459
The DAP code already claimed to implement "scopes" and "evaluate", but this wasn't done completely correctly. This patch implements these and also implements the "variables" request. After this patch, variables and scopes correctly report their sub-structure. This also interfaces with the gdb pretty-printer API, so the output of pretty-printers is available.
2023-03-14Hide the implementation of gdb_mpfTom Tromey2-6/+13
This renames the data member of gdb_mpf and makes it private. It also adds a single new method to aid in this change. Unlike the earlier changes here, I did this one all together because gdb_mpf has very few uses.
2023-03-14Rename gdb_mpq::val and make contents privateTom Tromey2-43/+47
This changes gdb_mpq to hide its data, and renames the data member from 'val' to 'm_val', following gdb convention.
2023-03-14Add operators and methods to gdb_mpqTom Tromey4-37/+100
This adds some operators and methods to gdb_mpq, in preparation for making its implementation private. This only adds the operators currently needed by gdb. More could be added as necessary.
2023-03-14Rename gdb_mpz::val and make contents privateTom Tromey2-55/+61
This changes gdb_mpz to hide its data, and renames the data member from 'val' to 'm_val', following gdb convention.