aboutsummaryrefslogtreecommitdiff
path: root/gdb/doc
AgeCommit message (Collapse)AuthorFilesLines
2021-02-24gdb: add a new 'maint info target-sections' commandAndrew Burgess2-0/+13
We already have a command 'maint info sections', this command prints all sections from all known object files. However, GDB maintains a second section table internally. This section table is used when GDB wants to read directly from an object file rather than actually reading memory on the target. As such only some sections (the allocatable ones) are added to this secondary section table. I recently ran into a situation where some of GDB's optimisations for reading directly from the files were not working. In 'maint info sections' I could see that GDB knew about the object file, and did know about the sections that it _should_ have been reading from. But I couldn't ask GDB which sections it had copied into its secondary section table. This commit adds a new command 'maint info target-sections' that fills this gap. This command lists only those sections that GDB has copied into its secondary table. You'll notice that the testsuite includes a comment indicating that there's a bug in GDB. Normally this is not something I would add to the testsuite, instead we should raise an actual bugzilla bug and then mark an xfail, however, a later patch in this series will remove this comment once the actual bug in GDB is fixed. gdb/ChangeLog: * NEWS: Mention new 'maint info target-sections' command. * maint.c (maintenance_info_target_sections): New function. (_initialize_maint_cmds): Register new command. gdb/doc/ChangeLog: * gdb.texinfo (Files): Document new 'maint info target-sections' command. gdb/testsuite/ChangeLog: * gdb.base/maint-info-sections.exp: Add new tests. (check_maint_info_target_sections_output): New proc.
2021-02-17[PR cli/17290] gdb/doc: Fix show remote interrupt-*.Lancelot SIX2-2/+8
Add the missing 'remote' in: - @item show remote interrupt-sequence - @item show remote interrupt-on-connect
2021-02-11gdb: change 'maint info section' to use command optionsAndrew Burgess2-13/+21
The 'maintenance info sections' command currently takes a list of filters on the command line. It can also accept the magic string 'ALLOBJ' which acts more like a command line flag, telling the command to print information about all objfiles. The manual has this to say about the options and filters: ... In addition, 'maint info sections' provides the following command options (which may be arbitrarily combined): ... Implying (to me at least) that I can do this: (gdb) maint info sections ALLOBJ READONLY to list all the read-only sections from all currently loaded object files. Unfortunately, this doesn't work. The READONLY filter will work, but ALLOBJ will not be detected correctly. It would be fairly simple to fix the ALLOBJ detection. However, I dislike this mixing of command options (ALLOBJ) with command data (the filters, e.g. READONLY, etc). As this is a maintenance command, so not really intended for end users, I think we can be a little more aggressive in "fixing" the option parsing. So that's what I do in this commit. The ALLOBJ mechanism is replaced with a real command option (-all-objects). The rest of the command operates just as before. The example above would now become: (gdb) maint info sections -all-objects READONLY The manual has been updated, and I added a NEWS entry to document the change. gdb/ChangeLog: * NEWS: Mention changes to 'maint info sections'. * maint.c (match_substring): Return a bool, fix whitespace issue. (struct single_bfd_flag_info): New struct. (bfd_flag_info): New static global. (match_bfd_flags): Return a bool, use bfd_flag_info. (print_bfd_flags): Use bfd_flag_info. (maint_print_section_info): Delete trailing whitespace. (struct maint_info_sections_opts): New struct. (maint_info_sections_option_defs): New static global. (maint_info_sections_completer): New function. (maintenance_info_sections): Use option parsing mechanism. (_initialize_maint_cmds): Register command completer. gdb/doc/ChangeLog: * gdb.texinfo (Files): Update documentation for 'maint info sections'. gdb/testsuite/ChangeLog: * gdb.base/maint-info-sections.exp: Update expected output, and add additional tests. Again.
2021-02-11gdb: Remove arm-symbianelf supportAlan Modra1-2/+2
Since it has gone from bfd/. * arm-symbian-tdep.c: Delete. * NEWS: Mention arm-symbian removal. * Makefile.in: Remove arm-symbian-tdep entries. * configure.tgt: Remove arm*-*-symbianelf*. * doc/gdb.texinfo: Remove mention of SymbianOS. * osabi.c (gdb_osabi_names): Remove "Symbian". * osabi.h (enum gdb_osabi): Remove GDB_OSABI_SYMBIAN. * testsuite/gdb.base/ending-run.exp: Remove E32Main handling. * testsuite/gdb.ada/catch_ex_std.exp: Remove arm*-*-symbianelf* handling. * testsuite/gdb.base/dup-sect.exp: Likewise. * testsuite/gdb.base/long_long.exp: Likewise. * testsuite/gdb.base/solib-weak.exp: Likewise. * testsuite/gdb.guile/scm-section-script.exp: Likewise. * testsuite/gdb.python/py-section-script.exp: Likewise. * testsuite/lib/dwarf.exp: Likewise. * testsuite/lib/gdb.exp: Likewise.
2021-02-08gdb: return true in TuiWindow.is_valid only if TUI is enabledAndrew Burgess2-0/+10
If the user implements a TUI window in Python, and this window responds to GDB events and then redraws its window contents then there is currently an edge case which can lead to problems. The Python API documentation suggests that calling methods like erase or write on a TUI window (from Python code) will raise an exception if the window is not valid. And the description for is_valid says: This method returns True when this window is valid. When the user changes the TUI layout, windows no longer visible in the new layout will be destroyed. At this point, the gdb.TuiWindow will no longer be valid, and methods (and attributes) other than is_valid will throw an exception. From this I, as a user, would expect that if I did 'tui disable' to switch back to CLI mode, then the window would no longer be valid. However, this is not the case. When the TUI is disabled the windows in the TUI are not deleted, they are simply hidden. As such, currently, the is_valid method continues to return true. This means that if the users Python code does something like: def event_handler (e): global tui_window_object if tui_window_object->is_valid (): tui_window_object->erase () tui_window_object->write ("Hello World") gdb.events.stop.connect (event_handler) Then when a stop event arrives GDB will try to draw the TUI window, even when the TUI is disabled. This exposes two bugs. First, is_valid should be returning false in this case, second, if the user forgot to add the is_valid call, then I believe the erase and write calls should be throwing an exception (when the TUI is disabled). The solution to both of these issues is I think bound together, as it depends on having a working 'is_valid' check. There's a rogue assert added into tui-layout.c as part of this commit. While working on this commit I managed to break GDB such that TUI_CMD_WIN was nullptr, this was causing GDB to abort. I'm leaving the assert in as it might help people catch issues in the future. This patch is inspired by the work done here: https://sourceware.org/pipermail/gdb-patches/2020-December/174338.html gdb/ChangeLog: * python/py-tui.c (gdbpy_tui_window) <is_valid>: New member function. (REQUIRE_WINDOW): Call is_valid member function. (REQUIRE_WINDOW_FOR_SETTER): New define. (gdbpy_tui_is_valid): Call is_valid member function. (gdbpy_tui_set_title): Call REQUIRE_WINDOW_FOR_SETTER instead. * tui/tui-data.h (struct tui_win_info) <is_visible>: Check tui_active too. * tui/tui-layout.c (tui_apply_current_layout): Add an assert. * tui/tui.c (tui_enable): Move setting of tui_active earlier in the function. gdb/doc/ChangeLog: * python.texinfo (TUI Windows In Python): Extend description of TuiWindow.is_valid. gdb/testsuite/ChangeLog: * gdb.python/tui-window-disabled.c: New file. * gdb.python/tui-window-disabled.exp: New file. * gdb.python/tui-window-disabled.py: New file.
2021-02-02Inferior without argument prints detail of current inferior.Lancelot SIX2-0/+21
This patch makes the inferior command display information about the current inferior when called with no argument. This behavior is similar to the one of the thread command. Before patch: (gdb) info inferior Num Description Connection Executable * 1 process 19221 1 (native) /home/lsix/tmp/a.out 2 process 19239 1 (native) /home/lsix/tmp/a.out (gdb) inferior 2 [Switching to inferior 2 [process 19239] (/home/lsix/tmp/a.out)] [Switching to thread 2.1 (process 19239)] #0 0x0000000000401146 in main () (gdb) inferior Argument required (expression to compute). After patch: (gdb) info inferior Num Description Connection Executable * 1 process 18699 1 (native) /home/lsix/tmp/a.out 2 process 18705 1 (native) /home/lsix/tmp/a.out (gdb) inferior 2 [Switching to inferior 2 [process 18705] (/home/lsix/tmp/a.out)] [Switching to thread 2.1 (process 18705)] #0 0x0000000000401146 in main () (gdb) inferior [Current inferior is 2 [process 18705] (/home/lsix/tmp/a.out)] gdb/doc/ChangeLog: * gdb.texinfo (Inferiors Connections and Programs): Document the inferior command when used without argument. gdb/ChangeLog: * NEWS: Add entry for the behavior change of the inferior command. * inferior.c (inferior_command): When no argument is given to the inferior command, display info about the currently selected inferior. gdb/testsuite/ChangeLog: * gdb.base/inferior-noarg.c: New test. * gdb.base/inferior-noarg.exp: New test.
2021-01-27Remove extra space after @pxref in gdb.texinfoTom Tromey2-1/+5
Internally at AdaCore, documentation is still built with Texinfo 4.13. This version gave an error when building gdb.texinfo: ../../../binutils-gdb/gdb/doc/gdb.texinfo:27672: @pxref expected braces. ../../../binutils-gdb/gdb/doc/gdb.texinfo:27672: ` {dotdebug_gdb_scripts section,,The @cod...' is too long for expansion; not expanded. ... followed by many more spurious errors that were caused by this one. This patch fix the problem by removing the extra space. I don't know whether it's advisable to try to support this ancient version of Texinfo (released in 2008 apparently); but in this particular case the fix is trivial, so I'm checking it in. gdb/doc/ChangeLog 2021-01-27 Tom Tromey <tromey@adacore.com> * gdb.texinfo (Auto-loading extensions): Remove extraneous space.
2021-01-25gdb/docs: add parentheses in Python examples using printMarco Barisione2-9/+13
This makes the examples work both in Python 2 and 3. gdb/doc/ChangeLog: * python.texi: Add parentheses to print statements/functions. Change-Id: I8571f2ee005acd96c7bb43f9882d19b00b2aa3db
2021-01-25gdb/doc: move @menu blocks to the end of their enclosing @nodeAndrew Burgess2-35/+44
The @menus should be at the end of a @node. We mostly get this right, but there's a few places where we don't. This commit fixes the 5 places we get this wrong. I manually checked the info page and read each of the offending nodes after this change and I believe they all still make sense with the menu moved. gdb/doc/ChangeLog: * gdb.texinfo (Specify Location): Move menu to the end of the node. (Auto-loading): Likewise. (Extending GDB): Likewise. (TUI): Likewise. (Operating System Information): Likewise.
2021-01-22gdb: add new version styleAndrew Burgess2-0/+17
This commit adds a new 'version' style, which replaces the hard coded styling currently used for GDB's version string. GDB's version number is displayed: 1. In the output of 'show version', and 2. When GDB starts up (without the --quiet option). This new style can only ever affect the first of these two cases as the second case is printed before GDB has processed any initialization files, or processed any GDB commands passed on the command line. However, because the first case exists I think this commit makes sense, it means the style is no longer hard coded into GDB, and we can add some tests that the style can be enabled/disabled correctly. This commit is an alternative to a patch Tom posted here: https://sourceware.org/pipermail/gdb-patches/2020-June/169820.html I've used the style name 'version' instead of 'startup' to reflect what the style is actually used for. If other parts of the startup text end up being highlighted I imagine they would get their own styles based on what is being highlighted. I feel this is more inline with the other style names that are already in use within GDB. I also decoupled adding this style from the idea of startup options, and the possibility of auto-saving startup options. Those ideas can be explored in later patches. This commit should probably be considered only a partial solution to issue PR cli/25956. The colours of the style are no longer hard coded, however, it is still impossible to change the styling of the version string displayed during startup, so in one sense, the styling of that string is still "hard coded". A later patch will hopefully extend GDB to allow it to adjust the version styling before the initial version string is printed. gdb/ChangeLog: PR cli/25956 * cli/cli-style.c: Add 'cli/cli-setshow.h' include. (version_style): Define. (cli_style_option::cli_style_option): Add intensity parameter, and use as appropriate. (_initialize_cli_style): Register version style set/show commands. * cli/cli-style.h (cli_style_option): Add intensity parameter. (version_style): Declare. * top.c (print_gdb_version): Use version_stype, and styled_string to print the GDB version string. gdb/doc/ChangeLog: PR cli/25956 * gdb.texinfo (Output Styling): Document version style. gdb/testsuite/ChangeLog: PR cli/25956 * gdb.base/style.exp (run_style_tests): Add version string test. (test_startup_version_string): Use version style name. * lib/gdb-utils.exp (style): Handle version style name.
2021-01-22gdb/doc: don't rely on @menu item within the docsAndrew Burgess2-11/+20
The node 'Auto-loading extensions' currently relies on a @menu item to provide a set of cross-references to different parts of the manual. Additionally the menu is placed part way through the node and the text prior to the menu seems (to me) to assume that the menu will be formatted into the document. This is a bad idea as the menus are not always part of the final document (e.g. pdf output does not include the menu), when compared to the info page the pdf version of this node is less helpful as it lacks proper cross references. Menus should always be placed at the end of a node. In this commit I rewrite a paragraph to add extra cross references inline within the text. I then move the menu to the end of the node. gdb/doc/ChangeLog: * gdb.texinfo (Auto-loading extensions): Add additional cross references and move @menu to the end of the node.
2021-01-22gdb/doc: move @menu to the end of the nodeAndrew Burgess2-4/+8
Commit: commit a72d0f3d69896b5fcdc916e0547fe774dcb58614 Date: Tue Jan 12 13:02:30 2021 +0000 gdb/doc: reorder and group sections relating to aliases Added a @menu block into the wrong place within a @node. This commit moves it to the end of the @node, where it should be been placed. gdb/doc/ChangeLog: * gdb.texinfo (Aliases): Move @menu to the end of the node.
2021-01-22gdb/doc: down case contents of @varAndrew Burgess2-2/+6
After a discussion on a recent patch it was pointed out that the contents of a @var should (generally) be lower case. I took a look through the GDB manual and there are a small number of places where the contents are currently upper case, but one in particular seemed like an obvious candidate for being down cased, so lets do that. gdb/doc/ChangeLog: * gdb.texinfo (PowerPC Embedded): Down case contents of @var.
2021-01-21gdb/doc: reorder and group sections relating to aliasesAndrew Burgess2-189/+204
This started by observing that the section name: Automatically prepend default arguments to user-defined aliases Is very long. When this is rendered in the PDF manual (at least for me), this name is so long that in the table of contents the page number ends up being misaligned. My first thought was we could drop the 'to user-defined aliases' bit if this section became a sub-section of the section on aliases. So then I looked for a section with 'aliases' in its name, and couldn't find one. It turns out that aliases are documented in a section called: Creating new spellings of existing commands Which (to me) seems an odd aspect of aliases to emphasise. So, in this patch I make the following changes: - Move the section on aliases earlier in the manual, this is now immediately after the section about creating user defined commands. This made more sense to me. - Rename the section on aliases from 'Creating new spellings of existing commands' to 'Command Aliases'. - Update the wording of the first paragraph in the 'Command Aliases' section so that it reads better given the new name. - Add a cross-reference from the 'Command Aliases' section to the 'Python' section now that the aliases section comes first. - Down case all the text inside @var within this section as this is the correct style for the GDB manual. - Move the section on default args to become a sub-section of the 'Command Aliases' section, and rename this sub-section from 'Automatically prepend default arguments to user-defined aliases' to 'Default Arguments'. - Add @menu into the 'Command Aliases' section to link to the 'Default Arguments' subsection. - Add a @cindex entry to the default arguments sub-section. gdb/doc/ChangeLog: * gdb.texinfo (Commands): Update menu. (Extending GDB): Likewise. (Command aliases default args): Moved later into the document, added a cindex entry. Renamed the section 'Automatically prepend default arguments to user-defined aliases' to 'Default Arguments'. (Aliases): Moved earlier in the document. Minor rewording of the first paragraph, down-cased the text inside all uses of @var, and added a cross reference to the Python code. Renamed the section 'Creating new spellings of existing commands' to 'Command Aliases'.
2021-01-21Add Python support for hardware breakpointsHannes Domani2-0/+10
This allows the creation of hardware breakpoints in Python with gdb.Breakpoint(type=gdb.BP_HARDWARE_BREAKPOINT) And they are included in the sequence returned by gdb.breakpoints(). gdb/ChangeLog: 2021-01-21 Hannes Domani <ssbssa@yahoo.de> PR python/19151 * python/py-breakpoint.c (bppy_get_location): Handle bp_hardware_breakpoint. (bppy_init): Likewise. (gdbpy_breakpoint_created): Likewise. gdb/doc/ChangeLog: 2021-01-21 Hannes Domani <ssbssa@yahoo.de> PR python/19151 * python.texi (Breakpoints In Python): Document gdb.BP_HARDWARE_BREAKPOINT. gdb/testsuite/ChangeLog: 2021-01-21 Hannes Domani <ssbssa@yahoo.de> PR python/19151 * gdb.python/py-breakpoint.exp: Add tests for hardware breakpoints.
2021-01-01Manual updates of copyright year range not covered by gdb/copyright.pyJoel Brobecker3-4/+8
gdb/ChangeLog: * gdbarch.sh: Update copyright year range. gdb/doc/ChangeLog: * gdb.texinfo, refcard.tex: Update copyright year range.
2021-01-01Update copyright year range in all GDB filesJoel Brobecker14-14/+14
This commits the result of running gdb/copyright.py as per our Start of New Year procedure... gdb/ChangeLog Update copyright year range in copyright header of all GDB files.
2020-12-29Fix wrong method nameHannes Domani2-1/+5
The objects returned by FrameDecorator.frame_args need to implement a method named symbol, not argument. gdb/doc/ChangeLog: 2020-12-29 Hannes Domani <ssbssa@yahoo.de> * python.texi (Frame Decorator API): Fix method name.
2020-12-23Clarify language for the '?' packetAlex Bennée2-3/+8
Both QEMU and kgdb make the assumption that the '?' packet is only sent during the initial setup of a gdbstub connection. Both use that knowledge to reset breakpoints and ensure the gdbstub is in a clean-state on a resumed connection. This can cause confusion for others implementing clients that speak to gdbstub devices. To avoid that make the language clearer that this is a start-up query packet that you only expect to see once. Signed-off-by: Alex Bennée <alex.bennee@linaro.org> gdb/doc/ChangeLog: * gdb.texinfo (Packets): Clarify language for ? packet. Change-Id: Iae25d3110fe28b8d2467704962a6889e55224ca5
2020-12-21gdb.texinfo: Document GMP as mandatory requirement to build GDBJoel Brobecker2-0/+13
gdb/doc/ChangeLog * gdb.texinfo (Requirements): Add GMP to list of requirements.
2020-12-18Remove erroneous 'a' in gdb.register_window_type documentationHannes Domani2-1/+5
gdb/doc/ChangeLog: 2020-12-18 Hannes Domani <ssbssa@yahoo.de> * python.texi (TUI Windows In Python): Remove erroneous 'a'.
2020-12-18Add address keyword to Value.format_stringHannes Domani2-0/+9
This makes it possible to disable the address in the result string: const char *str = "alpha"; (gdb) py print(gdb.parse_and_eval("str").format_string()) 0x404000 "alpha" (gdb) py print(gdb.parse_and_eval("str").format_string(address=False)) "alpha" gdb/ChangeLog: 2020-12-18 Hannes Domani <ssbssa@yahoo.de> * python/py-value.c (valpy_format_string): Implement address keyword. gdb/doc/ChangeLog: 2020-12-18 Hannes Domani <ssbssa@yahoo.de> * python.texi (Values From Inferior): Document the address keyword. gdb/testsuite/ChangeLog: 2020-12-18 Hannes Domani <ssbssa@yahoo.de> * gdb.python/py-format-string.exp: Add tests for address keyword.
2020-12-17gdb/doc: fix "show check range" command nameSimon Marchi2-1/+7
gdb/doc/ChangeLog: PR gdb/27088 * gdb.texinfo (Range Checking): Fix "show check range" command name. Change-Id: I0248ef76d205ac49ed71b813aafe3e630c2ffc2e
2020-12-13gdb: new command 'maint flush dcache'Andrew Burgess2-0/+11
Add a new command to flush the dcache. gdb/ChangeLog: * NEWS: Mention new commands. * target-dcache.c: Add 'cli/cli-cmds.h' include. (maint_flush_dcache_command): New function. (_initialize_target_dcache): Create new 'maint flush dcache' command. gdb/doc/ChangeLog: * gdb.texinfo (Caching Target Data): Document 'maint flush dcache'. gdb/testsuite/ChangeLog: * gdb.base/dcache-flush.c: New file. * gdb.base/dcache-flush.exp: New file.
2020-12-13gdb: introduce new 'maint flush ' prefix commandAndrew Burgess2-6/+21
We currently have two flushing commands 'flushregs' and 'maint flush-symbol-cache'. I'm planning to add at least one more so I thought it might be nice if we bundled these together into one place. And so I created the 'maint flush ' command prefix. Currently there are two commands: (gdb) maint flush symbol-cache (gdb) maint flush register-cache Unfortunately, even though both of the existing flush commands are maintenance commands, I don't know how keen we about deleting existing commands for fear of breaking things in the wild. So, both of the existing flush commands 'maint flush-symbol-cache' and 'flushregs' are still around as deprecated aliases to the new commands. I've updated the testsuite to use the new command syntax, and updated the documentation too. gdb/ChangeLog: * NEWS: Mention new commands, and that the old commands are now deprecated. * cli/cli-cmds.c (maintenanceflushlist): Define. * cli/cli-cmds.h (maintenanceflushlist): Declare. * maint.c (_initialize_maint_cmds): Initialise maintenanceflushlist. * regcache.c: Add 'cli/cli-cmds.h' include. (reg_flush_command): Add header comment. (_initialize_regcache): Create new 'maint flush register-cache' command, make 'flushregs' an alias. * symtab.c: Add 'cli/cli-cmds.h' include. (_initialize_symtab): Create new 'maint flush symbol-cache' command, make old command an alias. gdb/doc/ChangeLog: * gdb.texinfo (Symbols): Document 'maint flush symbol-cache'. (Maintenance Commands): Document 'maint flush register-cache'. gdb/testsuite/ChangeLog: * gdb.base/c-linkage-name.exp: Update to use new 'maint flush ...' commands. * gdb.base/killed-outside.exp: Likewise. * gdb.opt/inline-bt.exp: Likewise. * gdb.perf/gmonster-null-lookup.py: Likewise. * gdb.perf/gmonster-print-cerr.py: Likewise. * gdb.perf/gmonster-ptype-string.py: Likewise. * gdb.python/py-unwind.exp: Likewise.
2020-12-04Fix building gdb release from tar file without makeinfoBernd Edlinger2-4/+8
Add GDBvn.texi and version.subst to the release tar file, so the gdb.info does not need makeinfo. This avoids the need for makeinfo to be available. 2020-12-04 Bernd Edlinger <bernd.edlinger@hotmail.de> * Makefile.in: Delete GDBvn.texi and version.subst only in the maintainer-clean target.
2020-11-29Fix Value.format_string docu for static members argumentHannes Domani2-1/+6
The argument is called static_members, not static_fields. gdb/doc/ChangeLog: 2020-11-29 Hannes Domani <ssbssa@yahoo.de> PR python/26974 * python.texi: Fix docu for static members argument.
2020-11-19gdb/fortran: Add support for Fortran array slices at the GDB promptAndrew Burgess2-0/+39
This commit brings array slice support to GDB. WARNING: This patch contains a rather big hack which is limited to Fortran arrays, this can be seen in gdbtypes.c and f-lang.c. More details on this below. This patch rewrites two areas of GDB's Fortran support, the code to extract an array slice, and the code to print an array. After this commit a user can, from the GDB prompt, ask for a slice of a Fortran array and should get the correct result back. Slices can (optionally) have the lower bound, upper bound, and a stride specified. Slices can also have a negative stride. Fortran has the concept of repacking array slices. Within a compiled Fortran program if a user passes a non-contiguous array slice to a function then the compiler may have to repack the slice, this involves copying the elements of the slice to a new area of memory before the call, and copying the elements back to the original array after the call. Whether repacking occurs will depend on which version of Fortran is being used, and what type of function is being called. This commit adds support for both packed, and unpacked array slicing, with the default being unpacked. With an unpacked array slice, when the user asks for a slice of an array GDB creates a new type that accurately describes where the elements of the slice can be found within the original array, a value of this type is then returned to the user. The address of an element within the slice will be equal to the address of an element within the original array. A user can choose to select packed array slices instead using: (gdb) set fortran repack-array-slices on|off (gdb) show fortran repack-array-slices With packed array slices GDB creates a new type that reflects how the elements of the slice would look if they were laid out in contiguous memory, allocates a value of this type, and then fetches the elements from the original array and places then into the contents buffer of the new value. One benefit of using packed slices over unpacked slices is the memory usage, taking a small slice of N elements from a large array will require (in GDB) N * ELEMENT_SIZE bytes of memory, while an unpacked array will also include all of the "padding" between the non-contiguous elements. There are new tests added that highlight this difference. There is also a new debugging flag added with this commit that introduces these commands: (gdb) set debug fortran-array-slicing on|off (gdb) show debug fortran-array-slicing This prints information about how the array slices are being built. As both the repacking, and the array printing requires GDB to walk through a multi-dimensional Fortran array visiting each element, this commit adds the file f-array-walk.h, which introduces some infrastructure to support this process. This means the array printing code in f-valprint.c is significantly reduced. The only slight issue with this commit is the "rather big hack" that I mentioned above. This hack allows us to handle one specific case, array slices with negative strides. This is something that I don't believe the current GDB value contents model will allow us to correctly handle, and rather than rewrite the value contents code right now, I'm hoping to slip this hack in as a work around. The problem is that, as I see it, the current value contents model assumes that an object base address will be the lowest address within that object, and that the contents of the object start at this base address and occupy the TYPE_LENGTH bytes after that. ( We do have the embedded_offset, which is used for C++ sub-classes, such that an object can start at some offset from the content buffer, however, the assumption that the object then occupies the next TYPE_LENGTH bytes is still true within GDB. ) The problem is that Fortran arrays with a negative stride don't follow this pattern. In this case the base address of the object points to the element with the highest address, the contents of the array then start at some offset _before_ the base address, and proceed for one element _past_ the base address. As the stride for such an array would be negative then, in theory the TYPE_LENGTH for this type would also be negative. However, in many places a value in GDB will degrade to a pointer + length, and the length almost always comes from the TYPE_LENGTH. It is my belief that in order to correctly model this case the value content handling of GDB will need to be reworked to split apart the value's content buffer (which is a block of memory with a length), and the object's in memory base address and length, which could be negative. Things are further complicated because arrays with negative strides like this are always dynamic types. When a value has a dynamic type and its base address needs resolving we actually store the address of the object within the resolved dynamic type, not within the value object itself. In short I don't currently see an easy path to cleanly support this situation within GDB. And so I believe that leaves two options, either add a work around, or catch cases where the user tries to make use of a negative stride, or access an array with a negative stride, and throw an error. This patch currently goes with adding a work around, which is that when we resolve a dynamic Fortran array type, if the stride is negative, then we adjust the base address to point to the lowest address required by the array. The printing and slicing code is aware of this adjustment and will correctly slice and print Fortran arrays. Where this hack will show through to the user is if they ask for the address of an array in their program with a negative array stride, the address they get from GDB will not match the address that would be computed within the Fortran program. gdb/ChangeLog: * Makefile.in (HFILES_NO_SRCDIR): Add f-array-walker.h. * NEWS: Mention new options. * f-array-walker.h: New file. * f-lang.c: Include 'gdbcmd.h' and 'f-array-walker.h'. (repack_array_slices): New static global. (show_repack_array_slices): New function. (fortran_array_slicing_debug): New static global. (show_fortran_array_slicing_debug): New function. (value_f90_subarray): Delete. (skip_undetermined_arglist): Delete. (class fortran_array_repacker_base_impl): New class. (class fortran_lazy_array_repacker_impl): New class. (class fortran_array_repacker_impl): New class. (fortran_value_subarray): Complete rewrite. (set_fortran_list): New static global. (show_fortran_list): Likewise. (_initialize_f_language): Register new commands. (fortran_adjust_dynamic_array_base_address_hack): New function. * f-lang.h (fortran_adjust_dynamic_array_base_address_hack): Declare. * f-valprint.c: Include 'f-array-walker.h'. (class fortran_array_printer_impl): New class. (f77_print_array_1): Delete. (f77_print_array): Delete. (fortran_print_array): New. (f_value_print_inner): Update to call fortran_print_array. * gdbtypes.c: Include 'f-lang.h'. (resolve_dynamic_type_internal): Call fortran_adjust_dynamic_array_base_address_hack. gdb/testsuite/ChangeLog: * gdb.fortran/array-slices-bad.exp: New file. * gdb.fortran/array-slices-bad.f90: New file. * gdb.fortran/array-slices-sub-slices.exp: New file. * gdb.fortran/array-slices-sub-slices.f90: New file. * gdb.fortran/array-slices.exp: Rewrite tests. * gdb.fortran/array-slices.f90: Rewrite tests. * gdb.fortran/vla-sizeof.exp: Correct expected results. gdb/doc/ChangeLog: * gdb.texinfo (Debugging Output): Document 'set/show debug fortran-array-slicing'. (Special Fortran Commands): Document 'set/show fortran repack-array-slices'.
2020-11-12gdb: add an option flag to 'maint print c-tdesc'Andrew Burgess2-2/+12
GDB has two approaches to generating the target descriptions found in gdb/features/, the whole description approach, where the XML file contains a complete target description which is then used to generate a single C file that builds that target description. Or, the split feature approach, where the XML files contain a single target feature, each feature results in a single C file to create that one feature, and then a manually written C file is used to build a complete target description from individual features. There's a Makefile, gdb/features/Makefile, which is responsible for managing the regeneration of the C files from the XML files. However, some of the logic that selects between the whole description approach, or the split feature approach, is actually hard-coded into GDB, inside target-descriptions.c:maint_print_c_tdesc_cmd we check the path to the incoming XML file and use this to choose which type of C file we should generate. This commit removes this hard coding from GDB, and makes the Makefile entirely responsible for choosing the approach. This makes sense as the Makefile already has the XML files partitioned based on which approach they should use. In order to allow this change the 'maint print c-tdesc' command is given a new command option '-single-feature', which tells GDB which type of C file should be created. The makefile now supplies this flag to GDB. This did reveal a bug in features/Makefile, the rx.xml file was in the wrong list, this didn't matter previously as the actual choice of which approach to use was done in GDB. Now the Makefile decides, so placing each XML file in the correct list is critical. Tested this by doing 'make GDB=/path/to/gdb clean-cfiles cfiles' to regenerate all the C files from their XML source. There are no changes after this commit. gdb/ChangeLog: * features/Makefile (XMLTOC): Add rx.xml. (FEATURE_XMLFILES): Remove rx.xml. (FEATURE_CFILES rule): Pass '-single-feature' flag. * features/rx.c: Regenerate. * features/rx.xml: Wrap in `target` tags, and reindent. * target-descriptions.c (struct maint_print_c_tdesc_options): New structure. (maint_print_c_tdesc_opt_def): New typedef. (maint_print_c_tdesc_opt_defs): New static global. (make_maint_print_c_tdesc_options_def_group): New function. (maint_print_c_tdesc_cmd): Make use of command line flags, only print single feature C file for target descriptions containing a single feature. (maint_print_c_tdesc_cmd_completer): New function. (_initialize_target_descriptions): Update call to register command completer, and include command line flag in help text. gdb/doc/ChangeLog: * gdb.texinfo (Maintenance Commands): Update description of 'maint print c-tdesc'.
2020-11-02gdb: use get_standard_config_dir when looking for .gdbinitAndrew Burgess2-76/+140
This commit effectively changes the default location of the .gdbinit file, while maintaining backward compatibility. For non Apple hosts the .gdbinit file will now be looked for in the following locations: $XDG_CONFIG_HOME/gdb/gdbinit $HOME/.config/gdb/gdbinit $HOME/.gdbinit On Apple hosts the search order is instead: $HOME/Library/Preferences/gdb/gdbinit $HOME/.gdbinit I've performed an extensive rewrite of the documentation, moving all information about initialization files and where to find them into a new @node, text from other areas has been moved into this one location, and other areas cross-reference to this new @node as much as possible. gdb/ChangeLog: * NEWS: Mention changes to config file search path. * main.c gdb/doc/ChangeLog: * gdb.texinfo (Mode Options): Descriptions of initialization files has been moved to 'Initialization Files'. (Startup): Likewise. (Initialization Files): New node. (gdb man): Update to mention alternative file paths. (gdbinit man): Likewise.
2020-10-27gdb/breakpoint: add flags to 'condition' and 'break' commands to force conditionTankut Baris Aktemur2-0/+37
The previous patch made it possible to define a condition if it's valid at some locations. If the condition is invalid at all of the locations, it's rejected. However, there may be cases where the user knows the condition *will* be valid at a location in the future, e.g. due to a shared library load. To make it possible that such condition can be defined, this patch adds an optional '-force' flag to the 'condition' command, and, respectively, a '-force-condition' flag to the 'break'command. When the force flag is passed, the condition is not rejected even when it is invalid for all the current locations (note that all the locations would be internally disabled in this case). For instance: (gdb) break test.c:5 Breakpoint 1 at 0x1155: file test.c, line 5. (gdb) cond 1 foo == 42 No symbol "foo" in current context. Defining the condition was not possible because 'foo' is not available. The user can override this behavior with the '-force' flag: (gdb) cond -force 1 foo == 42 warning: failed to validate condition at location 1.1, disabling: No symbol "foo" in current context. (gdb) info breakpoints Num Type Disp Enb Address What 1 breakpoint keep y <MULTIPLE> stop only if foo == 42 1.1 N 0x0000000000001155 in main at test.c:5 Now the condition is accepted, but the location is automatically disabled. If a future location has a context in which 'foo' is available, that location would be enabled. For the 'break' command, -force-condition has the same result: (gdb) break test.c:5 -force-condition if foo == 42 warning: failed to validate condition at location 0x1169, disabling: No symbol "foo" in current context. Breakpoint 1 at 0x1169: file test.c, line 5. gdb/ChangeLog: 2020-10-27 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * breakpoint.h (set_breakpoint_condition): Add a new bool parameter. * breakpoint.c: Update the help text of the 'condition' and 'break' commands. (set_breakpoint_condition): Take a new bool parameter to control whether condition definition should be forced even when the condition expression is invalid in all of the current locations. (condition_command): Update the call to 'set_breakpoint_condition'. (find_condition_and_thread): Take the "-force-condition" flag into account. * linespec.c (linespec_keywords): Add "-force-condition" as an element. (FORCE_KEYWORD_INDEX): New #define. (linespec_lexer_lex_keyword): Update to consider "-force-condition" as a keyword. * ada-lang.c (create_ada_exception_catchpoint): Ditto. * guile/scm-breakpoint.c (gdbscm_set_breakpoint_condition_x): Ditto. * python/py-breakpoint.c (bppy_set_condition): Ditto. * NEWS: Mention the changes to the 'break' and 'condition' commands. gdb/testsuite/ChangeLog: 2020-10-27 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * gdb.base/condbreak-multi-context.exp: Expand to test forcing the condition. * gdb.linespec/cpcompletion.exp: Update to consider the '-force-condition' keyword. * gdb.linespec/explicit.exp: Ditto. * lib/completion-support.exp: Ditto. gdb/doc/ChangeLog: 2020-10-27 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * gdb.texinfo (Set Breaks): Document the '-force-condition' flag of the 'break'command. * gdb.texinfo (Conditions): Document the '-force' flag of the 'condition' command.
2020-10-27gdb/breakpoint: disable a bp location if condition is invalid at that locationTankut Baris Aktemur2-0/+45
Currently, for a conditional breakpoint, GDB checks if the condition can be evaluated in the context of the first symtab and line (SAL). In case of an error, defining the conditional breakpoint is aborted. This prevents having a conditional breakpoint whose condition may actually be meaningful for some of the location contexts. This patch makes it possible to define conditional BPs by checking all location contexts. If the condition is meaningful for even one context, the breakpoint is defined. The locations for which the condition gives errors are disabled. The bp_location struct is introduced a new field, 'disabled_by_cond'. This field denotes whether the location is disabled automatically because the condition was non-evaluatable. Disabled-by-cond locations cannot be enabled by the user. But locations that are not disabled-by-cond can be enabled/disabled by the user manually as before. For a concrete example, consider 3 contexts of a function 'func'. class Base { public: int b = 20; void func () {} }; class A : public Base { public: int a = 10; void func () {} }; class C : public Base { public: int c = 30; void func () {} }; Note that * the variable 'a' is defined only in the context of A::func. * the variable 'c' is defined only in the context of C::func. * the variable 'b' is defined in all the three contexts. With the existing GDB, it's not possible to define a conditional breakpoint at 'func' if the condition refers to 'a' or 'c': (gdb) break func if a == 10 No symbol "a" in current context. (gdb) break func if c == 30 No symbol "c" in current context. (gdb) info breakpoints No breakpoints or watchpoints. With this patch, it becomes possible: (gdb) break func if a == 10 warning: failed to validate condition at location 1, disabling: No symbol "a" in current context. warning: failed to validate condition at location 3, disabling: No symbol "a" in current context. Breakpoint 1 at 0x11b6: func. (3 locations) (gdb) break func if c == 30 Note: breakpoint 1 also set at pc 0x11ce. Note: breakpoint 1 also set at pc 0x11c2. Note: breakpoint 1 also set at pc 0x11b6. warning: failed to validate condition at location 1, disabling: No symbol "c" in current context. warning: failed to validate condition at location 2, disabling: No symbol "c" in current context. Breakpoint 2 at 0x11b6: func. (3 locations) (gdb) info breakpoints Num Type Disp Enb Address What 1 breakpoint keep y <MULTIPLE> stop only if a == 10 1.1 N* 0x00000000000011b6 in Base::func() at condbreak-multi-context.cc:23 1.2 y 0x00000000000011c2 in A::func() at condbreak-multi-context.cc:31 1.3 N* 0x00000000000011ce in C::func() at condbreak-multi-context.cc:39 2 breakpoint keep y <MULTIPLE> stop only if c == 30 2.1 N* 0x00000000000011b6 in Base::func() at condbreak-multi-context.cc:23 2.2 N* 0x00000000000011c2 in A::func() at condbreak-multi-context.cc:31 2.3 y 0x00000000000011ce in C::func() at condbreak-multi-context.cc:39 (*): Breakpoint condition is invalid at this location. Here, uppercase 'N' denotes that the location is disabled because of the invalid condition, as mentioned with a footnote in the legend of the table. Locations that are disabled by the user are still denoted with lowercase 'n'. Executing the code hits the breakpoints 1.2 and 2.3 as expected. Defining a condition on an unconditional breakpoint gives the same behavior above: (gdb) break func Breakpoint 1 at 0x11b6: func. (3 locations) (gdb) cond 1 a == 10 warning: failed to validate condition at location 1.1, disabling: No symbol "a" in current context. warning: failed to validate condition at location 1.3, disabling: No symbol "a" in current context. (gdb) info breakpoints Num Type Disp Enb Address What 1 breakpoint keep y <MULTIPLE> stop only if a == 10 1.1 N* 0x00000000000011b6 in Base::func() at condbreak-multi-context.cc:23 1.2 y 0x00000000000011c2 in A::func() at condbreak-multi-context.cc:31 1.3 N* 0x00000000000011ce in C::func() at condbreak-multi-context.cc:39 (*): Breakpoint condition is invalid at this location. Locations that are disabled because of a condition cannot be enabled by the user: ... (gdb) enable 1.1 Breakpoint 1's condition is invalid at location 1, cannot enable. Resetting the condition enables the locations back: ... (gdb) cond 1 Breakpoint 1's condition is now valid at location 1, enabling. Breakpoint 1's condition is now valid at location 3, enabling. Breakpoint 1 now unconditional. (gdb) info breakpoints Num Type Disp Enb Address What 1 breakpoint keep y <MULTIPLE> 1.1 y 0x00000000000011b6 in Base::func() at condbreak-multi-context.cc:23 1.2 y 0x00000000000011c2 in A::func() at condbreak-multi-context.cc:31 1.3 y 0x00000000000011ce in C::func() at condbreak-multi-context.cc:39 If a location is disabled by the user, a condition can still be defined but the location will remain disabled even if the condition is meaningful for the disabled location: ... (gdb) disable 1.2 (gdb) cond 1 a == 10 warning: failed to validate condition at location 1.1, disabling: No symbol "a" in current context. warning: failed to validate condition at location 1.3, disabling: No symbol "a" in current context. (gdb) info breakpoints Num Type Disp Enb Address What 1 breakpoint keep y <MULTIPLE> stop only if a == 10 1.1 N* 0x00000000000011b6 in Base::func() at condbreak-multi-context.cc:23 1.2 n 0x00000000000011c2 in A::func() at condbreak-multi-context.cc:31 1.3 N* 0x00000000000011ce in C::func() at condbreak-multi-context.cc:39 (*): Breakpoint condition is invalid at this location. The condition of a breakpoint can be changed. Locations' enable/disable states are updated accordingly. ... (gdb) cond 1 c == 30 warning: failed to validate condition at location 1.1, disabling: No symbol "c" in current context. Breakpoint 1's condition is now valid at location 3, enabling. (gdb) info breakpoints Num Type Disp Enb Address What 1 breakpoint keep y <MULTIPLE> stop only if c == 30 1.1 N* 0x00000000000011b6 in Base::func() at condbreak-multi-context.cc:23 1.2 N* 0x00000000000011c2 in A::func() at condbreak-multi-context.cc:31 1.3 y 0x00000000000011ce in C::func() at condbreak-multi-context.cc:39 (*): Breakpoint condition is invalid at this location. (gdb) cond 1 b == 20 Breakpoint 1's condition is now valid at location 1, enabling. (gdb) info breakpoints Num Type Disp Enb Address What 1 breakpoint keep y <MULTIPLE> stop only if b == 20 1.1 y 0x00000000000011b6 in Base::func() at condbreak-multi-context.cc:23 1.2 n 0x00000000000011c2 in A::func() at condbreak-multi-context.cc:31 1.3 y 0x00000000000011ce in C::func() at condbreak-multi-context.cc:39 # Note that location 1.2 was disabled by the user previously. If the condition expression is bad for all the locations, it will be rejected. (gdb) cond 1 garbage No symbol "garbage" in current context. For conditions that are invalid or valid for all the locations of a breakpoint, the existing behavior is preserved. Regression-tested on X86_64 Linux. gdb/ChangeLog: 2020-10-27 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * breakpoint.h (class bp_location) <disabled_by_cond>: New field. * breakpoint.c (set_breakpoint_location_condition): New function. (set_breakpoint_condition): Disable a breakpoint location if parsing the condition string gives an error. (should_be_inserted): Update to consider the 'disabled_by_cond' field. (build_target_condition_list): Ditto. (build_target_command_list): Ditto. (build_bpstat_chain): Ditto. (print_one_breakpoint_location): Ditto. (print_one_breakpoint): Ditto. (breakpoint_1): Ditto. (bp_location::bp_location): Ditto. (locations_are_equal): Ditto. (update_breakpoint_locations): Ditto. (enable_disable_bp_num_loc): Ditto. (init_breakpoint_sal): Use set_breakpoint_location_condition. (find_condition_and_thread_for_sals): New static function. (create_breakpoint): Call find_condition_and_thread_for_sals. (location_to_sals): Call find_condition_and_thread_for_sals instead of find_condition_and_thread. gdb/testsuite/ChangeLog: 2020-10-27 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * gdb.base/condbreak-multi-context.cc: New file. * gdb.base/condbreak-multi-context.exp: New file. gdb/doc/ChangeLog: 2020-10-27 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * gdb.texinfo (Set Breaks): Document disabling of breakpoint locations for which the breakpoint condition is invalid.
2020-10-06gdb: Fix installation of gcore.1 on some platformsMichael Forney2-0/+6
gcore is installed on NetBSD, FreeBSD, Solaris (HAVE_NATIVE_GCORE_HOST=1) and Linux (HAVE_NATIVE_GCORE_TARGET=1). However, even though gcore.1 is installed conditional on those variables, HAVE_NATIVE_GCORE_HOST was missing from gdb/doc/Makefile.in, so manual installation was skipped on NetBSD, FreeBSD, and Solaris. gdb/doc/ChangeLog: 2020-10-06 Michael Forney <mforney@mforney.org> * Makefile.in (HAVE_NATIVE_GCORE_HOST): Add for gcore.1 install condition. Change-Id: I17c3ce2ecdfb806ece17f05ba78356b25ffa865e
2020-10-04gdb: add doc for "set/show debug event-loop"Simon Marchi2-0/+14
I forgot that "set/show debug" commands are listed in the doc and in NEWS, so here they are. gdb/doc/ChangeLog: * gdb.texinfo (Debugging Output): Add set/show debug event-loop. gdb/ChangeLog: * NEWS: Mention set/show debug event-loop. Change-Id: If30b80177049006578280a06912ee2b97bd03a75
2020-10-04gdb/doc: space out list entries, fix one typeSimon Marchi2-1/+39
I want to add an item to this list, but it's so packed I have trouble finding where one item ends and the next starts. Add a few empty lines to make it a bit more readable. Doing this, I also noticed that an "aix-thread" should in fact be "aix-solib". gdb/doc/ChangeLog: * gdb.texinfo (Debugging Output): Add empty lines, fix typo. Change-Id: I7ef211f9e3988cfbc6ec94124d23a5f2412f3c82
2020-09-13Add MI "-break-insert --qualified"Pedro Alves2-4/+13
Currently -break-insert always creates a wildmatching breakpoint, and there's no way to ask for a fullname match. To address that, this patch adds the equivalent of "break -qualified" to MI: "-break-insert --qualified". For the testcase, curiously, it doesn't look like we have _any_ testcase that tests a breakpoint with multiple locations, and, the existing mi_create_breakpoint / mi_make_breakpoint procedures are only good for breakpoints with a single location. This patch thus adds a few new companion routines to mi-support.exp for breakpoints with multiple locations: mi_create_breakpoint_multi, mi_make_breakpoint_loc, mi_make_breakpoint_multi. gdb/ChangeLog: * NEWS: Document "-break-insert --qualified". * mi/mi-cmd-break.c (mi_cmd_break_insert_1): Handle "--qualified". gdb/doc/ChangeLog: * gdb.texinfo (GDB/MI Breakpoint Commands): Document "-break-insert --qualified" and "-dprintf-insert --qualified". gdb/testsuite/ChangeLog: * gdb.mi/mi-break-qualified.cc: New file. * gdb.mi/mi-break-qualified.exp: New file. * lib/mi-support.exp (mi_create_breakpoint_multi) (mi_make_breakpoint_loc, mi_make_breakpoint_multi): New procedures. (mi_create_breakpoint_1): New, factored out from mi_create_breakpoint.
2020-08-25arc: Add hardware loop detectionShahab Vahedi2-2/+13
For ARC there are registers that are not part of a required set in XML target descriptions by default, but are almost always present on ARC targets and are universally exposed by the ptrace interface. Hardware loop registers being one of them. LP_START and LP_END auxiliary registers are hardware loop start and end. Formally, they are optional, but it is hard to find an ARC configuration that doesn't have them. They are always present in processors that can run GNU/Linux. GDB needs to know about those registers to implement proper software single stepping, since they affect what instruction will be next. This commit adds the code to check for the existance of "lp_start" and "lp_end" in XML target descriptions. If they exist, then the function reports that the target supports hardware loops. gdb/ChangeLog: * arc-tdep.c (arc_check_for_hardware_loop): New. * arc-tdep.h (gdbarch_tdep): New field has_hw_loops. gdb/doc/ChangeLog: * gdb.texinfo (Synopsys ARC): Document LP_START, LP_END and BTA.
2020-08-25arc: Add ARCv2 XML target along with refactoringShahab Vahedi2-34/+40
A few changes have been made to make the register support simpler, more flexible and extendible. The trigger for most of these changes are the remarks [1] made earlier for v2 of this patch. The noticeable improvements are: - The arc XML target features are placed under gdb/features/arc - There are two cores (based on ISA) and one auxiliary feature: v1-core: ARC600, ARC601, ARC700 v2-core: ARC EM, ARC HS aux: common in both - The XML target features represent a minimalistic sane set of registers irrespective of application (baremetal or linux). - A concept of "feature" class has been introduced in the code. The "feature" object is constructed from BFD and GDBARCH data. It contains necessary information (ISA and register size) to determine which XML target feature to use. - A new structure (ARC_REGISTER_FEATURE) is added that allows providing index, names, and the necessity of registers. This simplifies the sanity checks and future extendibility. - Documnetation has been updated to reflect ARC features better. - Although the feature names has changed, there still exists backward compatibility with older names through find_obsolete_[core,aux]_names() functions. The last two points were inspired from RiscV port. [1] https://sourceware.org/pipermail/gdb-patches/2020-May/168511.html gdb/ChangeLog: * arch/arc.h (arc_gdbarch_features): New class to stir the selection of target XML. (arc_create_target_description): Use FEATURES to choose XML target. (arc_lookup_target_description): Use arc_create_target_description to create _new_ target descriptions or return the already created ones if the FEATURES is the same. * arch/arc.c: Implementation of prototypes described above. * gdb/arc-tdep.h (arc_regnum enum): Add more registers. (arc_gdbarch_features_init): Initialize the FEATURES struct. * arc-tdep.c (*_feature_name): Make feature names consistent. (arc_register_feature): A new struct to hold information about registers of a particular target/feature. (arc_check_tdesc_feature): Check if XML provides registers in compliance with ARC_REGISTER_FEATURE structs. (arc_update_acc_reg_names): Add aliases for r58 and r59. (determine_*_reg_feature_set): Which feature name to look for. (arc_gdbarch_features_init): Given MACH and ABFD, initialize FEATURES. (mach_type_to_arc_isa): Convert from a set of binutils machine types to expected ISA enums to be used in arc_gdbarch_features structs. * features/Makefile (FEATURE_XMLFILES): Add new files. * gdb/features/arc/v1-aux.c: New file. * gdb/features/arc/v1-aux.xml: Likewise. * gdb/features/arc/v1-core.c: Likewise. * gdb/features/arc/v1-core.xml: Likewise. * gdb/features/arc/v2-aux.c: Likewise. * gdb/features/arc/v2-aux.xml: Likewise. * gdb/features/arc/v2-core.c: Likewise. * gdb/features/arc/v2-core.xml: Likewise. * NEWS (Changes since GDB 9): Announce obsolence of old feature names. gdb/doc/ChangeLog: * gdb.texinfo (Synopsys ARC): Update the documentation for ARC Features. gdb/testsuite/ChangeLog: * gdb.arch/arc-tdesc-cpu.xml: Use new feature names.
2020-08-07Update Ravenscar documentationTom Tromey2-0/+33
This documents some recent Ravenscar changes, and further documents the known limitation where stepping through the runtime initialization code does not work properly. gdb/doc/ChangeLog 2020-08-07 Tom Tromey <tromey@adacore.com> * gdb.texinfo (Ravenscar Profile): Add examples. Document runtime initialization limitation.
2020-08-04gdb: support for eBPFJose E. Marchesi2-0/+27
This patch adds basic support for the eBPF target: tdep and build machinery. The accompanying simulator is introduced in subsequent patches. gdb/ChangeLog: 2020-08-04 Weimin Pan <weimin.pan@oracle.com> Jose E. Marchesi <jose.marchesi@oracle.com> * configure.tgt: Add entry for bpf-*-*. * Makefile.in (ALL_TARGET_OBS): Add bpf-tdep.o (ALLDEPFILES): Add bpf-tdep.c. * bpf-tdep.c: New file. * MAINTAINERS: Add bpf target and maintainer. gdb/doc/ChangeLog: 2020-08-04 Jose E. Marchesi <jose.marchesi@oracle.com> * gdb.texinfo (Contributors): Add information for the eBPF support. (BPF): New section.
2020-07-28gdb/python: make more use of RegisterDescriptorsAndrew Burgess2-12/+37
This commit unifies all of the Python register lookup code (used by Frame.read_register, PendingFrame.read_register, and gdb.UnwindInfo.add_saved_register), and adds support for using a gdb.RegisterDescriptor for register lookup. Currently the register unwind code (PendingFrame and UnwindInfo) allow registers to be looked up either by name, or by GDB's internal number. I suspect the number was added for performance reasons, when unwinding we don't want to repeatedly map from name to number for every unwind. However, this kind-of sucks, it means Python scripts could include GDB's internal register numbers, and if we ever change this numbering in the future users scripts will break in unexpected ways. Meanwhile, the Frame.read_register method only supports accessing registers using a string, the register name. This commit unifies all of the register to register-number lookup code in our Python bindings, and adds a third choice into the mix, the use of gdb.RegisterDescriptor. The register descriptors can be looked up by name, but once looked up, they contain GDB's register number, and so provide all of the performance benefits of using a register number directly. However, as they are looked up by name we are no longer tightly binding the Python API to GDB's internal numbering scheme. As we may already have scripts in the wild that are using the register numbers directly I have kept support for this in the API, but I have listed this method last in the manual, and I have tried to stress that this is NOT a good method to use and that users should use either a string or register descriptor approach. After this commit all existing Python code should function as before, but users now have new options for how to identify registers. gdb/ChangeLog: * python/py-frame.c: Remove 'user-regs.h' include. (frapy_read_register): Rewrite to make use of gdbpy_parse_register_id. * python/py-registers.c (gdbpy_parse_register_id): New function, moved here from python/py-unwind.c. Updated the return type, and also accepts register descriptor objects. * python/py-unwind.c: Remove 'user-regs.h' include. (pyuw_parse_register_id): Moved to python/py-registers.c. (unwind_infopy_add_saved_register): Update to use gdbpy_parse_register_id. (pending_framepy_read_register): Likewise. * python/python-internal.h (gdbpy_parse_register_id): Declare. gdb/testsuite/ChangeLog: * gdb.python/py-unwind.py: Update to make use of a register descriptor. gdb/doc/ChangeLog: * python.texi (Unwinding Frames in Python): Update descriptions for PendingFrame.read_register and gdb.UnwindInfo.add_saved_register. (Frames In Python): Update description of Frame.read_register.
2020-07-28gdb: Add a find method for RegisterDescriptorIteratorAndrew Burgess2-0/+13
Adds a new method 'find' to the gdb.RegisterDescriptorIterator class, this allows gdb.RegisterDescriptor objects to be looked up directly by register name rather than having to iterate over all registers. This will be of use for a later commit. I've documented the new function in the manual, but I don't think a NEWS entry is required here, as, since the last release, the whole register descriptor mechanism is new, and is already mentioned in the NEWS file. gdb/ChangeLog: * python/py-registers.c: Add 'user-regs.h' include. (register_descriptor_iter_find): New function. (register_descriptor_iterator_object_methods): New static global methods array. (register_descriptor_iterator_object_type): Add pointer to methods array. gdb/testsuite/ChangeLog: * gdb.python/py-arch-reg-names.exp: Add additional tests. gdb/doc/ChangeLog: * python.texi (Registers In Python): Document new find function.
2020-07-22Add documentation for "maint print core-file-backed-mappings"Kevin Buettner2-0/+13
gdb/ChangeLog: * NEWS (New commands): Mention new command "maintenance print core-file-backed-mappings". gdb/doc/ChangeLog: * gdb.texinfo (Maintenance Commands): Add documentation for new command "maintenance print core-file-backed-mappings".
2020-07-22Correct an error in the remote protocol specificationReuben Thomas2-4/+13
The list of commands that a stub must implement was wrong. gdb/ChangeLog: 2020-07-22 Reuben Thomas <rrt@sc3d.org> * gdb.texinfo (Remote Protocol, Overview): Correct the description of which remote protocol commands are mandatory for a stub to implement.
2020-07-20guile: Add support for Guile 3.0.Ludovic Courtès2-1/+5
gdb/ChangeLog 2020-06-28 Ludovic Courtès <ludo@gnu.org> * guile/scm-math.c (vlscm_integer_fits_p): Use 'uintmax_t' and 'intmax_t' instead of 'scm_t_uintmax' and 'scm_t_intmax', which are deprecated in Guile 3.0. * configure.ac (try_guile_versions): Add "guile-3.0". * configure (try_guile_versions): Regenerate. * NEWS: Update entry. gdb/testsuite/ChangeLog 2020-06-28 Ludovic Courtès <ludo@gnu.org> * gdb.guile/source2.scm: Add #f first argument to 'format'. * gdb.guile/types-module.exp: Remove "ERROR:" from regexps since Guile 3.0 no longer prints that. gdb/doc/ChangeLog 2020-06-28 Ludovic Courtès <ludo@gnu.org> * doc/guile.texi (Guile Introduction): Mention Guile 3.0. Change-Id: Iff116c2e40f334e4e0ca4e759a097bfd23634679
2020-07-20guile: Add support for Guile 2.2.Ludovic Courtès2-2/+26
This primarily updates code that uses the I/O port API of Guile. gdb/ChangeLog 2020-06-28 Ludovic Courtès <ludo@gnu.org> Doug Evans <dje@google.com> PR gdb/21104 * guile/scm-ports.c (USING_GUILE_BEFORE_2_2): New macro. (ioscm_memory_port)[read_buf_size, write_buf_size]: Wrap in #if USING_GUILE_BEFORE_2_2. (stdio_port_desc, memory_port_desc) [!USING_GUILE_BEFORE_2_2]: Change type to 'scm_t_port_type *'. (natural_buffer_size) [!USING_GUILE_BEFORE_2_2]: New variable. (ioscm_open_port) [USING_GUILE_BEFORE_2_2]: Add 'stream' parameter and honor it. Update callers. (ioscm_open_port) [!USING_GUILE_BEFORE_2_2]: New function. (ioscm_read_from_port, ioscm_write) [!USING_GUILE_BEFORE_2_2]: New functions. (ioscm_fill_input, ioscm_input_waiting, ioscm_flush): Wrap in #if USING_GUILE_BEFORE_2_2. (ioscm_init_gdb_stdio_port) [!USING_GUILE_BEFORE_2_2]: Use 'ioscm_read_from_port'. Call 'scm_set_port_read_wait_fd'. (ioscm_init_stdio_buffers) [!USING_GUILE_BEFORE_2_2]: New function. (gdbscm_stdio_port_p) [!USING_GUILE_BEFORE_2_2]: Use 'SCM_PORTP' and 'SCM_PORT_TYPE'. (gdbscm_memory_port_end_input, gdbscm_memory_port_seek) (ioscm_reinit_memory_port): Wrap in #if USING_GUILE_BEFORE_2_2. (gdbscm_memory_port_read, gdbscm_memory_port_write) (gdbscm_memory_port_seek, gdbscm_memory_port_close) [!USING_GUILE_BEFORE_2_2]: New functions. (gdbscm_memory_port_print): Remove use of 'SCM_PTOB_NAME'. (ioscm_init_memory_port_type) [!USING_GUILE_BEFORE_2_2]: Use 'gdbscm_memory_port_read'. Wrap 'scm_set_port_end_input', 'scm_set_port_flush', and 'scm_set_port_free' calls in #if USING_GUILE_BEFORE_2_2. (gdbscm_get_natural_buffer_sizes) [!USING_GUILE_BEFORE_2_2]: New function. (ioscm_init_memory_port): Remove. (ioscm_init_memory_port_stream): New function (ioscm_init_memory_port_buffers) [USING_GUILE_BEFORE_2_2]: New function. (gdbscm_memory_port_read_buffer_size) [!USING_GUILE_BEFORE_2_2]: Return scm_from_uint (0). (gdbscm_set_memory_port_read_buffer_size_x) [!USING_GUILE_BEFORE_2_2]: Call 'scm_setvbuf'. (gdbscm_memory_port_write_buffer_size) [!USING_GUILE_BEFORE_2_2]: Return scm_from_uint (0). (gdbscm_set_memory_port_write_buffer_size_x) [!USING_GUILE_BEFORE_2_2]: Call 'scm_setvbuf'. * configure.ac (try_guile_versions): Add "guile-2.2". * configure: Regenerate. * NEWS: Add entry. gdb/testsuite/ChangeLog 2020-06-28 Ludovic Courtès <ludo@gnu.org> * gdb.guile/scm-error.exp ("source $remote_guile_file_1"): Relax error regexp to match on Guile 2.2. gdb/doc/ChangeLog 2020-06-28 Ludovic Courtès <ludo@gnu.org> * guile.texi (Memory Ports in Guile): Mark 'memory-port-read-buffer-size', 'set-memory-port-read-buffer-size!', 'memory-port-write-buffer-size', 'set-memory-port-read-buffer-size!' as deprecated. * doc/guile.texi (Guile Introduction): Clarify which Guile versions are supported. Change-Id: Ib119b10a2787446e0ae482a5e1b36d809c44bb31
2020-07-13Fix frame-apply.html collision in GDB manual.Paul Carroll2-3/+9
The addition of an anchor for the "frame apply" command was causing the HTML documentation to include files named both "frame-apply.html" and "Frame-Apply.html", which collide on case-insensitive file systems. This patch removes the redundant anchor and adjusts the two xrefs to it. 2020-07-13 Paul Carroll <pcarroll@codesourcery.com> PR gdb/25716 gdb/doc/ * gdb.texinfo (Frame Apply): Remove anchor for 'frame apply' and adjust xrefs to it.
2020-07-11Fine tune exec-file-mismatch help and documentation.Philippe Waroquiers2-0/+6
It was deemed better to explicitly mention in help and doc that build IDs are used for comparison, and that symbols are loaded when asking to load the exec-file. This is V2, fixing 2 typos and replacing 'If the user asks to load' by 'If the user confirms loading', as suggested by Pedro. gdb/ChangeLog 2020-07-11 Philippe Waroquiers <philippe.waroquiers@skynet.be> * exec.c (_initialize_exec): Update exec-file-mismatch help. gdb/doc/ChangeLog 2020-07-11 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.texinfo (Attach): Update exec-file-mismatch doc.
2020-07-08Handle Windows drives in auto-load script pathsHannes Domani2-0/+9
Fixes this testsuite fail on Windows: FAIL: gdb.base/auto-load.exp: print $script_loaded Converts the debugfile path from c:/dir/file to /c/dir/file, so it can be appended to the auto-load path. gdb/ChangeLog: 2020-07-08 Hannes Domani <ssbssa@yahoo.de> * auto-load.c (auto_load_objfile_script_1): Convert drive part of debugfile path on Windows. gdb/doc/ChangeLog: 2020-07-08 Hannes Domani <ssbssa@yahoo.de> * gdb.texinfo: Document Windows drive conversion of 'set auto-load scripts-directory'.
2020-07-06gdb/python: New method to access list of register groupsAndrew Burgess3-0/+42
Add a new method gdb.Architecture.register_groups which returns a new object of type gdb.RegisterGroupsIterator. This new iterator then returns objects of type gdb.RegisterGroup. Each gdb.RegisterGroup object just wraps a single reggroup pointer, and (currently) has just one read-only property 'name' that is a string, the name of the register group. As with the previous commit (adding gdb.RegisterDescriptor) I made gdb.RegisterGroup an object rather than just a string in case we want to add additional properties in the future. gdb/ChangeLog: * NEWS: Mention additions to Python API. * python/py-arch.c (archpy_register_groups): New function. (arch_object_methods): Add 'register_groups' method. * python/py-registers.c (reggroup_iterator_object): New struct. (reggroup_object): New struct. (gdbpy_new_reggroup): New function. (gdbpy_reggroup_to_string): New function. (gdbpy_reggroup_name): New function. (gdbpy_reggroup_iter): New function. (gdbpy_reggroup_iter_next): New function. (gdbpy_new_reggroup_iterator): New function (gdbpy_initialize_registers): Register new types. (reggroup_iterator_object_type): Define new Python type. (gdbpy_reggroup_getset): New static global. (reggroup_object_type): Define new Python type. * python/python-internal.h gdb/testsuite/ChangeLog: * gdb.python/py-arch-reg-groups.exp: New file. gdb/doc/ChangeLog: * gdb.texi (Registers): Add @anchor for 'info registers <reggroup>' command. * python.texi (Architectures In Python): Document new register_groups method. (Registers In Python): Document two new object types related to register groups.