aboutsummaryrefslogtreecommitdiff
path: root/gdb/python
AgeCommit message (Collapse)AuthorFilesLines
2024-08-27[gdb/python] Use GDB_PY_HANDLE_EXCEPTION more oftenTom de Vries12-29/+14
I found a few more places where we can use GDB_PY_HANDLE_EXCEPTION. Tested on x86_64-linux. Approved-By: Tom Tromey <tom@tromey.com>
2024-08-22[gdb] Add const to catch gdb_exceptionTom de Vries3-6/+6
I did a review of lines containing "catch (gdb_exception" and found a few where we can add const. Tested on x86_64-linux. Approved-By: Tom Tromey <tom@tromey.com>
2024-08-22[gdb/python] Eliminate catch(...) in type_to_type_objectTom de Vries1-1/+5
In type_to_type_object we have: ... try { if (type->is_stub ()) type = check_typedef (type); } catch (...) { /* Just ignore failures in check_typedef. */ } ... The catch is supposed to ignore gdb_exception_error, but it ignores any exception. Fix that by only ignoring gdb_exception_error, and handling gdb_exception_quit / gdb_exception_forced_quit using GDB_PY_HANDLE_EXCEPTION. Tested on x86_64-linux. Approved-By: Tom Tromey <tom@tromey.com>
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.
2024-08-14Fix failure with C++ exceptions in DAPTom Tromey1-1/+4
While working on earlier patches, I noticed that the DAP C++ exception test had some strange results in the log. Digging into this, I found that while the Ada catchpoints emit a "bkptno" field in the MI result, the C++ ones do not -- but the DAP code was relying on this. This patch fixes the problem by changing which field is examined, and then updates the tests to verify this. Reviewed-by: Keith Seitz <keiths@redhat.com>
2024-08-14Make DAP instruction breakpoints unverifiedTom Tromey1-2/+7
Currently, when a DAP client uses setInstructionBreakpoints, the resulting breakpoints are created as "verified", even though there is no symbol file and thus the breakpoint can't possibly have a source location. This patch changes the DAP code to assume that all breakpoints are unverified before launch. Reviewed-by: Keith Seitz <keiths@redhat.com>
2024-08-14Introduce exec_mi_and_log for DAPTom Tromey4-9/+20
This adds a new exec_mi_and_log function that wraps gdb.execute_mi and logs the command. This can be handy when debugging DAP. Reviewed-by: Keith Seitz <keiths@redhat.com>
2024-08-14btrace, python: Enable ptwrite filter registration.Felix Willgerodt4-0/+185
By default GDB will be printing the hex payload of the ptwrite package as auxiliary information. To customize this, the user can register a ptwrite filter function in python, that takes the payload and the PC as arguments and returns a string which will be printed instead. Registering the filter function is done using a factory pattern to make per-thread filtering easier. Approved-By: Markus Metzger <markus.t.metzger@intel.com>
2024-08-14python: Add clear() to gdb.Record.Felix Willgerodt3-0/+32
This function allows to clear the trace data from python, forcing to re-decode the trace for successive commands. This will be used in future ptwrite patches, to trigger re-decoding when the ptwrite filter changes. Reviewed-By: Eli Zaretskii <eliz@gnu.org> Approved-By: Markus Metzger <markus.t.metzger@intel.com>
2024-08-14python: Introduce gdb.RecordAuxiliary class.Felix Willgerodt4-16/+140
Auxiliary instructions are no real instructions and get their own object class, similar to gaps. gdb.Record.instruction_history is now possibly a list of gdb.RecordInstruction, gdb.RecordGap or gdb.RecordAuxiliary objects. This patch is in preparation for the new ptwrite feature, which is based on auxiliary instructions. Approved-By: Markus Metzger <markus.t.metzger@intel.com> Reviewed-By: Eli Zaretskii <eliz@gnu.org>
2024-08-12gdb: drop struct keyword when using bound_minimal_symbolSimon Marchi1-2/+2
This is a simple find / replace from "struct bound_minimal_symbol" to "bound_minimal_symbol", to make things shorter and more consisten througout. In some cases, move variable declarations where first used. Change-Id: Ica4af11c4ac528aa842bfa49a7afe8fe77a66849 Reviewed-by: Keith Seitz <keiths@redhat.com> Approved-By: Andrew Burgess <aburgess@redhat.com>
2024-08-08[gdb/python] Fix handling of ^C during disassemblyTom de Vries1-1/+1
Inspired by the trigger patch I used here [1], I tried this in gdbpy_print_insn: ... /* Call into the registered disassembler to (possibly) perform the disassembly. */ + set_quit_flag (); PyObject *insn_disas_obj = (PyObject *) disasm_info; gdbpy_ref<> result (PyObject_CallFunctionObjArgs (hook.get (), insn_disas_obj, ... and with test-case gdb.python/py-disasm-exec.exp ran into: ... (gdb) disassemble test^M Dump of assembler code for function test:^M 0x00000000004101ac <+0>: Python Exception <class 'KeyboardInterrupt'>: ^M ^M unknown disassembler error (error = -1)^M (gdb) ... This is incorrect, the KeyboardInterrupt should propagate and interrupt the command. Fix this by using gdbpy_print_stack_or_quit instead of gdbpy_print_stack in gdbpy_print_insn, giving us instead: ... (gdb) disassemble test^M Dump of assembler code for function test:^M 0x00000000004101ac <+0>: ^M Quit^M (gdb) ... Tested on aarch64-linux. Approved-By: Andrew Burgess <aburgess@redhat.com> [1] https://sourceware.org/pipermail/gdb-patches/2024-July/210798.html
2024-07-24[gdb/exp] Allow internal function to indicate return typeTom de Vries1-1/+2
Currently an internal function handler has this prototype: ... struct value *handler (struct gdbarch *gdbarch, const struct language_defn *language, void *cookie, int argc, struct value **argv); ... Also allow an internal function with a handler with an additional "enum noside noside" parameter: ... struct value *handler (struct gdbarch *gdbarch, const struct language_defn *language, void *cookie, int argc, struct value **argv, enum noside noside); ... In case such a handler is called with noside == EVAL_AVOID_SIDE_EFFECTS, it's expected to return some value with the correct return type. At least, provided it can do so without side effects, otherwise it should throw an error. No functional changes. Tested on x86_64-linux and aarch64-linux. Reviewed-By: Keith Seitz <keiths@redhat.com>
2024-07-23Add returnValue scope to DAPTom Tromey1-12/+11
The DAP spec recently changed to add a new scope for the return value from a "stepOut" request. This new scope uses the "returnValue" presentation hint. See: https://github.com/microsoft/debug-adapter-protocol/issues/458 This patch implements this for gdb. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31945 Reviewed-By: Eli Zaretskii <eliz@gnu.org>
2024-07-16gdb, gdbserver, gdbsupport: use [[noreturn]] instead of ATTRIBUTE_NORETURNSimon Marchi1-3/+2
C++ 11 has a built-in attribute for this, no need to use a compat macro. Change-Id: I90e4220d26e8f3949d91761f8a13cd9c37da3875 Reviewed-by: Lancelot Six <lancelot.six@amd.com>
2024-07-15gdb: pass program space to get_current_source_symtab_and_lineSimon Marchi1-1/+1
Make the current program space reference bubble up one level. Change-Id: I6ba6dc4a2cb188720cbb61b84ab5c954aac105c6 Approved-By: Tom Tromey <tom@tromey.com> Reviewed-By: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
2024-07-15gdb: make objfile::pspace privateSimon Marchi1-1/+1
Rename to m_pspace, add getter. An objfile's pspace never changes, so no setter is necessary. Change-Id: If4dfb300cb90dc0fb9776ea704ff92baebb8f626
2024-06-24Rename symtab::fullnameTom Tromey1-2/+2
This renames symtab::fullname to m_fullname and adds new accessor methods.
2024-06-19[gdb/build] Redo poisoning of PyObject_CallMethodTom de Vries1-3/+5
In commit 764af878259 ("[gdb/python] Add typesafe wrapper around PyObject_CallMethod") I added poisoning of PyObject_CallMethod: ... /* Poison PyObject_CallMethod. The typesafe wrapper gdbpy_call_method should be used instead. */ template<typename... Args> PyObject * PyObject_CallMethod (Args...); ... The idea was that subsequent code would be forced to use gdbpy_call_method instead of PyObject_CallMethod. However, that caused build issues with gcc 14 and python 3.13: ... /usr/bin/ld: python/py-disasm.o: in function `gdb::ref_ptr<_object, gdbpy_ref_policy<_object> > gdbpy_call_method<unsigned int, long long>(_object*, char const*, unsigned int, long long)': /data/vries/gdb/src/gdb/python/python-internal.h:207:(.text+0x384f): undefined reference to `_object* PyObject_CallMethod<_object*, char*, char*, unsigned int, long long>(_object*, char*, char*, unsigned int, long long)' /usr/bin/ld: python/py-tui.o: in function `gdb::ref_ptr<_object, gdbpy_ref_policy<_object> > gdbpy_call_method<int>(_object*, char const*, int)': /data/vries/gdb/src/gdb/python/python-internal.h:207:(.text+0x1235): undefined reference to `_object* PyObject_CallMethod<_object*, char*, char*, int>(_object*, char*, char*, int)' /usr/bin/ld: python/py-tui.o: in function `gdb::ref_ptr<_object, gdbpy_ref_policy<_object> > gdbpy_call_method<int, int, int>(_object*, char const*, int, int, int)': /data/vries/gdb/src/gdb/python/python-internal.h:207:(.text+0x12b0): undefined reference to `_object* PyObject_CallMethod<_object*, char*, char*, int, int, int>(_object*, char*, char*, int, int, int)' collect2: error: ld returned 1 exit status ... Fix this by poisoning without using templates. Tested on x86_64-linux.
2024-06-19gdb/python/python-internal.h: avoid uninitialized constexprLancelot SIX1-6/+18
The following recent change introduced a regression when building using clang++: commit 764af878259768bb70c65bdf3f3285c2d6409bbd Date: Wed Jun 12 18:58:49 2024 +0200 [gdb/python] Add typesafe wrapper around PyObject_CallMethod The error message is: ../../gdb/python/python-internal.h:151:16: error: default initialization of an object of const type 'const char' constexpr char gdbpy_method_format; ^ = '\0' CXX python/py-block.o 1 error generated. make[2]: *** [Makefile:1959: python/py-arch.o] Error 1 make[2]: *** Waiting for unfinished jobs.... In file included from ../../gdb/python/py-auto-load.c:25: ../../gdb/python/python-internal.h:151:16: error: default initialization of an object of const type 'const char' constexpr char gdbpy_method_format; ^ = '\0' 1 error generated. make[2]: *** [Makefile:1959: python/py-auto-load.o] Error 1 In file included from ../../gdb/python/py-block.c:23: ../../gdb/python/python-internal.h:151:16: error: default initialization of an object of const type 'const char' constexpr char gdbpy_method_format; ^ = '\0' 1 error generated. This patch fixes this by changing gdbpy_method_format to be a templated struct, and only have its specializations define the static constexpr member "format". This way, we avoid having an uninitialized constexpr expression, regardless of it being instantiated or not. Reviewed-By: Tom de Vries <tdevries@suse.de> Change-Id: I5bec241144f13500ef78daea30f00d01e373692d
2024-06-13Add gdbpy_call_method overloads for gdbpy_ref<>Tom Tromey2-5/+14
This adds an overload of gdbpy_call_method that accepts a gdbpy_ref<>. This is just a small convenience. Reviewed-By: Tom de Vries <tdevries@suse.de>
2024-06-13Return gdbpy_ref<> from gdbpy_call_methodTom Tromey6-29/+29
This changes gdbpy_call_method to return a gdbpy_ref<>. This is slightly safer because it makes it simpler to correctly handle reference counts. Reviewed-By: Tom de Vries <tdevries@suse.de>
2024-06-12[gdb/python] Add typesafe wrapper around PyObject_CallMethodTom Tromey6-37/+79
In gdb/python/py-tui.c we have code like this: ... gdbpy_ref<> result (PyObject_CallMethod (m_window.get(), "hscroll", "i", num_to_scroll, nullptr)); ... The nullptr is superfluous, the format string already indicates that there's only one method argument. OTOH, passing no method args does use a nullptr: ... gdbpy_ref<> result (PyObject_CallMethod (m_window.get (), "render", nullptr)); ... Furthermore, choosing the right format string chars can be tricky. Add a typesafe wrapper around PyObject_CallMethod that hides these details, such that we can use the more intuitive: ... gdbpy_ref<> result (gdbpy_call_method (m_window.get(), "hscroll", num_to_scroll)); ... and: ... gdbpy_ref<> result (gdbpy_call_method (m_window.get (), "render")); ... Tested on x86_64-linux. Co-Authored-By: Tom de Vries <tdevries@suse.de> Approved-By: Tom Tromey <tom@tromey.com>
2024-06-11fix division by zero in target_read_string()Kilian Kilger1-1/+1
Under certain circumstances, a floating point exception in target_read_string() can happen when the type has been obtained by a call to stpy_lazy_string_elt_type(). In the latter function, a call to check_typedef() has been forgotten. This makes type->length = 0 in this case.
2024-06-10Make global_symbol_searcher::filenames privateTom Tromey1-8/+1
This patch renames global_symbol_searcher::filenames and makes it private, adding a new method to append a filename to the vector. This also cleans up memory management here, removing an alloca from rbreak, and removing a somewhat ugly SCOPE_EXIT from the Python code, in favor of having global_symbol_searcher manage the memory itself. Regression tested on x86-64 Fedora 38.
2024-06-10[gdb/python] Fix GDB_PY_{LL,LLU}_ARG on platform without long longTom de Vries1-2/+2
If in gdb/python/python-internal.h, we pretend to have a platform that doesn't support long long: ... -#ifdef HAVE_LONG_LONG +#if 0 ... I get on arm-linux: ... (gdb) placement_candidate() disassemble test^M Dump of assembler code for function test:^M 0x004004d8 <+0>: push {r11} @ (str r11, [sp, #-4]!)^M 0x004004dc <+4>: Python Exception <class 'ValueError'>: \ Buffer returned from read_memory is sized 0 instead of the expected 4^M ^M unknown disassembler error (error = -1)^M (gdb) FAIL: $exp: memory source api: second disassembler pass ... The problem is that gdb_py_longest is typedef-ed to long, but the corresponding format character GDB_PY_LL_ARG is defined to "L", meaning "long long" [1]. Fix this by using "l", meaning long instead. Likewise for GDB_PY_LLU_ARG. Tested on arm-linux. Approved-By: Tom Tromey <tom@tromey.com> PR python/31845 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31845 [1] https://docs.python.org/3/c-api/arg.html
2024-06-10[gdb/python] Fix gdb.python/py-disasm.exp on arm-linuxTom de Vries1-5/+7
After fixing test-case gdb.python/py-disasm.exp to recognize the arm nop: ... nop {0} ... we run into: ... disassemble test^M Dump of assembler code for function test:^M 0x004004d8 <+0>: push {r11} @ (str r11, [sp, #-4]!)^M 0x004004dc <+4>: add r11, sp, #0^M 0x004004e0 <+8>: nop {0}^M => 0x004004e4 <+12>: Python Exception <class 'ValueError'>: Buffer \ returned from read_memory is sized 0 instead of the expected 4^M ^M unknown disassembler error (error = -1)^M (gdb) FAIL: $exp: global_disassembler=ShowInfoRepr: disassemble test ... This is caused by this code in gdbpy_disassembler::read_memory_func: ... gdbpy_ref<> result_obj (PyObject_CallMethod ((PyObject *) obj, "read_memory", "KL", len, offset)); ... where len has type "unsigned int", while "K" means "unsigned long long" [1]. Fix this by using "I" instead, meaning "unsigned int". Also, offset has type LONGEST, which is typedef'ed to int64_t, while "L" means "long long". Fix this by using type gdb_py_longest for offset, in combination with format character "GDB_PY_LL_ARG". Likewise in disasmpy_info_read_memory. Tested on arm-linux. Reviewed-By: Alexandra Petlanova Hajkova <ahajkova@redhat.com> Approved-By: Tom Tromey <tom@tromey.com> PR python/31845 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31845 [1] https://docs.python.org/3/c-api/arg.html
2024-06-10[gdb/python] Note that python 3.6 assumes long long supportTom de Vries1-2/+13
Starting with python 3.6, support for platforms without long long support has been removed [1]. HAVE_LONG_LONG and PY_LONG_LONG are still defined, but only for compatibility, so stop relying on them. Tested on x86_64-linux. Approved-By: Tom Tromey <tom@tromey.com> [1] https://github.com/python/cpython/issues/72148
2024-06-07gdb: make progspace::exec_filename private, add getter / setterSimon Marchi1-1/+1
Just like the title says... I think this makes things a bit clearer, for instance where the exec filename is set. It also makes the read call sites a bit nicer, avoiding the `.get ()`. Change-Id: If8b58ae8f6270c8a34b868f6ca06128c6671ea3c Approved-By: Tom Tromey <tom@tromey.com>
2024-06-06DAP: Handle "stepOut" request in outermost frameJohan Sternerup1-2/+2
Previously a "stepOut" request when in the outermost frame would result in a sucessful response even though gdb internally would reject the associated "finish" request, which means no stoppedEvent would ever be sent back to the client. Thus the client would believe the inferior was still running and as a consequence reject subsequent "next" and "stepIn" requests from the user. The solution is to execute the underlying finish command as a background command, i.e. `finish &`. If we're in the outermost frame an exception will be raised immediately, which we can now capture and report back to the client as success=False so then the absence of a `stopped` event is no longer a problem. We also make use of the `defer_stop_event` option to prevent a stop event from reaching the client until the response has been sent. Approved-By: Tom Tromey <tom@tromey.com>
2024-06-06DAP: Allow gdb exception in exec_and_log to propagateJohan Sternerup2-5/+8
This allows a request to specify that any gdb exception raised in exec_and_log within the gdb thread to be propagated back to the DAP thread (using the Canceller object as the orchestrator). Approved-By: Tom Tromey <tom@tromey.com>
2024-06-06DAP: Allow for deferring stop events from gdb threadJohan Sternerup2-7/+51
The existing `send_event_later()` method allows commands processed on the DAP thread to queue an event for execution until after the response has been sent to the client. We now introduce a corresponding method for use by the gdb thread. This method `send_event_maybe_later()` will queue the event just like `send_event_later()`, but only if it has been configured to do so by a new @request option `defer_stop_events`. As the name implies the functionality is currently only used for handling stop events. Approved-By: Tom Tromey <tom@tromey.com>
2024-06-04Return global scope from DAP scopes requestTom Tromey2-0/+101
A co-worker requested that the DAP code emit a scope for global variables. It's not really practical to do this for all globals, but it seemed reasonable to do this for globals coming from the frame's compilation unit. For Ada in particular, this is convenient as it exposes package-scoped variables. Reviewed-By: Eli Zaretskii <eliz@gnu.org>
2024-06-04Convert DAP disassemble code to use Block hashingTom Tromey1-4/+3
This changes the DAP disassemble code to use the new Block hashing, storing the already-visited blocks in a set rather than a list.
2024-06-04Memoize gdb.Block and make them hashableTom Tromey1-64/+79
In subsequent patches, it's handy if gdb.Block is hashable, so it can be stored in a set or a dictionary. However, doing this in a straightforward way is not really possible, because a block isn't truly immutable -- it can be invalidated. And, while this isn't a real problem for my use case (in DAP the maps are only used during a single stop), it seemed error-prone. This patch instead takes the approach of using the gdb.Block's own object identity to allow hashing. This seems fine because the contents don't affect the hashing. In order for this to work, though, the blocks have to be memoized -- two requests for the same block must return the same object. This also allows (actually, requires) the simplification of the rich-compare method for blocks. Reviewed-By: Alexandra Petlanova Hajkova <ahajkova@redhat.com>
2024-06-04Put "source" into DAP scopeTom Tromey1-1/+4
I noticed a FIXME comment in the DAP code about adding a "source" field to a scope. This is easy to implement; I don't know why I didn't do this originally.
2024-06-03Enable call of overloaded subscript operator from pythonHannes Domani1-1/+5
If you try to use the overloaded subscript operator of a class in python, it fails like this: (gdb) py print(gdb.parse_and_eval('b')[5]) Traceback (most recent call last): File "<string>", line 1, in <module> gdb.error: Cannot subscript requested type. Error while executing Python code. This simply checks if such an operator exists, and calls it instead, making this possible: (gdb) py print(gdb.parse_and_eval('b')[5]) 102 'f' Approved-By: Tom Tromey <tom@tromey.com>
2024-06-03Allow calling of convenience functions with pythonHannes Domani1-5/+13
As mentioned in PR13326, currently when you try to call a convenience function with python, you get this error: (gdb) py print(gdb.convenience_variable("_isvoid")(3)) Traceback (most recent call last): File "<string>", line 1, in <module> RuntimeError: Value is not callable (not TYPE_CODE_FUNC or TYPE_CODE_METHOD). Error while executing Python code. So this extends valpy_call to handle TYPE_CODE_INTERNAL_FUNCTION as well, making this possible: (gdb) py print(gdb.convenience_variable("_isvoid")(3)) 0 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=13326 Approved-By: Tom Tromey <tom@tromey.com>
2024-05-17Don't allow new-ui to start the TUITom Tromey1-0/+3
The TUI can't really work properly with new-ui, at least not as currently written. This patch changes new-ui to reject an attempt. Attempting to make a DAP ui this way is also now rejected. Regression tested on x86-64 Fedora 38. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29273 Approved-By: Andrew Burgess <aburgess@redhat.com>
2024-05-10Add symbol, line, and location to DAP disassemble resultTom Tromey1-7/+52
The DAP spec allows a number of attributes on the resulting instructions that gdb currently does not emit. A user requested some of these, so this patch adds the 'symbol', 'line', and 'location' attributes. While the spec lets the implementation omit 'location' in some cases, it was simpler in the code to just always emit it, as then no extra tracking was needed.
2024-05-10Implement tp_richcompare for gdb.BlockTom Tromey1-1/+23
I noticed that two gdb.Block objects will never compare as equal with '=='. This patch fixes the problem by implementing tp_richcompare, as was done for gdb.Frame.
2024-05-10Simplify DAP make_source callersTom Tromey3-7/+8
A couple callers of make_source call basename by hand. Rather than add another caller like this, I thought it would be better to put this ability into make_source itself.
2024-05-10Remove FIXME from DAPTom Tromey1-1/+0
This patch removes one of the few DAP "FIXME" comments. This particular comment is already covered by PR dap/31036.
2024-05-10[gdb/python] Make gdb.UnwindInfo.add_saved_register more robust (fixup)Tom de Vries1-9/+17
In commit 2236c5e384d ("[gdb/python] Make gdb.UnwindInfo.add_saved_register more robust") I added this code in unwind_infopy_add_saved_register: ... if (value->optimized_out () || !value->entirely_available ()) ... which may throw c++ exceptions. This needs to be caught and transformed into a python exception. Fix this by using GDB_PY_HANDLE_EXCEPTION. Tested on x86_64-linux. Approved-By: Tom Tromey <tom@tromey.com> Fixes: 2236c5e384d ("[gdb/python] Make gdb.UnwindInfo.add_saved_register more robust")
2024-05-08[gdb/python] Make gdb.UnwindInfo.add_saved_register more robustTom de Vries1-0/+12
On arm-linux, until commit bbb12eb9c84 ("gdb/arm: Remove tpidruro register from non-FreeBSD target descriptions") I ran into: ... FAIL: gdb.base/inline-frame-cycle-unwind.exp: cycle at level 5: \ backtrace when the unwind is broken at frame 5 ... What happens is the following: - the TestUnwinder from inline-frame-cycle-unwind.py calls gdb.UnwindInfo.add_saved_register with reg == tpidruro and value "<unavailable>", - pyuw_sniffer calls value->contents ().data () to access the value of the register, which throws an UNAVAILABLE_ERROR, - this causes the TestUnwinder unwinder to fail, after which another unwinder succeeds and returns the correct frame, and - the test-case fails because it's counting on the TestUnwinder to succeed and return an incorrect frame. Fix this by checking for !value::entirely_available as well as valued::optimized_out in unwind_infopy_add_saved_register. Tested on x86_64-linux and arm-linux. Approved-By: Andrew Burgess <aburgess@redhat.com> PR python/31437 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31437
2024-04-25gdb: remove gdbcmd.hSimon Marchi8-8/+8
Most files including gdbcmd.h currently rely on it to access things actually declared in cli/cli-cmds.h (setlist, showlist, etc). To make things easy, replace all includes of gdbcmd.h with includes of cli/cli-cmds.h. This might lead to some unused includes of cli/cli-cmds.h, but it's harmless, and much faster than going through the 170 or so files by hand. Change-Id: I11f884d4d616c12c05f395c98bbc2892950fb00f Approved-By: Tom Tromey <tom@tromey.com>
2024-04-23gdb: change return type of check_quit_flag to boolSimon Marchi1-3/+3
Change the return type of the check_quit_flag function to bool. Update a few related spots. Change-Id: I9d3a15d3f8651efb02c7d211f06222a592bd4184 Approved-By: Tom Tromey <tom@tromey.com>
2024-04-16[gdb/python] Throw MemoryError in inferior.read_memory if malloc failsTom de Vries2-3/+17
PR python/31631 reports a gdb internal error when doing: ... (gdb) python gdb.selected_inferior().read_memory (0, 0xffffffffffffffff) utils.c:709: internal-error: virtual memory exhausted. A problem internal to GDB has been detected, further debugging may prove unreliable. ... Fix this by throwing a python MemoryError, such that we have instead: ... (gdb) python gdb.selected_inferior().read_memory (0, 0xffffffffffffffff) Python Exception <class 'MemoryError'>: Error occurred in Python. (gdb) ... Likewise for DAP. Tested on x86_64-linux. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31631
2024-04-02Run isortTom Tromey33-65/+77
This patch is the result of running 'isort .' in the gdb directory. Approved-By: Simon Marchi <simon.marchi@efficios.com>