aboutsummaryrefslogtreecommitdiff
path: root/gdb/NEWS
AgeCommit message (Collapse)AuthorFilesLines
2023-01-06gdb/mi: add no-history stop reasonBruno Larsen1-0/+5
When executing in reverse and runs out of recorded history, GDB prints a warning to the user, but does not add a reason in the stopped record, for example: *stopped,frame={addr="0x000000000040113e",func="main",args=[],file="/home/blarsen/Documents/fsf_build/gdb/testsuite/../../../binutils-gdb/gdb/testsuite/gdb.reverse/solib-reverse.c",fullname="/home/blarsen/Documents/binutils-gdb/gdb/testsuite/gdb.reverse/solib-reverse.c",line="27",arch="i386:x86-64"},thread-id="1",stopped-threads="all",core="1" This problem was reported as record/29260. This commit adds the reason no-history to the record, making it easier for interfaces using the mi interpreter to report the result. It also changes the test gdb.mi/mi-reverse.exp to test that the reason shows up correctly. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29260
2023-01-04gdb: add 'maintenance print record-instruction' commandBruno Larsen1-0/+8
While chasing some reverse debugging bugs, I found myself wondering what was recorded by GDB to undo and redo a certain instruction. This commit implements a simple way of printing that information. If there isn't enough history to print the desired instruction (such as when the user hasn't started recording yet or when they request 2 instructions back but only 1 was recorded), GDB warns the user like so: (gdb) maint print record-instruction Not enough recorded history If there is enough, GDB prints the instruction like so: (gdb) maint print record-instruction 4 bytes of memory at address 0x00007fffffffd5dc changed from: 01 00 00 00 Register eflags changed: [ IF ] Register rip changed: (void (*)()) 0x401115 <main+15> Approved-by: Eli Zaretskii <eliz@gnu.org> Reviewed-by: Alexandra Hajkova <ahajkova@redhat.com> Reviewed-by: Lancelot Six <lsix@lancelotsix.com> Approved-by: Tom Tromey <tom@tromey.com>
2023-01-02Initial implementation of Debugger Adapter ProtocolTom Tromey1-0/+4
The Debugger Adapter Protocol is a JSON-RPC protocol that IDEs can use to communicate with debuggers. You can find more information here: https://microsoft.github.io/debug-adapter-protocol/ Frequently this is implemented as a shim, but it seemed to me that GDB could implement it directly, via the Python API. This patch is the initial implementation. DAP is implemented as a new "interp". This is slightly weird, because it doesn't act like an ordinary interpreter -- for example it doesn't implement a command syntax, and doesn't use GDB's ordinary event loop. However, this seemed like the best approach overall. To run GDB in this mode, use: gdb -i=dap The DAP code will accept JSON-RPC messages on stdin and print responses to stdout. GDB redirects the inferior's stdout to a new pipe so that output can be encapsulated by the protocol. The Python code uses multiple threads to do its work. Separate threads are used for reading JSON from the client and for writing JSON to the client. All GDB work is done in the main thread. (The first implementation used asyncio, but this had some limitations, and so I rewrote it to use threads instead.) This is not a complete implementation of the protocol, but it does implement enough to demonstrate that the overall approach works. There is a rudimentary test suite. It uses a JSON parser written in pure Tcl. This parser is under the same license as Tcl itself, so I felt it was acceptable to simply import it into the tree. There is also a bit of documentation -- just documenting the new interpreter name.
2022-12-19Remove MI version 1Tom Tromey1-0/+2
MI version 1 is long since obsolete. Several years ago, I filed PR mi/23170 for this. I think it's finally time to remove this. Any users of MI 1 can and should upgrade to a newer version. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=23170
2022-12-18Update gdb/NEWS after GDB 13 branch creation.Joel Brobecker1-1/+3
This commit a new section for the next release branch, and renames the section of the current branch, now that it has been cut.
2022-12-14gdb/maint: add core file name to 'maint info program-spaces' outputAndrew Burgess1-0/+4
Each program space can have an associated core file. Include this information in the output of 'maint info program-spaces'.
2022-12-02gdb: merge solib-frv aix-solib debug options into "set/show debug solib"Simon Marchi1-0/+12
solib implementations are typically used one at a time. So it will be rare that you will want to enable debug for one solib kind, and absolutely want to keep the others disabled. To make things simpler, instead of adding separate variables / macros / commands for each solib implementation, merge the existing ones (frv and aix) into a unified "set/show debug solib", with the solib_debug_printf macro. Change-Id: I6e18bbc7401724f37ae66681badb079d75ecf7fa
2022-11-19Show locno for 'multi location' breakpoint hit msg+conv var $_hit_bbnum ↵Philippe Waroquiers1-0/+26
$_hit_locno PR breakpoints/12464 This implements the request given in PR breakpoints/12464. Before this patch, when a breakpoint that has multiple locations is reached, GDB printed: Thread 1 "zeoes" hit Breakpoint 1, some_func () at somefunc1.c:5 This patch changes the message so that bkpt_print_id prints the precise encountered breakpoint: Thread 1 "zeoes" hit Breakpoint 1.2, some_func () at somefunc1.c:5 In mi mode, bkpt_print_id also (optionally) prints a new table field "locno": locno is printed when the breakpoint hit has more than one location. Note that according to the GDB user manual node 'GDB/MI Development and Front Ends', it is ok to add new fields without changing the MI version. Also, when a breakpoint is reached, the convenience variables $_hit_bpnum and $_hit_locno are set to the encountered breakpoint number and location number. $_hit_bpnum and $_hit_locno can a.o. be used in the command list of a breakpoint, to disable the specific encountered breakpoint, e.g. disable $_hit_bpnum.$_hit_locno In case the breakpoint has only one location, $_hit_locno is set to the value 1, so as to allow a command such as: disable $_hit_bpnum.$_hit_locno to disable the breakpoint even when the breakpoint has only one location. This also fixes a strange behaviour: when a breakpoint X has only one location, enable|disable X.1 is accepted but transforms the breakpoint in a multiple locations breakpoint having only one location. The changes in RFA v4 handle the comments of Tom Tromey: - Changed convenience var names from $bkptno/$locno to $_hit_bpnum/$_hit_locno. - updated the tests and user manual accordingly. User manual also explictly describes that $_hit_locno is set to 1 for a breakpoint with a single location. - The variable values are now set in bpstat_do_actions_1 so that they are set for silent breakpoints, and when several breakpoints are hit at the same time, that the variables are set to the printed breakpoint. The changes in RFA v3 handle the additional comments of Eli: GDB/NEW: - Use max 80-column - Use 'code location' instead of 'location'. - Fix typo $bkpno - Ensure that disable $bkptno and disable $bkptno.$locno have each their explanation inthe example - Reworded the 'breakpoint-hit' paragraph. gdb.texinfo: - Use 'code location' instead of 'location'. - Add a note to clarify the distinction between $bkptno and $bpnum. - Use @kbd instead of examples with only one command. Compared to RFA v1, the changes in v2 handle the comments given by Keith Seitz and Eli Zaretskii: - Use %s for the result of paddress - Use bkptno_numopt_re instead of 2 different -re cases - use C@t{++} - Add index entries for $bkptno and $locno - Added an example for "locno" in the mi interface - Added examples in the Break command manual.
2022-11-17gdb: new $_inferior_thread_count convenience variableAndrew Burgess1-0/+3
Add a new convenience variable $_inferior_thread_count that contains the number of live (non-exited) threads in the current inferior. This can be used in command scripts, or breakpoint conditions, etc to adjust the behaviour for multi-threaded inferiors. This value is only stable in all-stop mode. In non-stop mode, where new threads can be started, and existing threads exit, at any time, this convenience variable can give a different value each time it is evaluated.
2022-11-16gdb: add "set style tui-current-position on|off", default to offPedro Alves1-0/+9
As discussed at: https://sourceware.org/pipermail/gdb-patches/2020-June/169519.html this patch disables source and assembly code highlighting for the text highlighted by the TUI's current position indicator, and adds a command to enable it back.
2022-11-05Deprecate MI version 1Tom Tromey1-0/+2
MI version 1 is long since obsolete. Rather than remove it immediately (though I did send a patch for that), instead let's deprecate it in GDB 13 and then remove it for GDB 14. This version of the patch incorporates Simon's warning change, and Luis' recommendation to mention the gdb versions here.
2022-10-10gdb: add infcall specific debuggingAndrew Burgess1-0/+4
Add two new commands: set debug infcall on|off show debug infcall These enable some new debugging related to when GDB makes inferior function calls. I've added some basic debugging for what I think are the major steps in the inferior function call process, but I'm sure we might want to add more later.
2022-10-02gdb: disassembler opcode display formattingAndrew Burgess1-0/+12
This commit changes the format of 'disassemble /r' to match GNU objdump. Specifically, GDB will now display the instruction bytes in as 'objdump --wide --disassemble' does. Here is an example for RISC-V before this patch: (gdb) disassemble /r 0x0001018e,0x0001019e Dump of assembler code from 0x1018e to 0x1019e: 0x0001018e <call_me+66>: 03 26 84 fe lw a2,-24(s0) 0x00010192 <call_me+70>: 83 25 c4 fe lw a1,-20(s0) 0x00010196 <call_me+74>: 61 65 lui a0,0x18 0x00010198 <call_me+76>: 13 05 85 6a addi a0,a0,1704 0x0001019c <call_me+80>: f1 22 jal 0x10368 <printf> End of assembler dump. And here's an example after this patch: (gdb) disassemble /r 0x0001018e,0x0001019e Dump of assembler code from 0x1018e to 0x1019e: 0x0001018e <call_me+66>: fe842603 lw a2,-24(s0) 0x00010192 <call_me+70>: fec42583 lw a1,-20(s0) 0x00010196 <call_me+74>: 6561 lui a0,0x18 0x00010198 <call_me+76>: 6a850513 addi a0,a0,1704 0x0001019c <call_me+80>: 22f1 jal 0x10368 <printf> End of assembler dump. There are two differences here. First, the instruction bytes after the patch are grouped based on the size of the instruction, and are byte-swapped to little-endian order. Second, after the patch, GDB now uses the bytes-per-line hint from libopcodes to add whitespace padding after the opcode bytes, this means that in most cases the instructions are nicely aligned. It is still possible for a very long instruction to intrude into the disassembled text space. The next example is x86-64, before the patch: (gdb) disassemble /r main Dump of assembler code for function main: 0x0000000000401106 <+0>: 55 push %rbp 0x0000000000401107 <+1>: 48 89 e5 mov %rsp,%rbp 0x000000000040110a <+4>: c7 87 d8 00 00 00 01 00 00 00 movl $0x1,0xd8(%rdi) 0x0000000000401114 <+14>: b8 00 00 00 00 mov $0x0,%eax 0x0000000000401119 <+19>: 5d pop %rbp 0x000000000040111a <+20>: c3 ret End of assembler dump. And after the patch: (gdb) disassemble /r main Dump of assembler code for function main: 0x0000000000401106 <+0>: 55 push %rbp 0x0000000000401107 <+1>: 48 89 e5 mov %rsp,%rbp 0x000000000040110a <+4>: c7 87 d8 00 00 00 01 00 00 00 movl $0x1,0xd8(%rdi) 0x0000000000401114 <+14>: b8 00 00 00 00 mov $0x0,%eax 0x0000000000401119 <+19>: 5d pop %rbp 0x000000000040111a <+20>: c3 ret End of assembler dump. Most instructions are aligned, except for the very long instruction. Notice too that for x86-64 libopcodes doesn't request that GDB group the instruction bytes. This matches the behaviour of objdump. In case the user really wants the old behaviour, I have added a new modifier 'disassemble /b', this displays the instruction byte at a time. For x86-64, which never groups instruction bytes, /b and /r are equivalent, but for RISC-V, using /b gets the old layout back (except that the whitespace for alignment is still present). Consider our original RISC-V example, this time using /b: (gdb) disassemble /b 0x0001018e,0x0001019e Dump of assembler code from 0x1018e to 0x1019e: 0x0001018e <call_me+66>: 03 26 84 fe lw a2,-24(s0) 0x00010192 <call_me+70>: 83 25 c4 fe lw a1,-20(s0) 0x00010196 <call_me+74>: 61 65 lui a0,0x18 0x00010198 <call_me+76>: 13 05 85 6a addi a0,a0,1704 0x0001019c <call_me+80>: f1 22 jal 0x10368 <printf> End of assembler dump. Obviously, this patch is a potentially significant change to the behaviour or /r. I could have added /b with the new behaviour and left /r alone. However, personally, I feel the new behaviour is significantly better than the old, hence, I made /r be what I consider the "better" behaviour. The reason I prefer the new behaviour is that, when I use /r, I almost always want to manually decode the instruction for some reason, and having the bytes displayed in "instruction order" rather than memory order, just makes this easier. The 'record instruction-history' command also takes a /r modifier, and has been modified in the same way as disassemble; /r gets the new behaviour, and /b has been added to retain the old behaviour. Finally, the MI command -data-disassemble, is unchanged in behaviour, this command now requests the raw bytes of the instruction, which is equivalent to the /b modifier. This means that the MI output will remain backward compatible.
2022-09-26binutils, gdb: support zstd compressed debug sectionsFangrui Song1-0/+2
PR29397 PR29563: Add new configure option --with-zstd which defaults to auto. If pkgconfig/libzstd.pc is found, define HAVE_ZSTD and support zstd compressed debug sections for most tools. * bfd: for addr2line, objdump --dwarf, gdb, etc * gas: support --compress-debug-sections=zstd * ld: support ELFCOMPRESS_ZSTD input and --compress-debug-sections=zstd * objcopy: support ELFCOMPRESS_ZSTD input for --decompress-debug-sections and --compress-debug-sections=zstd * gdb: support ELFCOMPRESS_ZSTD input. The bfd change references zstd symbols, so gdb has to link against -lzstd in this patch. If zstd is not supported, ELFCOMPRESS_ZSTD input triggers an error. We can avoid HAVE_ZSTD if binutils-gdb imports zstd/ like zlib/, but this is too heavyweight, so don't do it for now. ``` % ld/ld-new a.o ld/ld-new: a.o: section .debug_abbrev is compressed with zstd, but BFD is not built with zstd support ... % ld/ld-new a.o --compress-debug-sections=zstd ld/ld-new: --compress-debug-sections=zstd: ld is not built with zstd support % binutils/objcopy --compress-debug-sections=zstd a.o b.o binutils/objcopy: --compress-debug-sections=zstd: binutils is not built with zstd support % binutils/objcopy b.o --decompress-debug-sections binutils/objcopy: zstd.o: section .debug_abbrev is compressed with zstd, but BFD is not built with zstd support ... ```
2022-09-22gdb/python: restrict the names accepted by gdb.register_window_typeAndrew Burgess1-0/+5
I noticed that, from Python, I could register a new TUI window that had whitespace in its name, like this: gdb.register_window_type('my window', MyWindowType) however, it is not possible to then use this window in a new TUI layout, e.g.: (gdb) tui new-layout foo my window 1 cmd 1 Unknown window "my" (gdb) tui new-layout foo "my window" 1 cmd 1 Unknown window ""my" (gdb) tui new-layout foo my\ window 1 cmd 1 Unknown window "my\" GDB clearly uses the whitespace to split the incoming command line. I could fix this by trying to add a mechanism by which we can use whitespace within a window name, but it seems like an easier solution if we just forbid whitespace within a window name. Not only is this easier, but I think this is probably the better solution, identifier names with spaces in would mean we'd need to audit all the places a window name could be printed and ensure that the use of a space didn't make the output ambiguous. So, having decided to disallow whitespace, I then thought about other special characters. We currently accept anything as a window name, and I wondered if this was a good idea. My concerns were about how special characters used in a window name might cause confusion, for example, we allow '$' in window names, which is maybe fine now, but what if one day we wanted to allow variable expansion when creating new layouts? Or what about starting a window name with '-'? We already support a '-horizontal' option, what if we want to add more in the future? Or use of the special character '{' which has special meaning within a new layout? In the end I figured it might make sense to place some restrictive rules in place, and then relax the rules later if/when users complain, we can consider each relaxation as its requested. So, I propose that window names should match this regular expression: [a-zA-Z][-_.a-zA-Z0-9]* There is a chance that there is user code in the wild which will break with the addition of this change, but hopefully adapting to the new restrictions shouldn't be too difficult.
2022-09-13gdbserver/csky add csky gdbserver supportJiangshuai Li1-0/+4
Add new files: gdb/arch/csky.c gdb/arch/csky.h gdb/features/cskyv2-linux.c gdbserver/linux-csky-low.cc 1. In gdb/arch/csky.c file, add function "csky_create_target_description()" for csky_target::low_arch_setup(). later, it can be used for csky native gdb. 2. In gdb/features/cskyv2-linux.c file, create target_tdesc for csky, include gprs, pc, hi, lo, float, vector and float control registers. 3. In gdbserver/linux-csky-low.cc file, using PTRACE_GET/SET_RGESET to get/set registers. The main data structures in asm/ptrace.h are: struct pt_regs { unsigned long tls; unsigned long lr; unsigned long pc; unsigned long sr; unsigned long usp; /* * a0, a1, a2, a3: * r0, r1, r2, r3 */ unsigned long orig_a0; unsigned long a0; unsigned long a1; unsigned long a2; unsigned long a3; /* * r4 ~ r13 */ unsigned long regs[10]; /* r16 ~ r30 */ unsigned long exregs[15]; unsigned long rhi; unsigned long rlo; unsigned long dcsr; }; struct user_fp { unsigned long vr[96]; unsigned long fcr; unsigned long fesr; unsigned long fid; unsigned long reserved; };
2022-08-25Allow to document user-defined aliases.Philippe Waroquiers1-0/+10
Compared to the previous version, this version fixes the comments reported by Tom Tromey and ensures that the 'help some-user-documented-alias' shows the alias definition to ensure the user understands this is an alias even if specifically documented. When using 'help ALIASNAME', GDB shows the help of the aliased command. This is a good default behaviour. However, GDB alias command allows to define aliases with arguments possibly changing or tuning significantly the behaviour of the aliased command. In such a case, showing the help of the aliased command might not be ideal. This is particularly true when defining an alias as a set of nested 'with' followed by a last command to launch, such as: (gdb) alias pp10 = with print pretty -- with print elements 10 -- print Asking 'help pp10' shows the help of the 'with' command, which is not particularly useful: (gdb) help pp10 with, pp10, w alias pp10 = with print pretty -- with print elements 10 -- print Temporarily set SETTING to VALUE, run COMMAND, and restore SETTING. Usage: with SETTING [VALUE] [-- COMMAND] .... Such an alias can now be documented by the user: (gdb) document pp10 >Pretty printing an expressiong, printing 10 elements. >Usage: pp10 [PRINT-COMMAND-OPTIONS] EXP >See 'help print' for more information. >end (gdb) help pp10 alias pp10 = with print pretty -- with print elements 10 -- print Pretty printing an expressiong, printing 10 elements. Usage: pp10 [PRINT-COMMAND-OPTIONS] EXP See 'help print' for more information. (gdb) When a user-defined alias is documented specifically, help and apropos use the provided alias documentation instead of the documentation of the aliased command. Such a documented alias is also not shown anymore in the help of the aliased command, and the alias is not listed anymore in the help of the aliased command. In particular for cases such as pp10 example above, indicating that pp10 is an alias of the 'with' command is confusing.
2022-08-24gdb: new 'maint print frame-id' commandAndrew Burgess1-0/+4
When debugging a certain class of GDB bug, I often end up wanting to know what GDB thinks the frame-id is in a particular frame. It's not too hard to pull this from some debug output, but I thought it might be nice if there was a maintenance command that could tell us. This commit adds 'maint print frame-id' which prints the frame-id of the currently selected frame. You can also pass a frame level number to find the frame-id for a specific frame. There's a new test too.
2022-08-22Implement target async for WindowsTom Tromey1-0/+2
This implements target async for Windows. The basic idea is to have the worker thread block in WaitForDebugEvent, then notify the event loop when an event is seen. In a few situations, this blocking behavior is undesirable, so the functions passed to do_synchronously are changed to return a boolean indicating which behavior is needed.
2022-08-10gdb/mi: fix breakpoint script field outputSimon Marchi1-0/+14
The "script" field, output whenever information about a breakpoint with commands is output, uses wrong MI syntax. $ ./gdb -nx -q --data-directory=data-directory -x script -i mi =thread-group-added,id="i1" =breakpoint-created,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x000000000000111d",func="main",file="test.c",fullname="/home/simark/build/binutils-gdb-one-target/gdb/test.c",line="3",thread-groups=["i1"],times="0",original-location="main"} =breakpoint-modified,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x000000000000111d",func="main",file="test.c",fullname="/home/simark/build/binutils-gdb-one-target/gdb/test.c",line="3",thread-groups=["i1"],times="0",script={"aaa","bbb","ccc"},original-location="main"} (gdb) -break-info ^done,BreakpointTable={nr_rows="1",nr_cols="6",hdr=[{width="7",alignment="-1",col_name="number",colhdr="Num"},{width="14",alignment="-1",col_name="type",colhdr="Type"},{width="4",alignment="-1",col_name="disp",colhdr="Disp"},{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},{width="18",alignment="-1",col_name="addr",colhdr="Address"},{width="40",alignment="2",col_name="what",colhdr="What"}],body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x000000000000111d",func="main",file="test.c",fullname="/home/simark/build/binutils-gdb-one-target/gdb/test.c",line="3",thread-groups=["i1"],times="0",script={"aaa","bbb","ccc"},original-location="main"}]} (gdb) In both the =breakpoint-modified and -break-info output, we have: script={"aaa","bbb","ccc"} According to the output syntax [1], curly braces means tuple, and a tuple contains key=value pairs. This looks like it should be a list, but uses curly braces by mistake. This would make more sense: script=["aaa","bbb","ccc"] Fix it, keeping the backwards compatibility by introducing a new MI version (MI4), in exactly the same way as was done when fixing multi-locations breakpoint output in [2]. - Add a fix_breakpoint_script_output uiout flag. MI uiouts will use this flag if the version is >= 4. - Add a fix_breakpoint_script_output_globally variable and the -fix-breakpoint-script-output MI command to set it, if frontends want to use the fixed output for this without using the newer MI version. - When emitting the script field, use list instead of tuple, if we want the fixed output (depending on the two criteria above) - [1] https://sourceware.org/gdb/onlinedocs/gdb/GDB_002fMI-Output-Syntax.html#GDB_002fMI-Output-Syntax [2] https://gitlab.com/gnutools/binutils-gdb/-/commit/b4be1b0648608a2578bbed39841c8ee411773edd Change-Id: I7113c6892832c8d6805badb06ce42496677e2242 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=24285
2022-07-28gdb/python: Add BreakpointLocation typeSimon Farre1-0/+5
PR python/18385 v7: This version addresses the issues pointed out by Tom. Added nullchecks for Python object creations. Changed from using PyLong_FromLong to the gdb_py-versions. Re-factored some code to make it look more cohesive. Also added the more safe Python reference count decrement PY_XDECREF, even though the BreakpointLocation type is never instantiated by the user (explicitly documented in the docs) decrementing < 0 is made impossible with the safe call. Tom pointed out that using the policy class explicitly to decrement a reference counted object was not the way to go, so this has instead been wrapped in a ref_ptr that handles that for us in blocpy_dealloc. Moved macro from py-internal to py-breakpoint.c. Renamed section at the bottom of commit message "Patch Description". v6: This version addresses the points Pedro gave in review to this patch. Added the attributes `function`, `fullname` and `thread_groups` as per request by Pedro with the argument that it more resembles the output of the MI-command "-break-list". Added documentation for these attributes. Cleaned up left overs from copy+paste in test suite, removed hard coding of line numbers where possible. Refactored some code to use more c++-y style range for loops wrt to breakpoint locations. Changed terminology, naming was very inconsistent. Used a variety of "parent", "owner". Now "owner" is the only term used, and the field in the gdb_breakpoint_location_object now also called "owner". v5: Changes in response to review by Tom Tromey: - Replaced manual INCREF/DECREF calls with gdbpy_ref ptrs in places where possible. - Fixed non-gdb style conforming formatting - Get parent of bploc increases ref count of parent. - moved bploc Python definition to py-breakpoint.c The INCREF of self in bppy_get_locations is due to the individual locations holding a reference to it's owner. This is decremented at de-alloc time. The reason why this needs to be here is, if the user writes for instance; py loc = gdb.breakpoints()[X].locations[Y] The breakpoint owner object is immediately going out of scope (GC'd/dealloced), and the location object requires it to be alive for as long as it is alive. Thanks for your review, Tom! v4: Fixed remaining doc issues as per request by Eli. v3: Rewritten commit message, shortened + reworded, added tests. Patch Description Currently, the Python API lacks the ability to query breakpoints for their installed locations, and subsequently, can't query any information about them, or enable/disable individual locations. This patch solves this by adding Python type gdb.BreakpointLocation. The type is never instantiated by the user of the Python API directly, but is produced by the gdb.Breakpoint.locations attribute returning a list of gdb.BreakpointLocation. gdb.Breakpoint.locations: The attribute for retrieving the currently installed breakpoint locations for gdb.Breakpoint. Matches behavior of the "info breakpoints" command in that it only returns the last known or currently inserted breakpoint locations. BreakpointLocation contains 7 attributes 6 read-only attributes: owner: location owner's Python companion object source: file path and line number tuple: (string, long) / None address: installed address of the location function: function name where location was set fullname: fullname where location was set thread_groups: thread groups (inferiors) where location was set. 1 writeable attribute: enabled: get/set enable/disable this location (bool) Access/calls to these, can all throw Python exceptions (documented in the online documentation), and that's due to the nature of how breakpoint locations can be invalidated "behind the scenes", either by them being removed from the original breakpoint or changed, like for instance when a new symbol file is loaded, at which point all breakpoint locations are re-created by GDB. Therefore this patch has chosen to be non-intrusive: it's up to the Python user to re-request the locations if they become invalid. Also there's event handlers that handle new object files etc, if a Python user is storing breakpoint locations in some larger state they've built up, refreshing the locations is easy and it only comes with runtime overhead when the Python user wants to use them. gdb.BreakpointLocation Python type struct "gdbpy_breakpoint_location_object" is found in python-internal.h Its definition, layout, methods and functions are found in the same file as gdb.Breakpoint (py-breakpoint.c) 1 change was also made to breakpoint.h/c to make it possible to enable and disable a bp_location* specifically, without having its LOC_NUM, as this number also can change arbitrarily behind the scenes. Updated docs & news file as per request. Testsuite: tests the .source attribute and the disabling of individual locations. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=18385 Change-Id: I302c1c50a557ad59d5d18c88ca19014731d736b0
2022-07-19[AArch64] MTE corefile supportLuis Machado1-0/+10
Teach GDB how to dump memory tags for AArch64 when using the gcore command and how to read memory tag data back from a core file generated by GDB (via gcore) or by the Linux kernel. The format is documented in the Linux Kernel documentation [1]. Each tagged memory range (listed in /proc/<pid>/smaps) gets dumped to its own PT_AARCH64_MEMTAG_MTE segment. A section named ".memtag" is created for each of those segments when reading the core file back. To save a little bit of space, given MTE tags only take 4 bits, the memory tags are stored packed as 2 tags per byte. When reading the data back, the tags are unpacked. I've added a new testcase to exercise the feature. Build-tested with --enable-targets=all and regression tested on aarch64-linux Ubuntu 20.04. [1] Documentation/arm64/memory-tagging-extension.rst (Core Dump Support)
2022-07-15Add 'summary' mode to Value.format_stringTom Tromey1-0/+4
This adds a 'summary' mode to Value.format_string and to gdb.print_options. For the former, it lets Python code format values using this mode. For the latter, it lets a printer potentially detect if it is being called in a backtrace with 'set print frame-arguments' set to 'scalars'. I considered adding a new mode here to let a pretty-printer see whether it was being called in a 'backtrace' context at all, but I'm not sure if this is really desirable.
2022-07-15Expose current 'print' settings to PythonTom Tromey1-0/+7
PR python/17291 asks for access to the current print options. While I think this need is largely satisfied by the existence of Value.format_string, it seemed to me that a bit more could be done. First, while Value.format_string uses the user's settings, it does not react to temporary settings such as "print/x". This patch changes this. Second, there is no good way to examine the current settings (in particular the temporary ones in effect for just a single "print"). This patch adds this as well. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=17291
2022-07-14gdb: Document floating-point support for LoongArchTiezhu Yang1-0/+4
Update NEWS and gdb.texinfo to document floating-point support for LoongArch. Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
2022-07-11gdb: add support for disassembler styling using libopcodesAndrew Burgess1-0/+28
This commit extends GDB to make use of libopcodes styling support where available, currently this is just i386 based architectures, and RISC-V. For architectures that don't support styling using libopcodes GDB will fall back to using the Python Pygments package, when the package is available. The new libopcodes based styling has the disassembler identify parts of the disassembled instruction, e.g. registers, immediates, mnemonics, etc, and can style these components differently. Additionally, as the styling is now done in GDB we can add settings to allow the user to configure which colours are used right from the GDB CLI. There's some new maintenance commands: maintenance set libopcodes-styling enabled on|off maintenance show libopcodes-styling These can be used to manually disable use of libopcodes styling. This is a maintenance command as it's not anticipated that a user should need to do this. But, this could be useful for testing, or, in some rare cases, a user might want to override the Python hook used for disassembler styling, and then disable libopcode styling so that GDB falls back to using Python. Right now I would consider this second use case a rare situation, which is why I think a maintenance command is appropriate. When libopcodes is being used for styling then the user can make use of the following new styles: set/show style disassembler comment set/show style disassembler immediate set/show style disassembler mnemonic set/show style disassembler register The disassembler also makes use of the 'address' and 'function' styles to style some parts of the disassembler output. I have also added the following aliases though: set/show style disassembler address set/show style disassembler symbol these are aliases for: set/show style address set/show style function respectively, and exist to make it easier for users to discover disassembler related style settings. The 'address' style is used to style numeric addresses in the disassembler output, while the 'symbol' or 'function' style is used to style the names of symbols in disassembler output. As not every architecture supports libopcodes styling, the maintenance setting 'libopcodes-styling enabled' has an "auto-off" type behaviour. Consider this GDB session: (gdb) show architecture The target architecture is set to "auto" (currently "i386:x86-64"). (gdb) maintenance show libopcodes-styling enabled Use of libopcodes styling support is "on". the setting defaults to "on" for architectures that support libopcodes based styling. (gdb) set architecture sparc The target architecture is set to "sparc". (gdb) maintenance show libopcodes-styling enabled Use of libopcodes styling support is "off" (not supported on architecture "sparc") the setting will show as "off" if the user switches to an architecture that doesn't support libopcodes styling. The underlying setting is still "on" at this point though, if the user switches back to i386:x86-64 then the setting would go back to being "on". (gdb) maintenance set libopcodes-styling enabled off (gdb) maintenance show libopcodes-styling enabled Use of libopcodes styling support is "off". now the setting is "off" for everyone, even if the user switches back to i386:x86-64 the setting will still show as "off". (gdb) maintenance set libopcodes-styling enabled on Use of libopcodes styling not supported on architecture "sparc". (gdb) maintenance show libopcodes-styling enabled Use of libopcodes styling support is "off". attempting to switch the setting "on" for an unsupported architecture will give an error, and the setting will remain "off". (gdb) set architecture auto The target architecture is set to "auto" (currently "i386:x86-64"). (gdb) maintenance show libopcodes-styling enabled Use of libopcodes styling support is "off". (gdb) maintenance set libopcodes-styling enabled on (gdb) maintenance show libopcodes-styling enabled Use of libopcodes styling support is "on". the user will need to switch back to a supported architecture before they can one again turn this setting "on".
2022-07-05Add gdb.Objfile.is_file attributeTom Tromey1-0/+3
Sometimes an objfile comes from memory and not from a file. It can be useful to be able to check this from Python, so this patch adds a new "is_file" attribute.
2022-06-30GDB: Add `NUMBER' completion to `set' integer commandsMaciej W. Rozycki1-0/+12
Fix a completion consistency issue with `set' commands accepting integer values and the special `unlimited' keyword: (gdb) complete print -elements print -elements NUMBER print -elements unlimited (gdb) vs: (gdb) complete set print elements set print elements unlimited (gdb) (there is a space entered at the end of both commands, not shown here) which also means if you strike <Tab> with `set print elements ' input, it will, annoyingly, complete to `set print elements unlimited' right away rather than showing a choice between `NUMBER' and `unlimited'. Add `NUMBER' then as an available completion for such `set' commands: (gdb) complete set print elements set print elements NUMBER set print elements unlimited (gdb) Adjust the testsuite accordingly. Also document the feature in the Completion section of the manual in addition to the Command Options section already there.
2022-06-18gdb/doc: Documentation for the new print commandEnze Li1-0/+5
Document the new command "print nibbles" and add a NEWS entry.
2022-06-17gdb: NEWS: Move LoongArch gdbserver to the correct sectionTiezhu Yang1-3/+8
commit e5ab6af52d38 ("gdbserver: Add LoongArch/Linux support") was merged into the master since GDB 12, so we should put the news in the "Changes since GDB 12" section. Thanks Tom Tromey for your correction [1], sorry for that. [1] https://sourceware.org/pipermail/gdb-patches/2022-June/190122.html Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
2022-06-15gdb/python: implement the print_insn extension language hookAndrew Burgess1-0/+34
This commit extends the Python API to include disassembler support. The motivation for this commit was to provide an API by which the user could write Python scripts that would augment the output of the disassembler. To achieve this I have followed the model of the existing libopcodes disassembler, that is, instructions are disassembled one by one. This does restrict the type of things that it is possible to do from a Python script, i.e. all additional output has to fit on a single line, but this was all I needed, and creating something more complex would, I think, require greater changes to how GDB's internal disassembler operates. The disassembler API is contained in the new gdb.disassembler module, which defines the following classes: DisassembleInfo Similar to libopcodes disassemble_info structure, has read-only properties: address, architecture, and progspace. And has methods: __init__, read_memory, and is_valid. Each time GDB wants an instruction disassembled, an instance of this class is passed to a user written disassembler function, by reading the properties, and calling the methods (and other support methods in the gdb.disassembler module) the user can perform and return the disassembly. Disassembler This is a base-class which user written disassemblers should inherit from. This base class provides base implementations of __init__ and __call__ which the user written disassembler should override. DisassemblerResult This class can be used to hold the result of a call to the disassembler, it's really just a wrapper around a string (the text of the disassembled instruction) and a length (in bytes). The user can return an instance of this class from Disassembler.__call__ to represent the newly disassembled instruction. The gdb.disassembler module also provides the following functions: register_disassembler This function registers an instance of a Disassembler sub-class as a disassembler, either for one specific architecture, or, as a global disassembler for all architectures. builtin_disassemble This provides access to GDB's builtin disassembler. A common use case that I see is augmenting the existing disassembler output. The user code can call this function to have GDB disassemble the instruction in the normal way. The user gets back a DisassemblerResult object, which they can then read in order to augment the disassembler output in any way they wish. This function also provides a mechanism to intercept the disassemblers reads of memory, thus the user can adjust what GDB sees when it is disassembling. The included documentation provides a more detailed description of the API. There is also a new CLI command added: maint info python-disassemblers This command is defined in the Python gdb.disassemblers module, and can be used to list the currently registered Python disassemblers.
2022-06-14gdbserver: Add LoongArch/Linux supportYouling Tang1-0/+3
Implement LoongArch/Linux support, including XML target description handling based on features determined, GPR regset support, and software breakpoint handling. In the Linux kernel code of LoongArch, ptrace implements PTRACE_POKEUSR and PTRACE_PEEKUSR in the arch_ptrace function, so srv_linux_usrregs is set to yes. With this patch on LoongArch: $ make check-gdb TESTS="gdb.server/server-connect.exp" [...] # of expected passes 18 [...] Signed-off-by: Youling Tang <tangyouling@loongson.cn> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
2022-06-07Allow ASLR to be disabled on WindowsTom Tromey1-0/+2
On Windows, it is possible to disable ASLR when creating a process. This patch adds code to do this, and hooks it up to gdb's existing disable-randomization feature. Because the Windows documentation cautions that this isn't available on all versions of Windows, the CreateProcess wrapper function is updated to make the attempt, and then fall back to the current approach if it fails.
2022-06-06Consolidate "Python API" sections in NEWSTom Tromey1-7/+5
I noticed that the gdb NEWS file had two "Python API" sections in "Changes since GDB 12". This patch consolidates the two. I chose to preserve the second one, first because it is longer, and second because I felt that user command changes should come before API changes.
2022-06-01Add gdb.current_language and gdb.Frame.languageTom Tromey1-0/+7
This adds the gdb.current_language function, which can be used to find the current language without (1) ever having the value "auto" or (2) having to parse the output of "show language". It also adds the gdb.Frame.language, which can be used to find the language of a given frame. This is normally preferable if one has a Frame object handy.
2022-05-28gdb/python: improve formatting of help text for user defined commandsAndrew Burgess1-0/+7
Consider this command defined in Python (in the file test-cmd.py): class test_cmd (gdb.Command): """ This is the first line. Indented second line. This is the third line. """ def __init__ (self): super ().__init__ ("test-cmd", gdb.COMMAND_OBSCURE) def invoke (self, arg, from_tty): print ("In test-cmd") test_cmd() Now, within a GDB session: (gdb) source test-cmd.py (gdb) help test-cmd This is the first line. Indented second line. This is the third line. (gdb) I think there's three things wrong here: 1. The leading blank line, 2. The trailing blank line, and 3. Every line is indented from the left edge slightly. The problem of course, is that GDB is using the Python doc string verbatim as its help text. While the user has formatted the help text so that it appears clear within the .py file, this means that the text appear less well formatted when displayed in the "help" output. The same problem can be observed for gdb.Parameter objects in their set/show output. In this commit I aim to improve the "help" output for commands and parameters. To do this I have added gdbpy_fix_doc_string_indentation, a new function that rewrites the doc string text following the following rules: 1. Leading blank lines are removed, 2. Trailing blank lines are removed, and 3. Leading whitespace is removed in a "smart" way such that the relative indentation of lines is retained. With this commit in place the above example now looks like this: (gdb) source ~/tmp/test-cmd.py (gdb) help test-cmd This is the first line. Indented second line. This is the third line. (gdb) Which I think is much neater. Notice that the indentation of the second line is retained. Any blank lines within the help text (not leading or trailing) will be retained. I've added a NEWS entry to note that there has been a change in behaviour, but I didn't update the manual. The existing manual is suitably vague about how the doc string is used, so I think the new behaviour is covered just as well by the existing text.
2022-05-25Show enabled locations with disabled breakpoint parent as "y-"Pedro Alves1-0/+10
Currently, breakpoint locations that are enabled while their parent breakpoint is disabled are displayed with "y" in the Enb colum of "info breakpoints": (gdb) info breakpoints Num Type Disp Enb Address What 1 breakpoint keep n <MULTIPLE> 1.1 y 0x00000000000011b6 in ... 1.2 y 0x00000000000011c2 in ... 1.3 n 0x00000000000011ce in ... Such locations won't trigger a break, so to avoid confusion, show "y-" instead. For example: (gdb) info breakpoints Num Type Disp Enb Address What 1 breakpoint keep n <MULTIPLE> 1.1 y- 0x00000000000011b6 in ... 1.2 y- 0x00000000000011c2 in ... 1.3 n 0x00000000000011ce in ... The "-" sign is inspired on how the TUI represents breakpoints on the left side of the source window, with "b-" for a disabled breakpoint. Change-Id: I9952313743c51bf21b4b380c72360ef7d4396a09
2022-05-03NEWS: Add a note for TLS support on FreeBSD/arm and FreeBSD/Aarch64.John Baldwin1-0/+3
2022-04-27gdb/arm: Extend arm_m_addr_is_magic to support FNC_RETURN, add ↵Christophe Lyon1-0/+5
unwind-secure-frames command This patch makes use of the support for several stack pointers introduced by the previous patch to switch between them as needed during unwinding. It introduces a new 'unwind-secure-frames' arm command to enable/disable mode switching during unwinding. It is enabled by default. It has been tested using an STM32L5 board (with cortex-m33) and the sample applications shipped with the STM32Cube development environment: GTZC_TZSC_MPCBB_TrustZone in STM32CubeL5/Projects/NUCLEO-L552ZE-Q/Examples/GTZC. The test consisted in setting breakpoints in various places and check that the backtrace is correct: SecureFault_Callback (Non-secure mode), __gnu_cmse_nonsecure_call (before and after the vpush instruction), SecureFault_Handler (Secure mode). This implies that we tested only some parts of this patch (only MSP* were used), but remaining parts seem reasonable. Signed-off-by: Torbjörn Svensson <torbjorn.svensson@st.com> Signed-off-by: Christophe Lyon <christophe.lyon@foss.st.com> Signed-off-by: Christophe Lyon <christophe.lyon@arm.com>
2022-04-04gdb: Add maint set ignore-prologue-end-flagLancelot SIX1-0/+9
The previous patch added support for the DWARF prologue-end flag in line table. This flag can be used by DWARF producers to indicate where to place breakpoints past a function prologue. However, this takes precedence over prologue analyzers. So if we have to debug a program with erroneous debug information, the overall debugging experience will be degraded. This commit proposes to add a maintenance command to instruct GDB to ignore the prologue_end flag. Tested on x86_64-gnu-linux. Change-Id: Idda6d1b96ba887f4af555b43d9923261b9cc6f82
2022-04-04gdb: Add support for DW_LNS_set_prologue_end in line-tableLancelot SIX1-0/+11
Add support for DW_LNS_set_prologue_end when building line-tables. This attribute can be set by the compiler to indicate that an instruction is an adequate place to set a breakpoint just after the prologue of a function. The compiler might set multiple prologue_end, but considering how current skip_prologue_using_sal works, this commit modifies it to accept the first instruction with this marker (if any) to be the place where a breakpoint should be placed to be at the end of the prologue. The need for this support came from a problematic usecase generated by hipcc (i.e. clang). The problem is as follows: There's a function (lets call it foo) which covers PC from 0xa800 to 0xa950. The body of foo begins with a call to an inlined function, covering from 0xa800 to 0xa94c. The issue is that when placing a breakpoint at 'foo', GDB inserts the breakpoint at 0xa818. The 0x18 offset is what GDB thinks is foo's first address past the prologue. Later, when hitting the breakpoint, GDB reports the stop within the inlined function because the PC falls in its range while the user expects to stop in FOO. Looking at the line-table for this location, we have: INDEX LINE ADDRESS IS-STMT [...] 14 293 0x000000000000a66c Y 15 END 0x000000000000a6e0 Y 16 287 0x000000000000a800 Y 17 END 0x000000000000a818 Y 18 287 0x000000000000a824 Y [...] For comparison, let's look at llvm-dwarfdump's output for this CU: Address Line Column File ISA Discriminator Flags ------------------ ------ ------ ------ --- ------------- ------------- [...] 0x000000000000a66c 293 12 2 0 0 is_stmt 0x000000000000a6e0 96 43 82 0 0 is_stmt 0x000000000000a6f8 102 18 82 0 0 is_stmt 0x000000000000a70c 102 24 82 0 0 0x000000000000a710 102 18 82 0 0 0x000000000000a72c 101 16 82 0 0 is_stmt 0x000000000000a73c 2915 50 83 0 0 is_stmt 0x000000000000a74c 110 1 1 0 0 is_stmt 0x000000000000a750 110 1 1 0 0 is_stmt end_sequence 0x000000000000a800 107 0 1 0 0 is_stmt 0x000000000000a800 287 12 2 0 0 is_stmt prologue_end 0x000000000000a818 114 59 81 0 0 is_stmt 0x000000000000a824 287 12 2 0 0 is_stmt 0x000000000000a828 100 58 82 0 0 is_stmt [...] The main difference we are interested in here is that llvm-dwarfdump's output tells us that 0xa800 is an adequate place to place a breakpoint past a function prologue. Since we know that foo covers from 0xa800 to 0xa94c, 0xa800 is the address at which the breakpoint should be placed if the user wants to break in foo. This commit proposes to add support for the prologue_end flag in the line-program processing. The processing of this prologue_end flag is made in skip_prologue_sal, before it calls gdbarch_skip_prologue_noexcept. The intent is that if the compiler gave information on where the prologue ends, we should use this information and not try to rely on architecture dependent logic to guess it. The testsuite have been executed using this patch on GNU/Linux x86_64. Testcases have been compiled with both gcc/g++ (verison 9.4.0) and clang/clang++ (version 10.0.0) since at the time of writing GCC does not set the prologue_end marker. Tests done with GCC 11.2.0 (not over the entire testsuite) show that it does not emit this flag either. No regression have been observed with GCC or Clang. Note that when using Clang, this patch fixes a failure in gdb.opt/inline-small-func.exp. Change-Id: I720449a8a9b2e1fb45b54c6095d3b1e9da9152f8
2022-04-03gdb/tui: add a tui debugging flagAndrew Burgess1-0/+4
This commit adds 'set debug tui on|off' and 'show debug tui'. This commit adds the control variable, and the printing macros in tui/tui.h. I've then added some uses of these in tui.c and tui-layout.c. To help produce more useful debug output in tui-layout.c, I've added some helper member functions in the class tui_layout_split, and also moved the size_info struct out of tui_layout_split::apply into the tui_layout_split class. If tui debug is not turned on, then there should be no user visible changes after this commit. One thing to note is that, due to the way that the tui terminal is often cleared, the only way I've found this useful is when I do: (gdb) tui enable (gdb) set logging file /path/to/file (gdb) set logging debugredirect on (gdb) set logging enable on Additionally, gdb has some quirks when it comes to setting up logging redirect and switching interpreters. Thus, the above only really works if the logging is enabled after the tui is enabled, and disabled again before the tui is disabled. Enabling logging and switching interpreters can cause undefined results, including crashes. This is an existing bug in gdb[1], and has nothing directly to do with tui debug, but it is worth mentioning here I think. [1] https://sourceware.org/bugzilla/show_bug.cgi?id=28948
2022-04-03gdb/tui: add new 'tui window width' command and 'winwidth' aliasAndrew Burgess1-0/+6
This commit adds a new command 'tui window width', and an alias 'winwidth'. This command is equivalent to the old 'winheight' command (which was recently renamed 'tui window height'). Even though I recently moved the old tui commands under the tui namespace, and I would strongly encourage all new tui commands to be added as 'tui ....' only (users can create their own top-level aliases if they want), I'm breaking that suggestion here, and adding a 'winwidth' alias. Given that we already have 'winheight' and have done for years, it just didn't seem right to no have the matching 'winwidth'. You might notice in the test that the window resizing doesn't quite work right. I setup a horizontal layout, then grow and shrink the windows. At the end of the test the windows should be back to their original size... ... they are not. This isn't my fault, honest! GDB's window resizing is a little ... temperamental, and is prone to getting things slightly wrong during resizes, off by 1 type things. This is true for height resizing, as well as the new width resizing. Later patches in this series will rework the resizing algorithm, which should improve things in this area. For now, I'm happy that the width resizing is as good as the height resizing, given the existing quirks. For the docs side I include a paragraph that explains how multiple windows are required before the width can be adjusted. For completeness, I've added the same paragraph to the winheight description. With the predefined layouts this extra paragraph is not really needed for winheight, as there are always multiple windows on the screen. However, with custom layouts, this might not be true, so adding the paragraph seems like a good idea. As for the changes in gdb itself, I've mostly just taken the existing height adjustment code, changed the name to make it generic 'size' adjustment, and added a boolean flag to indicate if we are adjusting the width or the height.
2022-04-03gdb: move some commands into the tui namespaceAndrew Burgess1-0/+15
There are a lot of tui related commands that live in the top-level command name space, e.g. layout, focus, refresh, winheight. Having them at the top level means less typing for the user, which is good, but, I think, makes command discovery harder. In this commit, I propose moving all of the above mentioned commands into the tui namespace, so 'layout' becomes 'tui layout', etc. But I will then add aliases so that the old commands will still work, e.g. I'll make 'layout' an alias for 'tui layout'. The benefit I see in this work is that tui related commands can be more easily discovered by typing 'tui ' and then tab-completing. Also the "official" command is now a tui-sub-command, this is visible in, for example, the help output, e.g.: (gdb) help layout tui layout, layout Change the layout of windows. Usage: tui layout prev | next | LAYOUT-NAME List of tui layout subcommands: tui layout asm -- Apply the "asm" layout. tui layout next -- Apply the next TUI layout. tui layout prev -- Apply the previous TUI layout. tui layout regs -- Apply the TUI register layout. tui layout split -- Apply the "split" layout. tui layout src -- Apply the "src" layout. Which I think is a good thing, it makes it clearer that this is a tui command. I've added a NEWS entry and updated the docs to mention the new and old command names, with the new name being mentioned first.
2022-03-31Remove dbx modeTom Tromey1-0/+2
This patch removes gdb's dbx mode. Regression tested on x86-64 Fedora 34.
2022-03-23gdb/python: remove Python 2 supportSimon Marchi1-0/+3
New in this version: - Add a PY_MAJOR_VERSION check in configure.ac / AC_TRY_LIBPYTHON. If the user passes --with-python=python2, this will cause a configure failure saying that GDB only supports Python 3. Support for Python 2 is a maintenance burden for any patches touching Python support. Among others, the differences between Python 2 and 3 string and integer types are subtle. It requires a lot of effort and thinking to get something that behaves correctly on both. And that's if the author and reviewer of the patch even remember to test with Python 2. See this thread for an example: https://sourceware.org/pipermail/gdb-patches/2021-December/184260.html So, remove Python 2 support. Update the documentation to state that GDB can be built against Python 3 (as opposed to Python 2 or 3). Update all the spots that use: - sys.version_info - IS_PY3K - PY_MAJOR_VERSION - gdb_py_is_py3k ... to only keep the Python 3 portions and drop the use of some now-removed compatibility macros. I did not update the configure script more than just removing the explicit references to Python 2. We could maybe do more there, like check the Python version and reject it if that version is not supported. Otherwise (with this patch), things will only fail at compile time, so it won't really be clear to the user that they are trying to use an unsupported Python version. But I'm a bit lost in the configure code that checks for Python, so I kept that for later. Change-Id: I75b0f79c148afbe3c07ac664cfa9cade052c0c62
2022-03-22Add support for hardware breakpoints/watchpoints on FreeBSD/Aarch64.John Baldwin1-0/+2
This shares aarch64-nat.c and nat/aarch64-hw-point.c with the Linux native target. Since FreeBSD writes all of the debug registers in one ptrace op, use an unordered_set<> to track the "dirty" state for threads rather than bitmasks of modified registers.
2022-03-22gdb/python: add gdb.format_address functionAndrew Burgess1-0/+8
Add a new function, gdb.format_address, which is a wrapper around GDB's print_address function. This method takes an address, and returns a string with the format: ADDRESS <SYMBOL+OFFSET> Where, ADDRESS is the original address, formatted as hexadecimal, SYMBOL is a symbol with an address lower than ADDRESS, and OFFSET is the offset from SYMBOL to ADDRESS in decimal. If there's no SYMBOL suitably close to ADDRESS then the <SYMBOL+OFFSET> part is not included. This is useful if a user wants to write a Python script that pretty-prints addresses, the user no longer needs to do manual symbol lookup, or worry about correctly formatting addresses. Additionally, there are some settings that effect how GDB picks SYMBOL, and whether the file name and line number should be included with the SYMBOL name, the gdb.format_address function ensures that the users Python script also benefits from these settings. The gdb.format_address by default selects SYMBOL from the current inferiors program space, and address is formatted using the architecture for the current inferior. However, a user can also explicitly pass a program space and architecture like this: gdb.format_address(ADDRESS, PROGRAM_SPACE, ARCHITECTURE) In order to format an address for a different inferior. Notes on the implementation: In py-arch.c I extended arch_object_to_gdbarch to add an assertion for the type of the PyObject being worked on. Prior to this commit all uses of arch_object_to_gdbarch were guaranteed to pass this function a gdb.Architecture object, but, with this commit, this might not be the case. So, with this commit I've made it a requirement that the PyObject be a gdb.Architecture, and this is checked with the assert. And in order that callers from other files can check if they have a gdb.Architecture object, I've added the new function gdbpy_is_architecture. In py-progspace.c I've added two new function, the first progspace_object_to_program_space, converts a PyObject of type gdb.Progspace to the associated program_space pointer, and gdbpy_is_progspace checks if a PyObject is a gdb.Progspace or not.
2022-03-20Update gdb/NEWS after GDB 12 branch creation.Joel Brobecker1-1/+3
This commit a new section for the next release branch, and renames the section of the current branch, now that it has been cut.
2022-03-17gdb: Remove support for S+corePedro Alves1-1/+5
GCC removed support for score back in 2014 already. Back then, we basically agreed about removing it from GDB too, but it ended up being forgotten. See: https://sourceware.org/pipermail/gdb/2014-October/044643.html Following through this time around. Change-Id: I5b25a1ff7bce7b150d6f90f4c34047fae4b1f8b4