summaryrefslogtreecommitdiff
path: root/gdb/doc
AgeCommit message (Collapse)Author
2022-07-28gdb/python: Add BreakpointLocation typeSimon Farre
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-25set/show python dont-write-bytecode fixesKevin Buettner
GDB uses the environment variable PYTHONDONTWRITEBYTECODE to determine whether or not to write the result of byte-compiling python modules when the "python dont-write-bytecode" setting is "auto". Simon noticed that GDB's implementation doesn't follow the Python documentation. At present, GDB only checks for the existence of this environment variable. That is not sufficient though. Regarding PYTHONDONTWRITEBYTECODE, this document... https://docs.python.org/3/using/cmdline.html ...says: If this is set to a non-empty string, Python won't try to write .pyc files on the import of source modules. This commit fixes GDB's handling of PYTHONDONTWRITEBYTECODE by adding an empty string check. This commit also corrects the set/show command documentation for "python dont-write-bytecode". The current doc was just a copy of that for set/show python ignore-environment. During his review of an earlier version of this patch, Eli Zaretskii asked that the help text that I proposed for "set/show python dont-write-bytecode" be expanded. I've done that in addition to clarifying the documentation of this option in the GDB manual.
2022-07-19[AArch64] MTE corefile supportLuis Machado
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-18Add gdb.free_objfile event registryTom Tromey
Currently, Python code can use event registries to detect when gdb loads a new objfile, and when gdb clears the objfile list. However, there's no way to detect the removal of an objfile, say when the inferior calls dlclose. This patch adds a gdb.free_objfile event registry and arranges for an event to be emitted in this case.
2022-07-15Add 'summary' mode to Value.format_stringTom Tromey
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 Tromey
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 Yang
Update NEWS and gdb.texinfo to document floating-point support for LoongArch. Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
2022-07-12Improve "set scheduler-locking" documentationPedro Alves
This improves the "set scheduler-locking" documentation in the GDB manual: - Use a table to describe the four available modes. - Describe "step" in terms of "on" and "off". - Tweak the "replay" mode's description to describe replay first instead of recording, and also mention how the mode behaves during normal execution. - Say what is the default mode. Change-Id: Ie12140138b37534b7fc1d904da34f0f174aa11ce
2022-07-11Fix non-existent "@var{thread-id}" in stop reply descriptionsPedro Alves
In the description of stop replies, where the "thread" register is explained, and where the fork and vfork stop reasons are detailed, there are references to "@var{thread-id}", but such variable does not actually exist. This commit fixes it. Change-Id: If679944aaf15f6f64aabe506339a9e7667864cab
2022-07-11gdb: add support for disassembler styling using libopcodesAndrew Burgess
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 Tromey
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-07-01GDB/doc: Remove indentation from `print -elements' completion exampleMaciej W. Rozycki
Remove indentation from the text of the manual after the example here: " Completion will in some cases guide you with a suggestion of what kind of argument an option expects. For example: (gdb) print -elements <TAB><TAB> NUMBER unlimited Here, the option expects a number (e.g., '100'), not literal 'NUMBER'. Such metasyntactical arguments are always presented in uppercase." as this is a continuation of the same paragraph.
2022-07-01GDB/doc: Remove extraneous spaces from completion examplesMaciej W. Rozycki
Completion results are usually different when the operation is applied to a word that is or is not followed by a space. In some cases they are equivalent, however a space would not be produced if completion was used earlier on in the word processed. However in the manual we have completion examples given using a space that actually prevents the example from working. E.g.: (gdb) info bre <TAB> (nothing) and: (gdb) info bre <TAB><TAB> Display all 200 possibilities? (y or n) as it now goes on to propose the entire symbol table, while: (gdb) info bre<TAB> (gdb) info breakpoints does the right thing, but is not what is shown in the manual. In other cases an extraneous space is used that does not correspond to the actual completion pattern shown, which gives an impression of sloppiness. Remove extraneous spaces then from completion examples as appropriate.
2022-06-30GDB: Add `NUMBER' completion to `set' integer commandsMaciej W. Rozycki
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-30gdb/doc: fix column widths in MI compatibility tableAndrew Burgess
In passing I noticed that the column headings for the table of MI compatibility and breaking changes, were overlapping, at least when the PDF is generated on my machine. I propose giving slightly more space to the two version number columns, this prevents the headers overlapping for me.
2022-06-29gdb/doc: improve description of --data-disassemble opcodes outputAndrew Burgess
Extend the description of the MI command --data-disassemble. Specifically, expand the description of the 'opcodes' field to explain how the bytes are formatted.
2022-06-21Document how GDB searches for files when using -s, -e, and -se optionsKevin Buettner
GDB's documentation of the 'file' command says: If you do not specify a directory and the file is not found in the GDB working directory, GDB uses the environment variable PATH as a list of directories to search, just as the shell does when looking for a program to run. The same is true for files specified via commandline options -s, -e, and -se. This commit adds a cross reference to the file command for these options.
2022-06-18gdb/python: Export nibbles to python layerEnze Li
This patch makes it possible to allow Value.format_string() to return nibbles output. When we set the parameter of nibbles to True, we can achieve the displaying binary values in groups of every four bits. Here's an example: (gdb) py print (gdb.Value (1230).format_string (format='t', nibbles=True)) 0100 1100 1110 (gdb) Note that the parameter nibbles is only useful if format='t' is also used. This patch also includes update to the relevant testcase and documentation. Tested on x86_64 openSUSE Tumbleweed.
2022-06-18gdb/doc: Documentation for the new print commandEnze Li
Document the new command "print nibbles" and add a NEWS entry.
2022-06-15Add to documentation of Python 'dont_repeat' methodTom Tromey
PR python/28533 points out that the Python 'dont_repeat' documentation is a bit ambiguous about when the method ought to be called. This patch spells it out.
2022-06-15gdb/python: implement the print_insn extension language hookAndrew Burgess
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-09Minor fix to Python breakpoint event documentationTom Tromey
I noticed that the Python event documentation referred to the event's "breakpoint" field as a function, whereas it is actually an attribute. This patch fixes the error.
2022-06-06Remove "-break-insert -r" testsTom Tromey
PR mi/14270 points out that mi-break.exp has some tests for an unimplemented "-r" switch for "-break-insert". This switch was never implemented, and is not documented -- though it is mentioned in a comment in the documentation. This patch removes the test and the doc comment. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=14270
2022-06-02Rearrange and slightly reword the "Location Specification" sectionEli Zaretskii
This rearranges and changes the wording of the "Location Specification" section of the GDB manual in minor ways.
2022-06-01Add gdb.current_language and gdb.Frame.languageTom Tromey
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-31Improve clear command's documentationPedro Alves
Co-Authored-By: Eli Zaretskii <eliz@gnu.org> Change-Id: I9440052fd28f795d6f7c93a4576beadd21f28885
2022-05-31Improve break-range's documentationPedro Alves
Change-Id: Iac26e1d2e7d8dc8a7d9516e6bdcc5c3fc4af45c8
2022-05-31Explicitly mention yet-unloaded shared libraries in location spec examplesPedro Alves
Change-Id: I05639ddb3bf620c7297b57ed286adc3aa926b7b6
2022-05-30gdb/manual: Introduce location specsPedro Alves
The current "Specify Location" section of the GDB manual starts with: "Several @value{GDBN} commands accept arguments that specify a location of your program's code." And then, such commands are documented as taking a "location" argument. For example, here's a representative subset: @item break @var{location} @item clear @var{location} @item until @var{location} @item list @var{location} @item edit @var{location} @itemx info line @var{location} @item info macros @var{location} @item trace @var{location} @item info scope @var{location} @item maint agent @r{[}-at @var{location}@r{,}@r{]} @var{expression} The issue here is that "location" isn't really correct for most of these commands. Instead, the "location" argument is really a placeholder that represent an umbrella term for all of the "linespecs", "explicit location", and "address location" input formats. GDB parses these and then finds the actual code locations (plural) in the program that match. For example, a "location" specified like "-function func" will actually match all the code locations in the program that correspond to the address/file/lineno of all the functions named "func" in all the loaded programs and shared libraries of all the inferiors. A location specified like "-function func -label lab" matches all the addresses of C labels named "lab" in all functions named "func". Etc. This means that several of the commands that claim they accept a "location", actually end up working with multiple locations, and the manual doesn't explain that all that well. In some cases, the command will work with all the resolved locations. In other cases, the command aborts with an error if the location specification resolves to multiple locations in the program. In other cases, GDB just arbitrarily and silently picks whatever is the first resolved code location (which sounds like should be improved). To clarify this, I propose we use the term "Location Specification", with shorthand "locaction spec", when we're talking about the user input, the argument or arguments that is/are passed to commands to instruct GDB how to find locations of interest. This is distinct from the actual code locations in the program, which are what GDB finds based on the user-specified location spec. Then use "location specification or the shorter "location spec" thoughout instead of "location" when we're talking about the user input. Thus, this commit does the following: - renames the "Specify Location" section of the manual to "Location Specifications". - It then introduces the term "Location Specification", with corresponding shorthand "location spec", as something distinct from an actual code location in the program. It explains what a concrete code location is. It explains that a location specification may be incomplete, and that may match multiple code locations in the program, or no code location at all. It gives examples. Some pre-existing examples were moved from the "Set Breaks" section, and a few new ones that didn't exist yet were added. I think it is better to have these centralized in this "Location Specification" section, since all the other commands that accept a location spec have an xref that points there. - Goes through the manual, and where "@var{location}" was used for a command argument, updated it to say "@var{locspec}" instead. At the same time, tweaks the description of the affected commands to describe what happens when the location spec resolves to more than one location. Most commands just did not say anything about that. One command -- "maint agent -at @var{location}" -- currently says it accepts a "location", suggesting it can accept address and explicit locations too, but that's incorrect. In reality, it only accepts linespecs, so fix it accordingly. One MI command -- "-trace-find line" -- currently says it accepts a "line specification", but it can accept address and explicit locations too, so fix it accordingly. Special thanks goes to Eli Zaretskii for reviews and rewording suggestions. Change-Id: Ic42ad8565e79ca67bfebb22cbb4794ea816fd08b
2022-05-25Show enabled locations with disabled breakpoint parent as "y-"Pedro Alves
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-20Remove obsolete text from documentationTom Tromey
The documentation says that -enable-pretty-printing is experimental in 7.0 and may change -- that's long enough ago that I think we can say that this text is no longer correct or useful.
2022-05-19gdb/doc: use @value{GDBP} in 'info pretty-printer' exampleAndrew Burgess
Update the 'info pretty-printer' example in the manual to make use of @value{GDBP} instead of hard-coding '(gdb)'.
2022-05-19gdb/doc: make use of group/end group in 'info pretty-printers' exampleAndrew Burgess
The 'info pretty-printers' example is pretty long and consists of many commands and their output. Currently, when the pdf manual is generated this example spans a page-break, with the page-break falling part way through some example output from GDB. This commit breaks up the example using @group .... @end group, within each group is a single GDB command and all its output. Now, when the pdf manual is created, the page-break is placed after the output of one GDB command, and before the subsequent command, this looks much nicer.
2022-05-19gdb/doc: fix inconsistent info pretty-printer exampleNikolaos Chatzikonstantinou
The example for 'info pretty-printer' in the manual passes an object-regexp in some cases, but presents output as though no object-regexp was passed. This commit fixes the two mistakes, in one case, fixing the output to filter based on object-regexp, and in the other, to remove the object-regexp from the command and leave all the output.
2022-05-17Fix typo in info pageNikolaos Chatzikonstantinou
2022-05-16gdb: Fix typo in last change in gdb.texinfoEli Zaretskii
2022-05-16gdb: Document the 'metadata' styling in GDB displays.Eli Zaretskii
The 'metadata' styling was never documented in the GDB manual. This fills that gap.
2022-04-27gdb/arm: Extend arm_m_addr_is_magic to support FNC_RETURN, add ↵Christophe Lyon
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-14Reorganize Python events documentationTom Tromey
This slightly reorganizes the Python events documentation. It hoists the "ThreadEvent" text out of the list of events, where it seemed to be misplaced. It tidies the formatting a little bit (adding some vertical space for easier reading in info), fixes a typo, adds some missing commas, and fixes an incorrect reference to NewInferiorEvent.
2022-04-12Remove "Ada Settings" node from the manualTom Tromey
A while back, I sent a patch to unify the Ada varsize-limit setting with the more generic max-value-size: https://sourceware.org/pipermail/gdb-patches/2021-September/182004.html However, it turns out I somehow neglected to send part of the patch. Internally, I also removed the "Ada Settings" node from the manual, as it only documents the obsolete setting. This patch removes this text.
2022-04-11gdb/doc: add section about Fortran intrinsic functions and typesNils-Christian Kempke
The earlier version of this document had no sections about the available Fortran intrinsic functions or the Fortran builtin types. I added two sections 'Fortran intrinsics' and 'Fortran types' to document the available Fortran language features. The subsection 'Fortran Defaults' has been integrated into the Fortran subsection.
2022-04-06Enable ARMv8.1-m PACBTI supportLuis Machado
This set of changes enable support for the ARMv8.1-m PACBTI extensions [1]. The goal of the PACBTI extensions is similar in scope to that of a-profile PAC/BTI (aarch64 only), but the underlying implementation is different. One important difference is that the pointer authentication code is stored in a separate register, thus we don't need to mask/unmask the return address from a function in order to produce a correct backtrace. The patch introduces the following modifications: - Extend the prologue analyser for 32-bit ARM to handle some instructions from ARMv8.1-m PACBTI: pac, aut, pacg, autg and bti. Also keep track of return address signing/authentication instructions. - Adds code to identify object file attributes that indicate the presence of ARMv8.1-m PACBTI (Tag_PAC_extension, Tag_BTI_extension, Tag_PACRET_use and Tag_BTI_use). - Adds support for DWARF pseudo-register RA_AUTH_CODE, as described in the aadwarf32 [2]. - Extends the dwarf unwinder to track the value of RA_AUTH_CODE. - Decorates backtraces with the "[PAC]" identifier when a frame has signed the return address. - Makes GDB aware of a new XML feature "org.gnu.gdb.arm.m-profile-pacbti". This feature is not included as an XML file on GDB's side because it is only supported for bare metal targets. - Additional documentation. [1] https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/armv8-1-m-pointer-authentication-and-branch-target-identification-extension [2] https://github.com/ARM-software/abi-aa/blob/main/aadwarf32/aadwarf32.rst
2022-04-05Fix qRcmd error code parsingLuis Machado
Someone at IRC spotted a bug in qRcmd handling. This looks like an oversight or it is that way for historical reasons. The code in gdb/remote.c:remote_target::rcmd uses isdigit instead of isxdigit. One could argue that we are expecting decimal numbers, but further below we use fromhex (). Update the function to use isxdigit instead and also update the documentation. I see there are lots of other cases of undocumented number format for error messages, mostly described as NN instead of nn. For now I'll just update this particular function.
2022-04-04gdb: Add maint set ignore-prologue-end-flagLancelot SIX
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 SIX
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 Burgess
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 Burgess
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 Burgess
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-31Style URLs in GDB outputTom Tromey
I noticed that GDB will display URLs in a few spots. This changes them to be styled. Originally I thought I'd introduce a new "url" style, but there aren't many places to use this, so I just reused filename styling instead. This patch also changes the debuginfod URL list to be printed one URL per line. I think this is probably a bit easier to read.
2022-03-31Remove dbx modeTom Tromey
This patch removes gdb's dbx mode. Regression tested on x86-64 Fedora 34.