aboutsummaryrefslogtreecommitdiff
path: root/gdb/python/lib
AgeCommit message (Collapse)AuthorFilesLines
2 hoursChange DAP condition for Ada exception catchpointTom Tromey1-2/+11
Currently, the gdb DAP implementation doesn't provide a way to filter based on the thrown Ada exception. There isn't really an ideal way to handle this in DAP: * Requiring an IDE to use an expression checking $_ada_exception exposes the IDE to any workarounds needed to get this correct (see ada-lang.c). * The setExceptionBreakpoint "filterOptions" field doesn't allow a special kind of condition to be set. (We could add one but we've generally avoided gdb-specific extensions.) * The "exceptionOptions" approach is under-documented. It could be used but it would have to be in a somewhat gdb-specific way anyway -- and this approach does not allow a separate condition that is an expression. So, after some internal discussion, we agreed that it isn't all that useful to have conditions on Ada exception catchpoints. This patch changes the implementation to treat the condition as an exception name here.
5 hoursHandle optimized-out values in gdb.printing.make_visualizerTom Tromey1-2/+7
This changes gdb.printing.make_visualizer to treat an optimized-out pointer as a scalar variable -- that is, one that does not advertise any children. This makes sense because such a pointer cannot be dereferenced. The test case checks this case, plus it ensures that synthetic pointers still continue to work. Approved-By: Andrew Burgess <aburgess@redhat.com>
2025-09-04gdb/dap: check values are available before converting to intAndrew Burgess1-1/+5
In VariableReference.to_object, we try to convert a gdb.Value to an int without checking if the value is actually available. This came to light in PR gdb/33345, after the x86 CET shadow stack patches were merged. If the x86 CET shadow stack register is available on the machine, but the shadow stack feature is not enabled at run time, then the register will show as "<unavailable>". As the register is of type 'void *', then in the DAP code we try to add a 'memoryReference' attribute with the value of the register formatted as hex. This will fail if the register is unavailable. To test this change you'll need: (a) a machine which support the shadow stack feature, and (b) to revert the changes from commit 63b862be762e1e6e7 in the file gdb.dap/scopes.exp. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33345 Reviewed-By: Christina Schimpe <christina.schimpe@intel.com>
2025-08-11Emit DAPException when too many variable children are reqeustedTom Tromey1-0/+4
PR dap/33228 points out a failure that occurs when the DAP client requests more children of a variable than actually exist. Currently, gdb throws a somewhat confusing exception. This patch changes this code to throw a DAPException instead, resulting in a more ordinary and readable failure. The spec seems to be silent on what to do in this case. I chose an exception on the theory that it's easier to be strict now and lift the restriction later (if needed) than vice versa. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33228
2025-08-11Do not allow DAP clients to dereference "void *"Tom Tromey1-4/+10
While investigating a different bug, I noticed that the DAP code would report a "void *"-typed register as having children -- however, requesting the children of this register would fail. The issue here is that a plain "void *" can't be dereferenced. This patch changes the default visualizer to treat a "void *" as a scalar. This adds a new test; but also arranges to examine all the returned registers -- this was the first thing I attempted and it seemed reasonable to have a test that double-checks that all the registers really can be dereferenced as appropriate. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33228
2025-06-24Allow DAP "threads" request when inferior is runningTom Tromey1-9/+14
A user pointed out that DAP allows the "threads" request to work when the inferior is running. This is documented in the overview, not the specification. While looking into this, I found a few other issues: * The _thread_name function was not marked @in_gdb_thread. This isn't very important but is still an oversight. * DAP requires all threads to have a name -- the field is not optional in the "Thread" type. * There was no test examining events resulting from the inferior printing to stdout. This patch fixes all these problems. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33080
2025-06-17gdb/dap: allow more requests when the process is runningoltolm1-3/+3
Makes it possible to set and remove other types of breakpoints while the process is running. Makes debugging more convenient. Approved-By: Tom Tromey <tom@tromey.com>
2025-06-12Minor grammar fix in DAP commentTom Tromey1-1/+1
I noticed a minor grammer issue in a comment in DAP.
2025-06-02Fix DAP defer_stop_events implementationTom Tromey4-53/+62
DAP requests have a "defer_stop_events" option that is intended to defer the emission of any "stopped" event until after the current request completes. This was needed to handle async continues like "finish &". However, I noticed that sometimes DAP tests can fail, because a stop event does arrive before the response to the "stepOut" request. I've only noticed this when the machine is fairly loaded -- for instance when I'm regression-testing a series, it may occur in some of the tests mid-series. I believe the problem is that the implementation in the "request" function is incorrect -- the flag is set when "request" is invoked, but instead it must be deferred until the request itself is run. That is, the setting must be captured in one of the wrapper functions. Following up on this, Simon pointed out that introducing a delay before sending a request's response will cause test case failures. That is, there's a race here that is normally hidden. Investigation showed that that deferred requests can't force event deferral. This patch implements this; but more testing showed many more race failures. Some of these are due to how the test suite is written. Anyway, in the end I took the radical approach of deferring all events by default. Most DAP requests are asynchronous by nature, so this seemed ok. The only case I found that really required this is pause.exp, where the test (rightly) expects to see a 'continued' event while performing an inferior function call. I went through all events and all requests and tried to convince myself that this patch will cause acceptable behavior in every case. However, it's hard to be completely sure about this approach. Maybe there are cases that do still need an event before the response, but we just don't have tests for them. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32685 Acked-By: Simon Marchi <simon.marchi@efficios.com>
2025-06-02[gdb/python] Reimplement F405 fixTom de Vries1-10/+20
At commit 34b0776fd73^, flake8 reports the following F405 warnings: ... $ pre-commit run flake8 --file gdb/python/lib/gdb/__init__.py flake8...................................................................Failed - hook id: flake8 - exit code: 1 F405 'flush' may be undefined, or defined from star imports: _gdb F405 'write' may be undefined, or defined from star imports: _gdb F405 'STDOUT' may be undefined, or defined from star imports: _gdb F405 'STDERR' may be undefined, or defined from star imports: _gdb ... F405 'selected_inferior' may be undefined, or defined from star imports: _gdb F405 'execute' may be undefined, or defined from star imports: _gdb F405 'parameter' may be undefined, or defined from star imports: _gdb ... The F405s are addressed by commit 34b0776fd73 ('Suppress some "undefined" warnings from flake8'). The problem indicated by the first F405 is that the use of flush here: ... class _GdbFile(object): ... def flush(self): flush(stream=self.stream) ... cannot be verified by flake8. It concludes that either, flush is undefined, or it is defined by this "star import": ... from _gdb import * # noqa: F401,F403 ... In this particular case, indeed flush is defined by the star import. This can be addressed by simply adding: ... flush(stream=self.stream) # noqa: F405 ... but that has only effect for flake8, so other analyzers may report the same problem. The commit 34b0776fd73 addresses it instead by adding an "import _gdb" and adding a "_gdb." prefix: ... _gdb.flush(stream=self.stream) ... This introduces a second way to specify _gdb names, but the first one still remains, and occasionally someone will use the first one, which then requires fixing once flake8 is run [1]. While this works to silence the warnings, there is a problem: if a developer makes a typo: ... _gdb.flash(stream=self.stream) ... this is not detected by flake8. This matters because although the python import already complains: ... $ gdb -q -batch -ex "python import gdb" Exception ignored in: <gdb._GdbFile object at 0x7f6186d4d7f0> Traceback (most recent call last): File "__init__.py", line 63, in flush _gdb.flash(stream=self.stream) AttributeError: module '_gdb' has no attribute 'flash' ... that doesn't trigger if the code is hidden behind some control flow: ... if _var_mostly_false: flash(stream=self.stream) ... Instead, fix the F405s by reverting commit 34b0776fd73 and adding a second import of _gdb alongside the star import which lists the names used locally: ... from _gdb import * # noqa: F401,F403 +from _gdb import ( + STDERR, + STDOUT, + Command, + execute, + flush, + parameter, + selected_inferior, + write, +) ... This gives the following warnings for the flash typo: ... 31:1: F401 '_gdb.flush' imported but unused 70:5: F811 redefinition of unused 'flush' from line 31 71:9: F405 'flash' may be undefined, or defined from star imports: _gdb ... The benefits of this approach compared to the previous one are that: - the typo is noticed, and - when using a new name, the F405 fix needs to be done once (by adding it to the explicit import list), while previously the fix had to be applied to each use (by adding the "_gdb." prefix). Tested on x86_64-linux. Approved-By: Tom Tromey <tom@tromey.com> [1] Commit 475799b692e ("Fix some pre-commit nits in gdb/__init__.py")
2025-05-30Require Python 3.4Tom Tromey1-6/+1
I believe we previously agreed that the minimum supported Python version should be 3.4. This patch makes this change, harmonizing the documentation (which was inconsistent about the minimum version) and the code. New in v2: rebased, and removed a pre-3.4 workaround from __init__.py. Reviewed-By: Eli Zaretskii <eliz@gnu.org> Approved-by: Kevin Buettner <kevinb@redhat.com> Acked-By: Tom de Vries <tdevries@suse.de> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31870
2025-05-29gdb/dap: fix completion request for empty stringsJorenar1-2/+5
When DAP completion requests receives empty string to complete, the script crashes due trying to access element -1 from list being a result of `text.splitlines()` (which for `text == ""` evaluates into empty list). This patch adds simple check if `text` is populated, and when it is not, skips transformations and assigns correct result directly. Approved-By: Tom Tromey <tom@tromey.com>
2025-05-14Fix some pre-commit nits in gdb/__init__.pyTom Tromey1-3/+3
I noticed that pre-commit has some complaints (flake8 and codespell) about gdb/__init__.py. This patch fixes these. Approved-By: Tom de Vries <tdevries@suse.de>
2025-05-13gdb/python: new gdb.ParameterPrefix classAndrew Burgess1-0/+118
This commit adds a new gdb.ParameterPrefix class to GDB's Python API. When creating multiple gdb.Parameters, it is often desirable to group these together under a sub-command, for example, 'set print' has lots of parameters nested under it, like 'set print address', and 'set print symbol'. In the Python API the 'print' part of these commands are called prefix commands, and are created using gdb.Command objects. However, as parameters are set via the 'set ....' command list, and shown through the 'show ....' command list, creating a prefix for a parameter usually requires two prefix commands to be created, one for the 'set' command, and one for the 'show' command. This often leads to some duplication, or at the very least, each user will end up creating their own helper class to simplify creation of the two prefix commands. This commit adds a new gdb.ParameterPrefix class. Creating a single instance of this class will create both the 'set' and 'show' prefix commands, which can then be used while creating the gdb.Parameter. Here is an example of it in use: gdb.ParameterPrefix('my-prefix', gdb.COMMAND_NONE) This adds 'set my-prefix' and 'show my-prefix', both of which are prefix commands. The user can then add gdb.Parameter objects under these prefixes. The gdb.ParameterPrefix initialise method also supports documentation strings, so we can write: gdb.ParameterPrefix('my-prefix', gdb.COMMAND_NONE, "Configuration setting relating to my special extension.") which will set the documentation string for the prefix command. Also, it is possible to support prefix commands that use the `invoke` functionality to handle unknown sub-commands. This is done by sub-classing gdb.ParameterPrefix and overriding either 'invoke_set' or 'invoke_show' to handle the 'set' or 'show' prefix command respectively. Reviewed-By: Eli Zaretskii <eliz@gnu.org>
2025-05-12gdb/dap: fix decode_sourceoltolm1-3/+3
The documentation for the Source interface says * The path of the source to be shown in the UI. * It is only used to locate and load the content of the source if no * `sourceReference` is specified (or its value is 0). but the code used `path` first. I fixed it to use `sourceReference` first. Approved-By: Tom Tromey <tom@tromey.com>
2025-04-24gdb: fix some flake8 F824 warningsSimon Marchi11-33/+2
flake8 7.2.0 appears to have this new warning: F824: global name / nonlocal name is unused: name is never assigned in scope It points out a few places in our code base where "global" is not necessary, fix them. Change-Id: Ia6fb08686977559726fefe2a5bb95d8dcb298bb0 Approved-By: Tom Tromey <tom@tromey.com>
2025-04-08Update copyright dates to include 2025Tom Tromey52-52/+52
This updates the copyright headers to include 2025. I did this by running gdb/copyright.py and then manually modifying a few files as noted by the script. Approved-By: Eli Zaretskii <eliz@gnu.org>
2025-04-07[gdb/cli] Use debug info language to pick pygments lexerTom de Vries1-3/+7
Consider the following scenario: ... $ cat hello int main (void) { printf ("hello\n"); return 0; } $ gcc -x c hello -g $ gdb -q -iex "maint set gnu-source-highlight enabled off" a.out Reading symbols from a.out... (gdb) start Temporary breakpoint 1 at 0x4005db: file hello, line 6. Starting program: /data/vries/gdb/a.out [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". Temporary breakpoint 1, main () at hello:6 6 printf ("hello\n"); ... This doesn't produce highlighting for line 6, because: - pygments is used for highlighting instead of source-highlight, and - pygments guesses the language for highlighting only based on the filename, which in this case doesn't give a clue. Fix this by: - adding a language parameter to the extension_language_ops.colorize interface, - passing the language as found in the debug info, and - using it in gdb.styling.colorize to pick the pygments lexer. The new test-case gdb.python/py-source-styling-2.exp excercises a slightly different scenario: it compiles a c++ file with a .c extension, and checks that c++ highlighting is done instead of c highlighting. Tested on x86_64-linux. Approved-By: Tom Tromey <tom@tromey.com> PR cli/30966 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30966
2025-04-03Make gdb/python codespell-cleanTom Tromey1-1/+1
This cleans up the last codespell report in the Python directory and adds gdb/python to pre-commit. Approved-By: Tom de Vries <tdevries@suse.de>
2025-03-27gdb/dap - Add CompletionsRequestoltolm3-2/+80
Use GDB/MI command "-complete" to implement. Co-authored-by: Simon Farre <simon.farre.cx@gmail.com> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31140 Approved-By: Tom Tromey <tom@tromey.com> Reviewed-By: Eli Zaretskii <eliz@gnu.org>
2025-03-06[gdb/python] Fix typos in libTom de Vries2-2/+2
Fix typos: ... gdb/python/lib/gdb/disassembler.py:84: dissables ==> disables gdb/python/lib/gdb/command/xmethods.py:40: experession ==> expression ...
2025-02-18[gdb] Fix some typosTom de Vries1-1/+1
Fix typos: ... overriden -> overridden reate -> create ... Tested on x86_64-linux. I
2025-02-14gdb/python/dap: prefix internal attributes with underscoreSimon Marchi7-118/+116
I'm currently reading the DAP code, and I think this would help. This is pretty much standard Python style, we do it as some places but not others. I think it helps readability, by saying that this attribute isn't mean to be accessed outside the class. A similar pass could be done for internal methods, I haven't done that. Change-Id: I8e8789b39adafe62d14404d19f7fc75e2a364e01 Approved-By: Tom Tromey <tom@tromey.com>
2025-02-03pre-commit autoupdateSimon Marchi1-1/+1
Run `pre-commit autoupdate`. This picks up a fresh Black version from 2025, and with it comes a small but welcome formatting change. There is a new version of isort as well, but no formatting change there. Change-Id: Ie654a9c14c3a4096893011082668efb57c166fa4
2025-01-13Handle case where DAP line can be NoneTom Tromey1-2/+2
A comment in bugzilla pointed out a bug in my earlier patch to handle the DAP "linesStartAt1" setting. In particular, in the backtrace code, "line" can be None, which would lead to an exception from export_line. This patch fixes the problem. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32468
2025-01-06Handle linesStartAt1 in DAPTom Tromey6-14/+50
The DAP initialize request has a "linesStartAt1" option, where the client can indicate that it prefers whether line numbers be 0-based or 1-based. This patch implements this. I audited all the line-related code in the DAP implementation. Note that while a similar option exists for column numbers, gdb doesn't handle these yet, so nothing is done here. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32468
2024-12-16Re-run isortTom Tromey1-1/+1
I noticed that an earlier commit caused a change in the isort output. This patch repairs the problem.
2024-12-14[gdb/dap] Fix regressions with python 3.6Tom de Vries1-1/+2
With test-case gdb.dap/ada-arrays.exp, on Leap openSUSE 15.6 with python 3.6, I run into: ... Python Exception <class 'TypeError'>: 'type' object is not subscriptable Error occurred in Python: 'type' object is not subscriptable ERROR: tcl error sourcing ada-arrays.exp. ... This is due to using a python 3.9 construct: ... thread_ids: dict[int, int] = {} ... Fix this by using typing.Dict instead. Tested on x86_64-linux.
2024-12-13gdb/dap: allow some requests when the process is runningoltolm2-2/+2
It is impossible to set a breakpoint when the process is running, which I find annoying. LLDB does not have this restriction. I made `setBreakpoints` and `breakpointLocations` work when the process is running. Probably more requests can be changed, but I only need these two at the moment. Approved-By: Tom Tromey <tom@tromey.com>
2024-12-13gdb-dap: fix gdb.error: Frame is invalid.Oleg Tolmatcev2-18/+34
When you try to use a frame on one thread and it was created on another you get an error. I fixed it by creating a map from a frame ID to a thread ID. When a frame is created it is added to the map. When you try to find a frame for an id it checks if it is on the correct thread and if not switches to that thread. I had to store the frame id instead of the frame itself in a "_ScopeReference". Signed-off-by: Oleg Tolmatcev <oleg.tolmatcev@gmail.com> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32133 Approved-By: Tom Tromey <tom@tromey.com>
2024-12-09Introduce NoOpStringPrinterTom Tromey1-1/+39
We discovered that attempting to print a very large string-like array would succeed on the CLI, but in DAP would cause the "variables" request to fail with: value requires 67038491 bytes, which is more than max-value-size This turns out to be a limitation in Value.format_string, which de-lazy-ifies the value. This patch fixes this problem by introducing a new NoOpStringPrinter class, and then using it for string-like values. This printer returns a lazy string, which solves the problem. Note there are some special cases where we do not want to return a lazy string. I've documented these in the code. I considered making gdb.Value.lazy_string handle these cases -- for example it could return 'self' rather than a lazy string in some situations -- but this approach was simpler.
2024-12-09Omit artificial symbols from DAP variables responseTom Tromey2-1/+4
While testing DAP, we found a situation where a compiler-generated variable caused the "variables" request to fail -- the variable in question being an apparent 67-megabyte string. It seems to me that artificial variables like this aren't interesting to DAP users, and the gdb CLI omits these as well. This patch changes DAP to omit these variables, adding a new gdb.Symbol.is_artificial attribute to make this possible.
2024-12-09Defer DAP launch command until after configurationDoneTom Tromey1-38/+114
PR dap/32090 points out that gdb's DAP "launch" sequencing is incorrect. The current approach (which is itself a 2nd implementation...) was based on a misreading of the spec. The spec has since been clarified here: https://github.com/microsoft/debug-adapter-protocol/issues/497 The clarification here is that a client is free to send the "launch" (or "attach") request at any point after the "initialized" event has been sent by gdb. However, the "launch" does not cause any action to be taken -- and does not send a response -- until after "configurationDone" has been seen. This patch implements this by arranging for the launch and attach commands to return a DeferredRequest object. All the tests needed updates. I've also added a new test that checks that the deferred "launch" request can be cancelled. (Note that the cancellation is lazy -- it also waits until configurationDone is seen. This could be fixed, but I was not sure whether it is important to do so.) Finally, the "launch" command has a somewhat funny sequencing now. Simply sending the command and waiting for a response yielded strange results if the inferior did not stop -- in this case, the repsonse was never sent. So now, the command is split into two parts, with some setup being done synchronously (for better error propagation) and the actual "run" being done async. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32090 Reviewed-by: Kévin Le Gouguec <legouguec@adacore.com>
2024-12-09Add DAP deferred requestsTom Tromey1-24/+136
This adds a new "deferred request" capability to DAP. The idea here is that if a request returns a DeferredRequest object, then no response is sent immediately to the client. Instead, the request is pending until the deferred request is rescheduled. Some minor refactorings, particularly in cancellation, were needed to make this work. There's no use of this in the tree yet -- that is the next patch. Reviewed-by: Kévin Le Gouguec <legouguec@adacore.com>
2024-12-09Allow cancellation of DAP-thread requestsTom Tromey1-6/+18
This patch started as an attempt to fix the comment in CancellationHandler.cancel, but while working on it I found that the code could be improved as well. The current DAP cancellation code only handles the case where work is done on the gdb thread -- by checking for cancellation in interruptable_region. This means that if a request is handled completely in tthe DAP thread, then cancellation will never work. Now, this isn't a bug per se. DAP doesn't actually require that cancellation succeed. In fact, I think it can't, because cancellation is inherently racy. However, a coming patch will add a sort of "pending" request, and it would be nice if that were cancellable before any commands are sent to the gdb thread. No test in this patch, but one will arrive at the end of the series. Reviewed-by: Kévin Le Gouguec <legouguec@adacore.com>
2024-12-09Refactor CancellationHandler in DAPTom Tromey1-18/+15
This refactors the DAP CancellationHandler to be a context manager, and reorganizes the caller to use this. This is a bit more robust and also simplifies a subsequent patch in this series. Reviewed-by: Kévin Le Gouguec <legouguec@adacore.com>
2024-12-09Add call_function_later to DAPTom Tromey1-0/+12
This adds a new call_function_later API to DAP. This arranges to run a function after the current request has completed. This isn't used yet, but will be at the end of this series. Reviewed-by: Kévin Le Gouguec <legouguec@adacore.com>
2024-12-09Reimplement DAP delayed eventsTom Tromey1-12/+12
This patch changes how delayed events are implemented in DAP. The new implementation makes it simpler to add a delayed function call, which will be needed by the final patch in this series. Reviewed-by: Kévin Le Gouguec <legouguec@adacore.com>
2024-12-09Reimplement DAP's stopAtBeginningOfMainSubprogramTom Tromey1-5/+7
Right now, stopAtBeginningOfMainSubprogram is implemented "by hand", but then later the launch function uses "starti" to implement stopOnEntry. This patch unifies this code and rewrites it to use "start" when appropriate. Reviewed-by: Kévin Le Gouguec <legouguec@adacore.com>
2024-11-11gdb: fix missing operator % on xmethod matcher outputPedro Silva1-3/+8
Fixed missing operator % on xmethod matcher registration output and, as suggested on bug 32532, converted both uses of operator % to str.format. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32352 Change-Id: Ic471516292c2f1d6d1284aaeaea3ec14421decb8
2024-11-10gdb/python: implement Python find_exec_by_build_id hookAndrew Burgess5-216/+461
Implement extension_language_ops::find_objfile_from_buildid within GDB's Python API. Doing this allows users to write Python extensions that can help locate missing objfiles when GDB opens a core file. A handler might perform some project- or site-specific actions to find a missing objfile. Or might provide some project- or site-specific advice to the user on how they can obtain the missing objfile. The implementation is very similar to the approach taken in: commit 8f6c452b5a4e50fbb55ff1d13328b392ad1fd416 Date: Sun Oct 15 22:48:42 2023 +0100 gdb: implement missing debug handler hook for Python The following new commands are added as commands implemented in Python, this is similar to how the Python missing debug and unwinder commands are implemented: info missing-objfile-handlers enable missing-objfile-handler LOCUS HANDLER disable missing-objfile-handler LOCUS HANDLER To make use of this extension hook a user will create missing objfile handler objects, and registers these handlers with GDB. When GDB opens a core file and encounters a missing objfile each handler is called in turn until one is able to help. Here is a minimal handler that does nothing useful: import gdb import gdb.missing_objfile class MyFirstHandler(gdb.missing_objfile.MissingObjfileHandler): def __init__(self): super().__init__("my_first_handler") def __call__(self, pspace, build_id, filename): # This handler does nothing useful. return None gdb.missing_objfile.register_handler(None, MyFirstHandler()) Returning None from the __call__ method tells GDB that this handler was unable to find the missing objfile, and GDB should ask any other registered handlers. Possible return values from a handler: - None: This means the handler couldn't help. GDB will call other registered handlers to see if they can help instead. - False: The handler has done all it can, but the objfile couldn't be found. GDB will not call any other handlers, and will continue without the objfile. - True: The handler has installed the objfile into a location where GDB would normally expect to find it. GDB should repeat its normal lookup process and the objfile should now be found. - A string: The handler can return a filename, which is the missing objfile. GDB will load this file. Handlers can be registered globally, or per program space. GDB checks the handlers for the current program space first, and then all of the global handles. The first handler that returns a value that is not None, has "handled" the missing objfile, at which point GDB continues. The implementation of this feature is mostly straight forward. I have reworked some of the missing debug file related code so that it can be shared with this feature. E.g. gdb/python/lib/gdb/missing_files.py is mostly content moved from gdb/python/lib/gdb/missing_debug.py, but updated to be more generic. Now gdb/python/lib/gdb/missing_debug.py and the new file gdb/python/lib/gdb/missing_objfile.py both call into the missing_files.py file. For gdb/python/lib/gdb/command/missing_files.py this is even more extreme, gdb/python/lib/gdb/command/missing_debug.py is completely gone now and gdb/python/lib/gdb/command/missing_files.py provides all of the new commands in a generic way. I have made one change to the existing Python API, I renamed the attribute Progspace.missing_debug_handlers to Progspace.missing_file_handlers. I don't see this as too problematic. This attribute was only used to implement the missing debug feature and was never documented beyond the fact that it existed. There was no reason for users to be touching this attribute. Reviewed-By: Eli Zaretskii <eliz@gnu.org>
2024-10-06[gdb] Fix common misspellingsTom de Vries1-1/+1
Fix the following common misspellings: ... accidently -> accidentally additonal -> additional addresing -> addressing adress -> address agaisnt -> against albiet -> albeit arbitary -> arbitrary artifical -> artificial auxillary -> auxiliary auxilliary -> auxiliary bcak -> back begining -> beginning cannonical -> canonical compatiblity -> compatibility completetion -> completion diferent -> different emited -> emitted emiting -> emitting emmitted -> emitted everytime -> every time excercise -> exercise existance -> existence fucntion -> function funtion -> function guarentee -> guarantee htis -> this immediatly -> immediately layed -> laid noone -> no one occurances -> occurrences occured -> occurred originaly -> originally preceeded -> preceded preceeds -> precedes propogate -> propagate publically -> publicly refering -> referring substract -> subtract substracting -> subtracting substraction -> subtraction taht -> that targetting -> targeting teh -> the thier -> their thru -> through transfered -> transferred transfering -> transferring upto -> up to vincinity -> vicinity whcih -> which whereever -> wherever wierd -> weird withing -> within writen -> written wtih -> with doesnt -> doesn't ... Tested on x86_64-linux.
2024-10-03gdb-dap: disable events when deleting breakpointsoltolm1-3/+3
when I disable a breakpoint in VS Code the breakpoint is removed instead. I compared the behavior to lldb-dap and disabled events when removing a breakpoint. Now it is possible to disable and enable breakpoints in VS Code.
2024-09-25gdb, gdbserver, python, testsuite: Remove MPX.Schimpe, Christina1-39/+0
GDB deprecated the commands "show/set mpx bound" in GDB 15.1, as Intel listed Intel(R) Memory Protection Extensions (MPX) as removed in 2019. MPX is also deprecated in gcc (since v9.1), the linux kernel (since v5.6) and glibc (since v2.35). Let's now remove MPX support in GDB completely. This includes the removal of: - MPX functionality including register support - deprecated mpx commands - i386 and amd64 implementation of the hooks report_signal_info and get_siginfo_type - tests - and pretty printer. We keep MPX register numbers to not break compatibility with old gdbservers. Approved-By: Felix Willgerodt <felix.willgerodt@intel.com>
2024-09-25gdb, testsuite, python: Add missing imports.Schimpe, Christina1-0/+1
Removing the pretty printer (bound_registers.py) in the next commit leads to failures due to a missing import of 'gdb.printing': "AttributeError: module 'gdb' has no attribute 'printing'". Add this import to each file requiring it, as it's not imported by the pretty-printer anymore. Approved-By: Andrew Burgess <aburgess@redhat.com>
2024-09-13gdb dap: introduce stopOnEntry optionoltolm1-1/+2
Approved-By: Tom Tromey <tom@tromey.com> Reviewed-By: Eli Zaretskii <eliz@gnu.org>
2024-09-13Add quoting to 'file' invocations in DAPTom Tromey1-3/+14
Oleg Tolmatcev noticed that DAP launch and attach requests don't properly handle Windows filenames, because "file" doesn't handle the backslash characters correctly. This patch adds quoting to the command in an attempt to fix this.
2024-09-10gdb/python: avoid depending on the curses libraryAndrew Burgess1-3/+27
The commit: commit 29c70787112e01cd52b53bf14bdcacb0a11e0725 Date: Sun Sep 8 07:46:09 2024 +0200 [gdb/testsuite] Handle missing curses in gdb.python/py-missing-debug.exp Highlighted that in some cases we might be running on a system with an older version of Python (earlier than 3.7), and on a system for which the curses library has not been installed. In these circumstances the gdb.missing_debug module will not load as it uses curses to provide isalnum() and isascii() functions. To avoid this problem I propose that we copy the isalnum() and isascii() from the Python curses library. These functions are basically trivial and removing the curses dependency means GDB will work in more cases without increasing its dependencies. I did consider keeping the uses of curses and only having the function definitions be a fallback for when the curses library failed to load, but this felt like overkill. The function definitions are both tiny and I think "obvious" given their specifications, so I figure we might as well just use our own definitions if they are not available as builtin methods on the str class. For testing I changed this line: if sys.version_info >= (3, 7): to if sys.version_info >= (3, 7) and False: then reran gdb.python/py-missing-debug.exp, there were no failures. Approved-By: Tom de Vries <tdevries@suse.de>
2024-08-16Fix DAP failure when fetching global variablesTom Tromey1-1/+2
The relatively new "globals" scope code in DAP has a fairly obvious bug -- the fetch_one_child method should return a tuple with two elements, but instead just returns the variable's value. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32029 Reviewed-By: Tom de Vries <tdevries@suse.de>
2024-08-14Log gdb version and configuration in DAPTom Tromey1-0/+3
I think it would be useful for gdb's DAP logs to come with the version and configuration information. This might make debugging some bug reports a little simpler.