aboutsummaryrefslogtreecommitdiff
path: root/gdb/mi/mi-cmds.h
AgeCommit message (Collapse)AuthorFilesLines
2023-05-25Make MI commands const-correctTom Tromey1-1/+2
I've had this patch for a while now and figured I'd update it and send it. It changes MI commands to use a "const char * const" for their argv parameter. Regression tested on x86-64 Fedora 36. Acked-By: Simon Marchi <simon.marchi@efficios.com>
2023-05-23Implement gdb.execute_miTom Tromey1-0/+5
This adds a new Python function, gdb.execute_mi, that can be used to invoke an MI command but get the output as a Python object, rather than a string. This is done by implementing a new ui_out subclass that builds a Python object. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=11688 Reviewed-By: Eli Zaretskii <eliz@gnu.org>
2023-05-04Don't treat references to compound values as "simple".Gareth Rees1-0/+5
SUMMARY The '--simple-values' argument to '-stack-list-arguments' and similar GDB/MI commands does not take reference types into account, so that references to arbitrarily large structures are considered "simple" and printed. This means that the '--simple-values' argument cannot be used by IDEs when tracing the stack due to the time taken to print large structures passed by reference. DETAILS Various GDB/MI commands ('-stack-list-arguments', '-stack-list-locals', '-stack-list-variables' and so on) take a PRINT-VALUES argument which may be '--no-values' (0), '--all-values' (1) or '--simple-values' (2). In the '--simple-values' case, the command is supposed to print the name, type, and value of variables with simple types, and print only the name and type of variables with compound types. The '--simple-values' argument ought to be suitable for IDEs that need to update their user interface with the program's call stack every time the program stops. However, it does not take C++ reference types into account, and this makes the argument unsuitable for this purpose. For example, consider the following C++ program: struct s { int v[10]; }; int sum(const struct s &s) { int total = 0; for (int i = 0; i < 10; ++i) total += s.v[i]; return total; } int main(void) { struct s s = { { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 } }; return sum(s); } If we start GDB in MI mode and continue to 'sum', the behaviour of '-stack-list-arguments' is as follows: (gdb) -stack-list-arguments --simple-values ^done,stack-args=[frame={level="0",args=[{name="s",type="const s &",value="@0x7fffffffe310: {v = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}}"}]},frame={level="1",args=[]}] Note that the value of the argument 's' was printed, even though 's' is a reference to a structure, which is not a simple value. See https://github.com/microsoft/MIEngine/pull/673 for a case where this behaviour caused Microsoft to avoid the use of '--simple-values' in their MIEngine debug adapter, because it caused Visual Studio Code to take too long to refresh the call stack in the user interface. SOLUTIONS There are two ways we could fix this problem, depending on whether we consider the current behaviour to be a bug. 1. If the current behaviour is a bug, then we can update the behaviour of '--simple-values' so that it takes reference types into account: that is, a value is simple if it is neither an array, struct, or union, nor a reference to an array, struct or union. In this case we must add a feature to the '-list-features' command so that IDEs can detect that it is safe to use the '--simple-values' argument when refreshing the call stack. 2. If the current behaviour is not a bug, then we can add a new option for the PRINT-VALUES argument, for example, '--scalar-values' (3), that would be suitable for use by IDEs. In this case we must add a feature to the '-list-features' command so that IDEs can detect that the '--scalar-values' argument is available for use when refreshing the call stack. PATCH This patch implements solution (1) as I think the current behaviour of not printing structures, but printing references to structures, is contrary to reasonable expectation. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29554
2023-01-01Update copyright year range in header of all files managed by GDBJoel Brobecker1-1/+1
This commit is the result of running the gdb/copyright.py script, which automated the update of the copyright year range for all source files managed by the GDB project to be updated to include year 2023.
2022-03-18gdb/python: remove gdb._mi_commands dictSimon Marchi1-0/+7
The motivation for this patch is the fact that py-micmd.c doesn't build with Python 2, due to PyDict_GetItemWithError being a Python 3-only function: CXX python/py-micmd.o /home/smarchi/src/binutils-gdb/gdb/python/py-micmd.c: In function ‘int micmdpy_uninstall_command(micmdpy_object*)’: /home/smarchi/src/binutils-gdb/gdb/python/py-micmd.c:430:20: error: ‘PyDict_GetItemWithError’ was not declared in this scope; did you mean ‘PyDict_GetItemString’? 430 | PyObject *curr = PyDict_GetItemWithError (mi_cmd_dict.get (), | ^~~~~~~~~~~~~~~~~~~~~~~ | PyDict_GetItemString A first solution to fix this would be to try to replace PyDict_GetItemWithError equivalent Python 2 code. But I looked at why we are doing this in the first place: it is to maintain the `gdb._mi_commands` Python dictionary that we use as a `name -> gdb.MICommand object` map. Since the `gdb._mi_commands` dictionary is never actually used in Python, it seems like a lot of trouble to use a Python object for this. My first idea was to replace it with a C++ map (std::unordered_map<std::string, gdbpy_ref<micmdpy_object>>). While implementing this, I realized we don't really need this map at all. The mi_command_py objects registered in the main MI command table can own their backing micmdpy_object (that's a gdb.MICommand, but seen from the C++ code). To know whether an mi_command is an mi_command_py, we can use a dynamic cast. Since there's one less data structure to maintain, there are less chances of messing things up. - Change mi_command_py::m_pyobj to a gdbpy_ref, the mi_command_py is now what keeps the MICommand alive. - Set micmdpy_object::mi_command in the constructor of mi_command_py. If mi_command_py manages setting/clearing that field in swap_python_object, I think it makes sense that it also takes care of setting it initially. - Move a bunch of checks from micmdpy_install_command to swap_python_object, and make them gdb_asserts. - In micmdpy_install_command, start by doing an mi_cmd_lookup. This is needed to know whether there's a Python MI command already registered with that name. But we can already tell if there's a non-Python command registered with that name. Return an error if that happens, rather than waiting for insert_mi_cmd_entry to fail. Change the error message to "name is already in use" rather than "may already be in use", since it's more precise. I asked Andrew about the original intent of using a Python dictionary object to hold the command objects. The reason was to make sure the objects get destroyed when the Python runtime gets finalized, not later. Holding the objects in global C++ data structures and not doing anything more means that the held Python objects will be decref'd after the Python interpreter has been finalized. That's not desirable. I tried it and it indeed segfaults. Handle this by adding a gdbpy_finalize_micommands function called in finalize_python. This is the mirror of gdbpy_initialize_micommands called in do_start_initialization. In there, delete all Python MI commands. I think it makes sense to do it this way: if it was somehow possible to unload Python support from GDB in the middle of a session we'd want to unregister any Python MI command. Otherwise, these MI commands would be backed with a stale PyObject or simply nothing. Delete tests that were related to `gdb._mi_commands`. Co-Authored-By: Andrew Burgess <aburgess@redhat.com> Change-Id: I060d5ebc7a096c67487998a8a4ca1e8e56f12cd3
2022-03-16gdb/mi: consistently notify user when GDB/MI client uses -thread-selectJan Vrany1-11/+6
GDB notifies users about user selected thread changes somewhat inconsistently as mentioned on gdb-patches mailing list here: https://sourceware.org/pipermail/gdb-patches/2022-February/185989.html Consider GDB debugging a multi-threaded inferior with both CLI and GDB/MI interfaces connected to separate terminals. Assuming inferior is stopped and thread 1 is selected, when a thread 2 is selected using '-thread-select 2' command on GDB/MI terminal: -thread-select 2 ^done,new-thread-id="2",frame={level="0",addr="0x00005555555551cd",func="child_sub_function",args=[],file="/home/jv/Projects/gdb/users_jv_patches/gdb/testsuite/gdb.mi/user-selected-context-sync.c",fullname="/home/uuu/gdb/gdb/testsuite/gdb.mi/user-selected-context-sync.c",line="30",arch="i386:x86-64"} (gdb) and on CLI terminal we get the notification (as expected): [Switching to thread 2 (Thread 0x7ffff7daa640 (LWP 389659))] #0 child_sub_function () at /home/uuu/gdb/gdb/testsuite/gdb.mi/user-selected-context-sync.c:30 30 volatile int dummy = 0; However, now that thread 2 is selected, if thread 1 is selected using 'thread-select --thread 1 1' command on GDB/MI terminal terminal: -thread-select --thread 1 1 ^done,new-thread-id="1",frame={level="0",addr="0x0000555555555294",func="main",args=[],file="/home/jv/Projects/gdb/users_jv_patches/gdb/testsuite/gdb.mi/user-selected-context-sync.c",fullname="/home/jv/Projects/gdb/users_jv_patches/gdb/testsuite/gdb.mi/user-selected-context-sync.c",line="66",arch="i386:x86-64"} (gdb) but no notification is printed on CLI terminal, despite the fact that user selected thread has changed. The problem is that when `-thread-select --thread 1 1` is executed then thread is switched to thread 1 before mi_cmd_thread_select () is called, therefore the condition "inferior_ptid != previous_ptid" there does not hold. To address this problem, we have to move notification logic up to mi_cmd_execute () where --thread option is processed and notify user selected contents observers there if context changes. However, this in itself breaks GDB/MI because it would cause context notification to be sent on MI channel. This is because by the time we notify, MI notification suppression is already restored (done in mi_command::invoke(). Therefore we had to lift notification suppression logic also up to mi_cmd_execute (). This change in made distinction between mi_command::invoke() and mi_command::do_invoke() unnecessary as all mi_command::invoke() did (after the change) was to call do_invoke(). So this patches removes do_invoke() and moves the command execution logic directly to invoke(). With this change, all gdb.mi tests pass, tested on x86_64-linux. Co-authored-by: Andrew Burgess <aburgess@redhat.com> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=20631
2022-03-14gdb/python/mi: create MI commands using pythonAndrew Burgess1-0/+18
This commit allows a user to create custom MI commands using Python similarly to what is possible for Python CLI commands. A new subclass of mi_command is defined for Python MI commands, mi_command_py. A new file, gdb/python/py-micmd.c contains the logic for Python MI commands. This commit is based on work linked too from this mailing list thread: https://sourceware.org/pipermail/gdb/2021-November/049774.html Which has also been previously posted to the mailing list here: https://sourceware.org/pipermail/gdb-patches/2019-May/158010.html And was recently reposted here: https://sourceware.org/pipermail/gdb-patches/2022-January/185190.html The version in this patch takes some core code from the previously posted patches, but also has some significant differences, especially after the feedback given here: https://sourceware.org/pipermail/gdb-patches/2022-February/185767.html A new MI command can be implemented in Python like this: class echo_args(gdb.MICommand): def invoke(self, args): return { 'args': args } echo_args("-echo-args") The 'args' parameter (to the invoke method) is a list containing (almost) all command line arguments passed to the MI command (--thread and --frame are handled before the Python code is called, and removed from the args list). This list can be empty if the MI command was passed no arguments. When used within gdb the above command produced output like this: (gdb) -echo-args a b c ^done,args=["a","b","c"] (gdb) The 'invoke' method of the new command must return a dictionary. The keys of this dictionary are then used as the field names in the mi command output (e.g. 'args' in the above). The values of the result returned by invoke can be dictionaries, lists, iterators, or an object that can be converted to a string. These are processed recursively to create the mi output. And so, this is valid: class new_command(gdb.MICommand): def invoke(self,args): return { 'result_one': { 'abc': 123, 'def': 'Hello' }, 'result_two': [ { 'a': 1, 'b': 2 }, { 'c': 3, 'd': 4 } ] } Which produces output like: (gdb) -new-command ^done,result_one={abc="123",def="Hello"},result_two=[{a="1",b="2"},{c="3",d="4"}] (gdb) I have required that the fields names used in mi result output must match the regexp: "^[a-zA-Z][-_a-zA-Z0-9]*$" (without the quotes). This restriction was never written down anywhere before, but seems sensible to me, and we can always loosen this rule later if it proves to be a problem. Much harder to try and add a restriction later, once people are already using the API. What follows are some details about how this implementation differs from the original patch that was posted to the mailing list. In this patch, I have changed how the lifetime of the Python gdb.MICommand objects is managed. In the original patch, these object were kept alive by an owned reference within the mi_command_py object. As such, the Python object would not be deleted until the mi_command_py object itself was deleted. This caused a problem, the mi_command_py were held in the global mi command table (in mi/mi-cmds.c), which, as a global, was not cleared until program shutdown. By this point the Python interpreter has already been shutdown. Attempting to delete the mi_command_py object at this point was causing GDB to try and invoke Python code after finalising the Python interpreter, and we would crash. To work around this problem, the original patch added code in python/python.c that would search the mi command table, and delete the mi_command_py objects before the Python environment was finalised. In contrast, in this patch, I have added a new global dictionary to the gdb module, gdb._mi_commands. We already have several such global data stores related to pretty printers, and frame unwinders. The MICommand objects are placed into the new gdb.mi_commands dictionary, and it is this reference that keeps the objects alive. When GDB's Python interpreter is shut down gdb._mi_commands is deleted, and any MICommand objects within it are deleted at this point. This change avoids having to make the mi_cmd_table global, and walk over it from within GDB's python related code. This patch handles command redefinition entirely within GDB's python code, though this does impose one small restriction which is not present in the original code (detailed below), I don't think this is a big issue. However, the original patch relied on being able to finish executing the mi_command::do_invoke member function after the mi_command object had been deleted. Though continuing to execute a member function after an object is deleted is well defined, it is also (IMHO) risky, its too easy for someone to later add a use of the object without realising that the object might sometimes, have been deleted. The new patch avoids this issue. The one restriction that is added to avoid this, is that an MICommand object can't be reinitialised with a different command name, so: (gdb) python cmd = MyMICommand("-abc") (gdb) python cmd.__init__("-def") can't reinitialize object with a different command name This feels like a pretty weird edge case, and I'm happy to live with this restriction. I have also changed how the memory is managed for the command name. In the most recently posted patch series, the command name is moved into a subclass of mi_command, the python mi_command_py, which inherits from mi_command is then free to use a smart pointer to manage the memory for the name. In this patch, I leave the mi_command class unchanged, and instead hold the memory for the name within the Python object, as the lifetime of the Python object always exceeds the c++ object stored in the mi_cmd_table. This adds a little more complexity in py-micmd.c, but leaves the mi_command class nice and simple. Next, this patch adds some extra functionality, there's a MICommand.name read-only attribute containing the name of the command, and a read-write MICommand.installed attribute that can be used to install (make the command available for use) and uninstall (remove the command from the mi_cmd_table so it can't be used) the command. This attribute will be automatically updated if a second command replaces an earlier command. This patch adds additional error handling, and makes more use the gdbpy_handle_exception function. Co-Authored-By: Jan Vrany <jan.vrany@labware.com>
2022-03-08gdb/mi: preserve user selected thread and frame when invoking MI commandsJan Vrany1-0/+12
Fix for PR gdb/20684. When invoking MI commands with --thread and/or --frame, the user selected thread and frame was not preserved: (gdb) info thread &"info thread\n" ~" Id Target Id Frame \n" ~"* 1 Thread 0x7ffff7c30740 (LWP 19302) \"user-selected-c\" main () at /home/uuu/gdb/gdb/testsuite/gdb.mi/user-selected-context-sync.c:60\n" ~" 2 Thread 0x7ffff7c2f700 (LWP 19306) \"user-selected-c\" child_sub_function () at /home/uuu/gdb/gdb/testsuite/gdb.mi/user-selected-context-sync.c:30\n" ~" 3 Thread 0x7ffff742e700 (LWP 19307) \"user-selected-c\" child_sub_function () at /home/uuu/gdb/gdb/testsuite/gdb.mi/user-selected-context-sync.c:30\n" ^done (gdb) info frame &"info frame\n" ~"Stack level 0, frame at 0x7fffffffdf90:\n" ~" rip = 0x555555555207 in main (/home/uuu/gdb/gdb/testsuite/gdb.mi/user-selected-context-sync.c:60); saved rip = 0x7ffff7c5709b\n" ~" source language c.\n" ~" Arglist at 0x7fffffffdf80, args: \n" ~" Locals at 0x7fffffffdf80, Previous frame's sp is 0x7fffffffdf90\n" ~" Saved registers:\n " ~" rbp at 0x7fffffffdf80, rip at 0x7fffffffdf88\n" ^done (gdb) -stack-info-depth --thread 3 ^done,depth="4" (gdb) info thread &"info thread\n" ~" Id Target Id Frame \n" ~" 1 Thread 0x7ffff7c30740 (LWP 19302) \"user-selected-c\" main () at /home/uuu/gdb/gdb/testsuite/gdb.mi/user-selected-context-sync.c:60\n" ~" 2 Thread 0x7ffff7c2f700 (LWP 19306) \"user-selected-c\" child_sub_function () at /home/uuu/gdb/gdb/testsuite/gdb.mi/user-selected-context-sync.c:30\n" ~"* 3 Thread 0x7ffff742e700 (LWP 19307) \"user-selected-c\" child_sub_function () at /home/uuu/gdb/gdb/testsuite/gdb.mi/user-selected-context-sync.c:30\n" ^done (gdb) info frame &"info frame\n" ~"Stack level 0, frame at 0x7ffff742dee0:\n" ~" rip = 0x555555555169 in child_sub_function (/home/uuu/gdb/gdb/testsuite/gdb.mi/user-selected-context-sync.c:30); saved rip = 0x555555555188\n" ~" called by frame at 0x7ffff742df00\n" ~" source language c.\n" ~" Arglist at 0x7ffff742ded0, args: \n" ~" Locals at 0x7ffff742ded0, Previous frame's sp is 0x7ffff742dee0\n" ~" Saved registers:\n " ~" rbp at 0x7ffff742ded0, rip at 0x7ffff742ded8\n" ^done (gdb) This caused problems for frontends that provide access to CLI because UI may silently change the context for CLI commands (as demonstrated above). This commit fixes the problem by restoring thread and frame in mi_cmd_execute (). With this change, there are only two GDB/MI commands that can change user selected context: -thread-select and -stack-select-frame. This allows us to remove all and rather complicated logic of notifying about user selected context change from mi_execute_command (), leaving it to these two commands themselves to notify. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=20684
2022-01-01Automatic Copyright Year update after running gdb/copyright.pyJoel Brobecker1-1/+1
This commit brings all the changes made by running gdb/copyright.py as per GDB's Start of New Year Procedure. For the avoidance of doubt, all changes in this commits were performed by the script.
2021-12-29Use gdb_stdlog for MI debuggingTom Tromey1-3/+0
When MI debugging is enabled, the logging output should be sent to gdb_stdlog. This is part of PR gdb/7233. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=7233
2021-12-14gdb/mi: rename mi_cmd to mi_commandJan Vrany1-4/+4
Just give this class a new name, more inline with the name of the sub-classes. I've also updated mi_cmd_up to mi_command_up in mi-cmds.c inline with this new naming scheme. There should be no user visible changes after this commit.
2021-12-14gdb/mi: use separate classes for different types of MI commandJan Vrany1-23/+46
This commit changes the infrastructure in mi-cmds.{c,h} to add new sub-classes for the different types of MI command. Instances of these sub-classes are then created and added into mi_cmd_table. The existing mi_cmd class becomes the abstract base class, this has an invoke method and takes care of the suppress notifications handling, before calling a do_invoke virtual method which is implemented by all of the sub-classes. There's currently two different sub-classes, one of pure MI commands, and a second for MI commands that delegate to CLI commands. There should be no user visible changes after this commit.
2021-12-14gdb/mi: rename mi_lookup to mi_cmd_lookupJan Vrany1-2/+3
Lets give this function a more descriptive name. I've also improved the comments in the header and source files. There should be no user visible changes after this commit.
2021-05-06gdb/mi: add a '--force' flag to the '-break-condition' commandTankut Baris Aktemur1-0/+1
Add a '--force' flag to the '-break-condition' command to be able to force conditions. gdb/ChangeLog: 2021-05-06 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * mi/mi-cmd-break.c (mi_cmd_break_condition): New function. * mi/mi-cmds.c: Change the binding of "-break-condition" to mi_cmd_break_condition. * mi/mi-cmds.h (mi_cmd_break_condition): Declare. * breakpoint.h (set_breakpoint_condition): Declare a new overload. * breakpoint.c (set_breakpoint_condition): New overloaded function extracted out from ... (condition_command): ... this. * NEWS: Mention the change. gdb/testsuite/ChangeLog: 2021-05-06 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * gdb.mi/mi-break.exp (test_forced_conditions): Add a test for the -break-condition command's "--force" flag. gdb/doc/ChangeLog: 2021-05-06 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * gdb.texinfo (GDB/MI Breakpoint Commands): Mention the '--force' flag of the '-break-condition' command.
2021-01-01Update copyright year range in all GDB filesJoel Brobecker1-1/+1
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-01-01Update copyright year range in all GDB files.Joel Brobecker1-1/+1
gdb/ChangeLog: Update copyright year range in all GDB files.
2019-12-04gdb/mi: Add -symbol-info-module-{variables,functions}Andrew Burgess1-0/+2
Two new MI command -symbol-info-module-variables and -symbol-info-module-functions, which are the equivalent of the CLI command 'info module variables' and 'info module functions'. These return information about functions and variables within Fortran modules. gdb/ChangeLog: * mi/mi-cmds.c (mi_cmds): Add -symbol-info-module-functions and -symbol-info-module-variables entries. * mi/mi-cmds.h (mi_cmd_symbol_info_module_functions): Declare. (mi_cmd_symbol_info_module_variables): Declare. * mi/mi-symbol-cmds.c (module_symbol_search_iterator): New typedef. (output_module_symbols_in_single_module_and_file): New function. (output_module_symbols_in_single_module): New function. (mi_info_module_functions_or_variables): New function. (mi_cmd_symbol_info_module_functions): New function. (mi_cmd_symbol_info_module_variables): New function. * NEWS: Mention new MI command. gdb/doc/ChangeLog: * doc/gdb.texinfo (GDB/MI Symbol Query): Document new MI command -symbol-info-module-functions and -symbol-info-module-variables. gdb/testsuite/ChangeLog: * gdb.mi/mi-fortran-modules.exp: Add additional tests for -symbol-info-module-functions and -symbol-info-module-variables. Change-Id: Ic96f12dd14bd7e34774c3cde008fec30a4055bfe
2019-11-27gdb/mi: Add -symbol-info-modules commandAndrew Burgess1-0/+1
Add '-symbol-info-modules', an MI version of the CLI 'info modules' command. gdb/ChangeLog: * mi/mi-cmds.c (mi_cmds): Add 'symbol-info-modules' entry. * mi/mi-cmds.h (mi_cmd_symbol_info_modules): Declare. * mi/mi-symbol-cmds.c (mi_cmd_symbol_info_modules): New function. * NEWS: Mention new MI command. gdb/testsuite/ChangeLog: * gdb.mi/mi-fortran-modules-2.f90: New file. * gdb.mi/mi-fortran-modules.exp: New file. * gdb.mi/mi-fortran-modules.f90: New file. gdb/doc/ChangeLog: * doc/gdb.texinfo (GDB/MI Symbol Query): Document new MI command -symbol-info-modules. Change-Id: Ibc618010d1d5f36ae8a8baba4fb9d9d724e62b0f
2019-11-27gdb/mi: Add new commands -symbol-info-{functions,variables,types}Andrew Burgess1-0/+3
Add new MI commands -symbol-info-functions, -symbol-info-variables, and -symbol-info-types which correspond to the CLI commands 'info functions', 'info variables', and 'info types' respectively. gdb/ChangeLog: * mi/mi-cmds.c (mi_cmds): Add '-symbol-info-functions', '-symbol-info-types', and '-symbol-info-variables'. * mi/mi-cmds.h (mi_cmd_symbol_info_functions): Declare. (mi_cmd_symbol_info_types): Declare. (mi_cmd_symbol_info_variables): Declare. * mi/mi-symbol-cmds.c: Add 'source.h' and 'mi-getopt.h' includes. (output_debug_symbol): New function. (output_nondebug_symbol): New function. (mi_symbol_info): New function. (mi_info_functions_or_variables): New function. (mi_cmd_symbol_info_functions): New function. (mi_cmd_symbol_info_types): New function. (mi_cmd_symbol_info_variables): New function. * NEWS: Mention new commands. gdb/testsuite/ChangeLog: * gdb.mi/mi-sym-info-1.c: New file. * gdb.mi/mi-sym-info-2.c: New file. * gdb.mi/mi-sym-info.exp: New file. gdb/doc/ChangeLog: * doc/gdb.texinfo (GDB/MI Symbol Query): Document new MI command -symbol-info-functions, -symbol-info-types, and -symbol-info-variables. Change-Id: Ic2fc6a6750bbce91cdde2344791014e5ef45642d
2019-06-15gdb/mi: New commands to catch C++ exceptionsAndrew Burgess1-0/+3
Adds some MI commands to catch C++ exceptions. The new commands are -catch-throw, -catch-rethrow, and -catch-catch, these all correspond to the CLI commands 'catch throw', 'catch rethrow', and 'catch catch'. Each MI command takes two optional arguments, '-t' has the effect of calling 'tcatch' instead of 'catch', for example: (gdb) -catch-throw -t Is the same as: (gdb) tcatch throw There is also a '-r REGEXP' argument that can supply a regexp to match against the exception type, so: (gdb) -catch-catch -r PATTERN Is the same as: (gdb) catch catch PATTERN The change in print_mention_exception_catchpoint might seem a little strange; changing the output from using ui_out::field_int and ui_out::text to using ui_out::message. The print_mention_exception_catchpoint is used as the 'print_mention' method for the exception catchpoint breakpoint object. Most of the other 'print_mention' methods (see breakpoint.c) use either printf_filtered, of ui_out::message. Using field_int was causing an unexpected field to be added to the MI output. Here's the output without the change in print_mention_exception_catchpoint: (gdb) -catch-throw ^done,bkptno="1",bkpt={number="1",type="breakpoint",disp="keep", enabled="y",addr="0x00000000004006c0", what="exception throw",catch-type="throw", thread-groups=["i1"],times="0"} Notice the breakpoint number appears in both the 'bkptno' field, and the 'number' field within the 'bkpt' tuple. Here's the output with the change in print_mention_exception_catchpoint: (gdb) -catch-throw ^done,bkpt={number="1",type="breakpoint",disp="keep", enabled="y",addr="0x00000000004006c0", what="exception throw",catch-type="throw", thread-groups=["i1"],times="0"} gdb/ChangeLog: * NEWS: Mention new MI commands. * break-catch-throw.c (enum exception_event_kind): Move to breakpoint.h. (print_mention_exception_catchpoint): Output text as a single message. (catch_exception_command_1): Rename to... (catch_exception_event): ...this, make non-static, update header command, and change some parameter types. (catch_catch_command): Update for changes to catch_exception_command_1. (catch_throw_command): Likewise. (catch_rethrow_command): Likewise. * breakpoint.c (enum exception_event_kind): Delete. * breakpoint.h (enum exception_event_kind): Moved here from break-catch-throw.c. (catch_exception_event): Declare. * mi/mi-cmd-catch.c (mi_cmd_catch_exception_event): New function. (mi_cmd_catch_throw): New function. (mi_cmd_catch_rethrow): New function. (mi_cmd_catch_catch): New function. * mi/mi-cmds.c (mi_cmds): Add 'catch-throw', 'catch-rethrow', and 'catch-catch' entries. * mi/mi-cmds.h (mi_cmd_catch_throw): Declare. (mi_cmd_catch_rethrow): Declare. (mi_cmd_catch_catch): Declare. gdb/doc/ChangeLog: * gdb.texinfo (GDB/MI Catchpoint Commands): Add menu entry to new node. (C++ Exception GDB/MI Catchpoint Commands): New node to describe new MI commands. gdb/testsuite/ChangeLog: * gdb.mi/mi-catch-cpp-exceptions.cc: New file. * gdb.mi/mi-catch-cpp-exceptions.exp: New file. * lib/mi-support.exp (mi_expect_stop): Handle 'exception-caught' as a stop reason.
2019-05-17MI: Add new command -completeJan Vrany1-0/+1
There is a CLI command 'complete' intended to use with emacs. Such a command would also be useful for MI frontends, when separate CLI and MI channels cannot be used. For example, on Windows (because of lack of PTYs) or when GDB is used through SSH session. This commit adds a new '-complete' MI command. gdb/Changelog: 2019-01-28 Jan Vrany <jan.vrany@fit.cvut.cz> * mi/mi-cmds.h (mi_cmd_complete): New function. * mi/mi-main.c (mi_cmd_complete): Likewise. * mi/mi-cmds.c: Define new MI command -complete. * NEWS: Mention new -complete command. gdb/doc/ChangeLog: 2019-01-28 Jan Vrany <jan.vrany@fit.cvut.cz> * gdb.texinfo (Miscellaneous GDB/MI Commands): Document new MI command -complete. gdb/testsuite/ChangeLog: 2019-01-28 Jan Vrany <jan.vrany@fit.cvut.cz> * gdb.mi/mi-complete.exp: New file. * gdb.mi/mi-complete.cc: Likewise.
2019-02-07Normalize include guards in gdbTom Tromey1-3/+3
While working on my other scripts to deal with gdb headers, I noticed that some files were missing include guards. I wrote a script to add the missing ones, but found that using the obvious names for the guards ran into clashes -- for example, gdb/nat/linux-nat.h used "LINUX_NAT_H", but this was also the script's choice for gdb/linux-nat.h. So, I changed the script to normalize all include guards in gdb. This patch is the result. As usual the script is available here: https://github.com/tromey/gdb-refactoring-scripts Tested by rebuilding; I also ran it through "Fedora-x86_64-m64" on the buildbot. gdb/ChangeLog 2019-02-07 Tom Tromey <tom@tromey.com> * yy-remap.h: Add include guard. * xtensa-tdep.h: Add include guard. * xcoffread.h: Rename include guard. * varobj-iter.h: Add include guard. * tui/tui.h: Rename include guard. * tui/tui-winsource.h: Rename include guard. * tui/tui-wingeneral.h: Rename include guard. * tui/tui-windata.h: Rename include guard. * tui/tui-win.h: Rename include guard. * tui/tui-stack.h: Rename include guard. * tui/tui-source.h: Rename include guard. * tui/tui-regs.h: Rename include guard. * tui/tui-out.h: Rename include guard. * tui/tui-layout.h: Rename include guard. * tui/tui-io.h: Rename include guard. * tui/tui-hooks.h: Rename include guard. * tui/tui-file.h: Rename include guard. * tui/tui-disasm.h: Rename include guard. * tui/tui-data.h: Rename include guard. * tui/tui-command.h: Rename include guard. * tic6x-tdep.h: Add include guard. * target/waitstatus.h: Rename include guard. * target/wait.h: Rename include guard. * target/target.h: Rename include guard. * target/resume.h: Rename include guard. * target-float.h: Rename include guard. * stabsread.h: Add include guard. * rs6000-tdep.h: Add include guard. * riscv-fbsd-tdep.h: Add include guard. * regformats/regdef.h: Rename include guard. * record.h: Rename include guard. * python/python.h: Rename include guard. * python/python-internal.h: Rename include guard. * python/py-stopevent.h: Rename include guard. * python/py-ref.h: Rename include guard. * python/py-record.h: Rename include guard. * python/py-record-full.h: Rename include guard. * python/py-record-btrace.h: Rename include guard. * python/py-instruction.h: Rename include guard. * python/py-events.h: Rename include guard. * python/py-event.h: Rename include guard. * procfs.h: Add include guard. * proc-utils.h: Add include guard. * p-lang.h: Add include guard. * or1k-tdep.h: Rename include guard. * observable.h: Rename include guard. * nto-tdep.h: Rename include guard. * nat/x86-linux.h: Rename include guard. * nat/x86-linux-dregs.h: Rename include guard. * nat/x86-gcc-cpuid.h: Add include guard. * nat/x86-dregs.h: Rename include guard. * nat/x86-cpuid.h: Rename include guard. * nat/ppc-linux.h: Rename include guard. * nat/mips-linux-watch.h: Rename include guard. * nat/linux-waitpid.h: Rename include guard. * nat/linux-ptrace.h: Rename include guard. * nat/linux-procfs.h: Rename include guard. * nat/linux-osdata.h: Rename include guard. * nat/linux-nat.h: Rename include guard. * nat/linux-namespaces.h: Rename include guard. * nat/linux-btrace.h: Rename include guard. * nat/glibc_thread_db.h: Rename include guard. * nat/gdb_thread_db.h: Rename include guard. * nat/gdb_ptrace.h: Rename include guard. * nat/fork-inferior.h: Rename include guard. * nat/amd64-linux-siginfo.h: Rename include guard. * nat/aarch64-sve-linux-sigcontext.h: Rename include guard. * nat/aarch64-sve-linux-ptrace.h: Rename include guard. * nat/aarch64-linux.h: Rename include guard. * nat/aarch64-linux-hw-point.h: Rename include guard. * mn10300-tdep.h: Add include guard. * mips-linux-tdep.h: Add include guard. * mi/mi-parse.h: Rename include guard. * mi/mi-out.h: Rename include guard. * mi/mi-main.h: Rename include guard. * mi/mi-interp.h: Rename include guard. * mi/mi-getopt.h: Rename include guard. * mi/mi-console.h: Rename include guard. * mi/mi-common.h: Rename include guard. * mi/mi-cmds.h: Rename include guard. * mi/mi-cmd-break.h: Rename include guard. * m2-lang.h: Add include guard. * location.h: Rename include guard. * linux-record.h: Rename include guard. * linux-nat.h: Add include guard. * linux-fork.h: Add include guard. * i386-darwin-tdep.h: Rename include guard. * hppa-linux-offsets.h: Add include guard. * guile/guile.h: Rename include guard. * guile/guile-internal.h: Rename include guard. * gnu-nat.h: Rename include guard. * gdb-stabs.h: Rename include guard. * frv-tdep.h: Add include guard. * f-lang.h: Add include guard. * event-loop.h: Add include guard. * darwin-nat.h: Rename include guard. * cp-abi.h: Rename include guard. * config/sparc/nm-sol2.h: Rename include guard. * config/nm-nto.h: Rename include guard. * config/nm-linux.h: Add include guard. * config/i386/nm-i386gnu.h: Rename include guard. * config/djgpp/nl_types.h: Rename include guard. * config/djgpp/langinfo.h: Rename include guard. * compile/gcc-cp-plugin.h: Add include guard. * compile/gcc-c-plugin.h: Add include guard. * compile/compile.h: Rename include guard. * compile/compile-object-run.h: Rename include guard. * compile/compile-object-load.h: Rename include guard. * compile/compile-internal.h: Rename include guard. * compile/compile-cplus.h: Rename include guard. * compile/compile-c.h: Rename include guard. * common/xml-utils.h: Rename include guard. * common/x86-xstate.h: Rename include guard. * common/version.h: Rename include guard. * common/vec.h: Rename include guard. * common/tdesc.h: Rename include guard. * common/selftest.h: Rename include guard. * common/scoped_restore.h: Rename include guard. * common/scoped_mmap.h: Rename include guard. * common/scoped_fd.h: Rename include guard. * common/safe-iterator.h: Rename include guard. * common/run-time-clock.h: Rename include guard. * common/refcounted-object.h: Rename include guard. * common/queue.h: Rename include guard. * common/ptid.h: Rename include guard. * common/print-utils.h: Rename include guard. * common/preprocessor.h: Rename include guard. * common/pathstuff.h: Rename include guard. * common/observable.h: Rename include guard. * common/netstuff.h: Rename include guard. * common/job-control.h: Rename include guard. * common/host-defs.h: Rename include guard. * common/gdb_wait.h: Rename include guard. * common/gdb_vecs.h: Rename include guard. * common/gdb_unlinker.h: Rename include guard. * common/gdb_unique_ptr.h: Rename include guard. * common/gdb_tilde_expand.h: Rename include guard. * common/gdb_sys_time.h: Rename include guard. * common/gdb_string_view.h: Rename include guard. * common/gdb_splay_tree.h: Rename include guard. * common/gdb_setjmp.h: Rename include guard. * common/gdb_ref_ptr.h: Rename include guard. * common/gdb_optional.h: Rename include guard. * common/gdb_locale.h: Rename include guard. * common/gdb_assert.h: Rename include guard. * common/filtered-iterator.h: Rename include guard. * common/filestuff.h: Rename include guard. * common/fileio.h: Rename include guard. * common/environ.h: Rename include guard. * common/common-utils.h: Rename include guard. * common/common-types.h: Rename include guard. * common/common-regcache.h: Rename include guard. * common/common-inferior.h: Rename include guard. * common/common-gdbthread.h: Rename include guard. * common/common-exceptions.h: Rename include guard. * common/common-defs.h: Rename include guard. * common/common-debug.h: Rename include guard. * common/cleanups.h: Rename include guard. * common/buffer.h: Rename include guard. * common/btrace-common.h: Rename include guard. * common/break-common.h: Rename include guard. * cli/cli-utils.h: Rename include guard. * cli/cli-style.h: Rename include guard. * cli/cli-setshow.h: Rename include guard. * cli/cli-script.h: Rename include guard. * cli/cli-interp.h: Rename include guard. * cli/cli-decode.h: Rename include guard. * cli/cli-cmds.h: Rename include guard. * charset-list.h: Add include guard. * buildsym-legacy.h: Rename include guard. * bfin-tdep.h: Add include guard. * ax.h: Rename include guard. * arm-linux-tdep.h: Add include guard. * arm-fbsd-tdep.h: Add include guard. * arch/xtensa.h: Rename include guard. * arch/tic6x.h: Add include guard. * arch/i386.h: Add include guard. * arch/arm.h: Rename include guard. * arch/arm-linux.h: Rename include guard. * arch/arm-get-next-pcs.h: Rename include guard. * arch/amd64.h: Add include guard. * arch/aarch64-insn.h: Rename include guard. * arch-utils.h: Rename include guard. * annotate.h: Add include guard. * amd64-darwin-tdep.h: Rename include guard. * aarch64-linux-tdep.h: Add include guard. * aarch64-fbsd-tdep.h: Add include guard. * aarch32-linux-nat.h: Add include guard. gdb/gdbserver/ChangeLog 2019-02-07 Tom Tromey <tom@tromey.com> * x86-tdesc.h: Rename include guard. * x86-low.h: Add include guard. * wincecompat.h: Rename include guard. * win32-low.h: Add include guard. * utils.h: Rename include guard. * tracepoint.h: Rename include guard. * tdesc.h: Rename include guard. * target.h: Rename include guard. * server.h: Rename include guard. * remote-utils.h: Rename include guard. * regcache.h: Rename include guard. * nto-low.h: Rename include guard. * notif.h: Add include guard. * mem-break.h: Rename include guard. * lynx-low.h: Add include guard. * linux-x86-tdesc.h: Add include guard. * linux-s390-tdesc.h: Add include guard. * linux-ppc-tdesc-init.h: Add include guard. * linux-low.h: Add include guard. * linux-aarch64-tdesc.h: Add include guard. * linux-aarch32-low.h: Add include guard. * inferiors.h: Rename include guard. * i387-fp.h: Rename include guard. * hostio.h: Rename include guard. * gdbthread.h: Rename include guard. * gdb_proc_service.h: Rename include guard. * event-loop.h: Rename include guard. * dll.h: Rename include guard. * debug.h: Rename include guard. * ax.h: Rename include guard.
2019-01-01Update copyright year range in all GDB files.Joel Brobecker1-1/+1
This commit applies all changes made after running the gdb/copyright.py script. Note that one file was flagged by the script, due to an invalid copyright header (gdb/unittests/basic_string_view/element_access/char/empty.cc). As the file was copied from GCC's libstdc++-v3 testsuite, this commit leaves this file untouched for the time being; a patch to fix the header was sent to gcc-patches first. gdb/ChangeLog: Update copyright year range in all GDB files.
2018-01-31(Ada) Add gdb-mi support for stopping at start of exception handler.Xavier Roirand1-0/+1
Following my previous commit which add support for stopping at start of exception handler, this commit adds required gdb-mi support for this feature. gdb/ChangeLog: * mi/mi-cmd-catch.c (mi_cmd_catch_handlers): New function. * mi/mi-cmds.c (mi_cmds): Add catch-handlers command. * mi/mi-cmds.h (mi_cmd_catch_handlers): Add external declaration. * NEWS: Document "-catch-handlers" command. gdb/doc/ChangeLog: * gdb.texinfo (Ada Exception gdb/mi Catchpoints): Add documentation for new "-catch-handlers" command. gdb/testsuite/ChangeLog: * gdb.ada/mi_catch_ex_hand.exp: New testcase. * gdb.ada/mi_catch_ex_hand/foo.adb: New file. Tested on x86_64-linux.
2018-01-02Update copyright year range in all GDB filesJoel Brobecker1-1/+1
gdb/ChangeLog: Update copyright year range in all GDB files
2017-04-05-Wwrite-strings: Constify mi_cmd_argv_ftype's 'command' parameterPedro Alves1-1/+1
-Wwrite-strings flags this attempt to pass a literal to a "char *": mi_cmd_interpreter_exec ("-interpreter-exec", argv, 2); Fix that by constifying mi_cmd_argv_ftype's 'command' parameter and adjusting all MI commands. gdb/ChangeLog: 2017-04-05 Pedro Alves <palves@redhat.com> * mi/mi-cmd-break.c (mi_cmd_break_insert_1, mi_cmd_break_insert) (mi_cmd_dprintf_insert, mi_cmd_break_passcount) (mi_cmd_break_watch, mi_cmd_break_commands): Constify 'command' parameter. * mi/mi-cmd-catch.c (mi_cmd_catch_assert, mi_cmd_catch_exception) (mi_cmd_catch_load, mi_cmd_catch_unload): Constify cmd' parameter. * mi/mi-cmd-disas.c (mi_cmd_disassemble): Constify 'command' parameter. * mi/mi-cmd-env.c (mi_cmd_env_pwd, mi_cmd_env_cd, mi_cmd_env_path) (mi_cmd_env_dir, mi_cmd_inferior_tty_set, _cmd_inferior_tty_show) * mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_file) (mi_cmd_file_list_exec_source_files) (mi_cmd_file_list_shared_libraries): Constify 'command' parameter. * mi/mi-cmd-info.c (mi_cmd_info_ada_exceptions) (mi_cmd_info_gdb_mi_command, mi_cmd_info_os): Constify 'command' parameter. * mi/mi-cmd-stack.c (mi_cmd_enable_frame_filters) (mi_cmd_stack_list_frames, mi_cmd_stack_info_depth) (mi_cmd_stack_list_locals, mi_cmd_stack_list_args) (mi_cmd_stack_list_variables, mi_cmd_stack_select_frame) (mi_cmd_stack_info_frame): Constify 'command' parameter. * mi/mi-cmd-target.c (mi_cmd_target_file_get) (mi_cmd_target_file_put, mi_cmd_target_file_delete): Constify 'command' parameter. * mi/mi-cmd-var.c (mi_cmd_var_create, mi_cmd_var_delete) (mi_cmd_var_set_format, mi_cmd_var_set_visualizer) (mi_cmd_var_set_frozen, mi_cmd_var_show_format) (mi_cmd_var_info_num_children, mi_cmd_var_list_children) (mi_cmd_var_info_type, mi_cmd_var_info_path_expression) (mi_cmd_var_info_expression, mi_cmd_var_show_attributes) (mi_cmd_var_evaluate_expression, mi_cmd_var_assign) (mi_cmd_var_update, mi_cmd_enable_pretty_printing) (mi_cmd_var_set_update_range): Constify 'command' parameter. * mi/mi-cmds.h (mi_cmd_argv_ftype): Constify 'command' parameter. * mi/mi-interp.c (mi_cmd_interpreter_exec): Constify 'command' parameter. * mi/mi-main.c (mi_cmd_gdb_exit, mi_cmd_exec_next) (mi_cmd_exec_next_instruction, mi_cmd_exec_step) (mi_cmd_exec_step_instruction, mi_cmd_exec_finish) (mi_cmd_exec_return ,mi_cmd_exec_jump, mi_cmd_exec_continue) (mi_cmd_exec_interrupt, mi_cmd_exec_run, mi_cmd_target_detach) (mi_cmd_target_flash_erase, mi_cmd_thread_select) (mi_cmd_thread_list_ids, mi_cmd_thread_info) (mi_cmd_list_thread_groups, mi_cmd_data_list_register_names) (mi_cmd_data_list_changed_registers) (mi_cmd_data_write_register_values) (mi_cmd_data_evaluate_expression, mi_cmd_data_read_memory) (mi_cmd_data_read_memory_bytes, mi_cmd_data_write_memory) (mi_cmd_data_write_memory_bytes, mi_cmd_enable_timings) (mi_cmd_list_features, mi_cmd_list_target_features) (mi_cmd_add_inferior, mi_cmd_remove_inferior) (mi_cmd_trace_define_variable, mi_cmd_trace_list_variables) (mi_cmd_trace_find, mi_cmd_trace_save, mi_cmd_trace_start) (mi_cmd_trace_status, mi_cmd_trace_stop, mi_cmd_ada_task_info) (mi_cmd_trace_frame_collected): Constify 'command' parameter. * mi/mi-symbol-cmds.c (mi_cmd_symbol_list_lines): Constify 'command' parameter.
2017-03-20Add -file-list-shared-libraries MI commandMarc-Andre Laperle1-0/+1
This change adds the MI equivalent for the "info sharedlibrary" command. The command was already partially documented but ignored as it was not implemented. The new MI command works similarly to the CLI command, taking an optional regular expression as an argument and outputting the library information. I included a test for the new command in mi-solib.exp. gdb/doc/ChangeLog: * gdb.texinfo (gdb/mi Symbol Query Commands): Document new MI command file-list-shared-libraries (GDB/MI Async Records): Update documentation of library-loaded with new field. gdb/ChangeLog: * NEWS: Add an entry about new '-file-list-shared-libraries' command. * mi/mi-cmd-file.c (mi_cmd_file_list_shared_libraries): New function definition. * mi/mi-cmds.c (mi_cmds): Add -file-list-shared-libraries command. * mi/mi-cmds.h (mi_cmd_file_list_shared_libraries): New function declaration. * mi/mi-interp.c (mi_output_solib_attribs): New Function. * mi/mi-interp.h: New file. * solib.c (info_sharedlibrary_command): Replace for loop with ALL_SO_LIBS macro * solib.h (update_solib_list): New function declaration. (so_list_head): Move macro. * solist.h (ALL_SO_LIBS): New macro. gdb/testsuite/ChangeLog: * gdb.mi/mi-solib.exp (test_file_list_shared_libraries): New procedure. Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
2017-01-20Add command to erase all flash memory regionsLuis Machado1-0/+1
Changes in v4: - Replaced phex call with hex_string. Changes in v3: - Addressed comments by Pedro. - Output of memory region size now in hex format. - Misc formatting fixups. - Addressed Simon's comments on formatting. - Adjusted command text in the manual entry. - Fixed up ChangeLog. - Renamed flash_erase_all_command to flash_erase_command. Changes in v2: - Added NEWS entry. - Fixed long lines. - Address printing with paddress. Years ago we contributed flash programming patches upstream. The following patch is a leftover one that complements that functionality by adding a new command to erase all reported flash memory blocks. The command is most useful when we're dealing with flash-enabled targets (mostly bare-metal) and we need to reset the board for some reason. The wiping out of flash memory regions should help the target come up with a known clean state from which the user can load a new image and resume debugging. It is convenient enough to do this from the debugger, and there is also an MI command to expose this functionality to the IDE's. gdb/doc/ChangeLog: 2017-01-20 Mike Wrighton <mike_wrighton@codesourcery.com> Luis Machado <lgustavo@codesourcery.com> * gdb.texinfo (-target-flash-erase): New MI command description. (flash-erase): New CLI command description. gdb/ChangeLog: 2017-01-20 Mike Wrighton <mike_wrighton@codesourcery.com> Luis Machado <lgustavo@codesourcery.com> * NEWS (New commands): Mention flash-erase. (New MI commands): Mention target-flash-erase. * mi/mi-cmds.c (mi_cmd_target_flash_erase): Add target-flash-erase MI command. * mi/mi-cmds.h (mi_cmd_target_flash_erase): New declaration. * mi/mi-main.c (mi_cmd_target_flash_erase): New function. * target.c (flash_erase_command): New function. (initialize_targets): Add new flash-erase command. * target.h (flash_erase_command): New declaration.
2017-01-01update copyright year range in GDB filesJoel Brobecker1-1/+1
This applies the second part of GDB's End of Year Procedure, which updates the copyright year range in all of GDB's files. gdb/ChangeLog: Update copyright year range in all GDB files.
2016-06-21Make raw_stdout be per MI instancePedro Alves1-3/+0
Each MI instance should obviously have its own raw output channel, along with save_raw_stdout. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * interps.c (current_interpreter): New function. * interps.h (current_interpreter): New declaration. * mi/mi-cmds.h (raw_stdout): Delete declaration. * mi/mi-common.h (struct mi_interp) <raw_stdout, saved_raw_stdout>: New field. * mi/mi-interp.c (display_mi_prompt): New parameter 'mi'. Adjust to per-UI raw_stdout. (mi_interpreter_init): Adjust to per-UI raw_stdout. (mi_on_sync_execution_done, mi_execute_command_input_handler) (mi_command_loop): Pass MI instance to display_mi_prompt. (mi_on_normal_stop_1, mi_output_running_pid, mi_on_resume_1) (mi_on_resume): Adjust to per-UI raw_stdout. (saved_raw_stdout): Delete. (mi_set_logging): Adjust to per-UI raw_stdout and saved_raw_stdout. * mi/mi-main.c (raw_stdout): Delete. (mi_cmd_gdb_exit, captured_mi_execute_command) (mi_print_exception, mi_load_progress): Adjust to per-UI raw_stdout. (print_diff_now, mi_print_timing_maybe): New ui_file parameter. Pass it along. (print_diff): New ui_file parameter. Send output there instead of raw_stdout. * mi/mi-main.h (struct ui_file): Forward declare. (mi_print_timing_maybe): Add ui_file parameter.
2016-01-01GDB copyright headers update after running GDB's copyright.py script.Joel Brobecker1-1/+1
gdb/ChangeLog: Update year range in copyright notice of all files.
2015-01-01Update year range in copyright notice of all files owned by the GDB project.Joel Brobecker1-1/+1
gdb/ChangeLog: Update year range in copyright notice of all files.
2014-01-01Update Copyright year range in all files maintained by GDB.Joel Brobecker1-1/+1
2013-12-03New GDB/MI command "-info-gdb-mi-command"Joel Brobecker1-0/+1
This patch adds a new GDB/MI command meant for graphical frontends trying to determine whether a given GDB/MI command exists or not. Examples: -info-gdb-mi-command unsupported-command ^done,command={exists="false"} (gdb) -info-gdb-mi-command symbol-list-lines ^done,command={exists="true"} (gdb) At the moment, this is the only piece of information that this command returns. Eventually, and if needed, we can extend it to provide command-specific pieces of information, such as updates to the command's syntax since inception. This could become, for instance: -info-gdb-mi-command symbol-list-lines ^done,command={exists="true",features=[]} (gdb) -info-gdb-mi-command catch-assert ^done,command={exists="true",features=["conditions"]} In the first case, it would mean that no extra features, while in the second, it announces that the -catch-assert command in this version of the debugger supports a feature called "condition" - exact semantics to be documented with combined with the rest of the queried command's documentation. But for now, we start small, and only worry about existance. And to bootstrap the process, I have added an entry in the output of the -list-features command as well ("info-gdb-mi-command"), allowing the graphical frontends to go through the following process: 1. Send -list-features, collect info from there as before; 2. Check if the output contains "info-gdb-mi-command". If it does, then support for various commands can be queried though -info-gdb-mi-command. Newer commands will be expected to always be checked via this new -info-gdb-mi-command. gdb/ChangeLog: * mi/mi-cmds.h (mi_cmd_info_gdb_mi_command): Declare. * mi/mi-cmd-info.c (mi_cmd_info_gdb_mi_command): New function. * mi/mi-cmds.c (mi_cmds): Add -info-gdb-mi-command command. * mi/mi-main.c (mi_cmd_list_features): Add "info-gdb-mi-command" field to output of "-list-features". * NEWS: Add entry for new -info-gdb-mi-command. gdb/doc/ChangeLog: * gdb.texinfo (GDB/MI Miscellaneous Commands): Document the new -info-gdb-mi-command GDB/MI command. Document the meaning of "-info-gdb-mi-command" in the output of -list-features. gdb/testsuite/ChangeLog: * gdb.mi/mi-i-cmd.exp: New file.
2013-11-12Implement GDB/MI equivalent of "info exceptions" CLI command.Joel Brobecker1-0/+1
This patch implements a new GDB/MI command implementing the equivalent of the "info exceptions" CLI command. The command syntax is: -info-ada-exceptions [REGEXP] Here is an example of usage (slightly formatted by hand to make it easier to read): -info-ada-exceptions ions\.a_ ^done,ada-exceptions= {nr_rows="2",nr_cols="2", hdr=[{width="1",alignment="-1",col_name="name",colhdr="Name"}, {width="1",alignment="-1",col_name="address",colhdr="Address"}], body=[{name="global_exceptions.a_global_exception", address="0x0000000000613a80"}, {name="global_exceptions.a_private_exception", address="0x0000000000613ac0"}]} Also, in order to allow graphical frontends to easily determine whether this command is available or not, the output of the "-list-features" command has been augmented to contain "info-ada-exceptions". gdb/Changelog: * mi/mi-cmds.h (mi_cmd_info_ada_exceptions): Add declaration. * mi/mi-cmds.c (mi_cmds): Add entry for -info-ada-exceptions command. * mi/mi-cmd-info.c: #include "ada-lang.c" and "arch-utils.c". (mi_cmd_info_ada_exceptions): New function. * mi/mi-main.c (mi_cmd_list_features): Add "info-ada-exceptions". gdb/testsuite/ChangeLog: * gdb.ada/mi_exc_info: New testcase.
2013-10-11New GDB/MI commands to catch Ada exceptionsJoel Brobecker1-0/+2
This patch introduces two new GDB/MI commands implementing the equivalent of the "catch exception" and "catch assert" GDB/CLI commands. gdb/ChangeLog: * breakpoint.h (init_ada_exception_breakpoint): Add parameter "enabled". * breakpoint.c (init_ada_exception_breakpoint): Add parameter "enabled". Set B->ENABLE_STATE accordingly. * ada-lang.h (ada_exception_catchpoint_kind): Move here from ada-lang.c. (create_ada_exception_catchpoint): Add declaration. * ada-lang.c (ada_exception_catchpoint_kind): Move to ada-lang.h. (create_ada_exception_catchpoint): Make non-static. Add new parameter "disabled". Use it in call to init_ada_exception_breakpoint. (catch_ada_exception_command): Add parameter "enabled" in call to create_ada_exception_catchpoint. (catch_assert_command): Likewise. * mi/mi-cmds.h (mi_cmd_catch_assert, mi_cmd_catch_exception): Add declarations. * mi/mi-cmds.c (mi_cmds): Add the "catch-assert" and "catch-exception" commands. * mi/mi-cmd-catch.c: Add #include "ada-lang.h". (mi_cmd_catch_assert, mi_cmd_catch_exception): New functions.
2013-06-26gdb/Yao Qi1-0/+1
2013-06-26 Pedro Alves <pedro@codesourcery.com> Yao Qi <yao@codesourcery.com> * gdb.texinfo (GDB/MI Tracepoint Commands): Document -trace-frame-collected. gdb: 2013-06-26 Pedro Alves <pedro@codesourcery.com> Yao Qi <yao@codesourcery.com> * mi/mi-cmds.c (mi_cmds): Register -trace-frame-collected. * mi/mi-cmds.h (mi_cmd_trace_frame_collected): Declare. * mi/mi-main.c (print_variable_or_computed): New function. (mi_cmd_trace_frame_collected): New function. * tracepoint.c (find_trace_state_variable_by_number): New. (struct traceframe_info): Move to tracepoint.h (struct collection_list): Likewise. (do_collect_symbol): Include locals and arguments in the wholly collected variables list. (clear_collection_list): Clear wholly collected variables list and computed variables list. (append_exp): New function. (encode_actions_1): Include variables in the wholly collected variables list. Include memory ranges and full-fledged expressions in the computed expressions list. (encode_actions): Move some code to ... Return the cleanup chain. (encode_actions_rsp): ... here. New function. (get_traceframe_location, get_traceframe_info): Remove static. * tracepoint.h (struct memrange): Moved from tracepoint.c. (struct collection_list): Moved from tracepoint.c. Add two new fields 'wholly_collected' and 'computed'. (find_trace_state_variable_by_number): Declare. (encode_actions): Adjust declaration. (encode_actions_rsp): Declare. (get_traceframe_info, get_traceframe_location): Declare. * NEWS: Mention new MI command -trace-frame-collected.
2013-06-03gdb/Yao Qi1-4/+0
* mi/mi-cmd-var.c (mi_no_values, mi_simple_values): Move to mi-parse.c. Make them static. (mi_all_values): Likewise. (mi_parse_values_option): Move to mi-parse.c. Rename it to mi_parse_print_values. Make it external. * mi/mi-cmds.h (mi_no_values, mi_simple_values, mi_all_values): Remove the declarations. * mi/mi-parse.c (mi_parse_print_values): Moved from mi-cmd-var.c. * mi/mi-parse.h (mi_parse_print_values): Declare. * mi/mi-cmd-stack.c: Include mi-parse.h. (parse_print_values): Remove (mi_cmd_stack_list_locals): Call mi_parse_print_values instead of parse_print_values. (mi_cmd_stack_list_args, mi_cmd_stack_list_variables): Likewise.
2013-05-212013-05-21 Hui Zhu <hui@codesourcery.com>Hui Zhu1-0/+1
* breakpoint.c (dprintf_breakpoint_ops): Remove its static. * breakpoint.h (dprintf_breakpoint_ops): Add extern. * mi/mi-cmd-break.c (ctype.h): New include. (gdb_obstack.h): New include. (mi_argv_to_format, mi_cmd_break_insert_1): New. (mi_cmd_break_insert): Call mi_cmd_break_insert_1. (mi_cmd_dprintf_insert): New. * mi/mi-cmds.c (mi_cmds): Add "dprintf-insert". * mi/mi-cmds.h (mi_cmd_dprintf_insert): New extern. 2013-05-21 Hui Zhu <hui@codesourcery.com> * gdb.texinfo (GDB/MI Breakpoint Commands): Describe the "-dprintf-insert" command. 2013-05-21 Hui Zhu <hui@codesourcery.com> * gdb.mi/Makefile.in (PROGS): Add "mi-dprintf". * gdb.mi/mi-dprintf.exp, gdb.mi/mi-dprintf.c: New.
2013-05-102013-05-10 Phil Muldoon <pmuldoon@redhat.com>Phil Muldoon1-0/+1
* stack.c (backtrace_command_1): Add "no-filters", and Python frame filter logic. (backtrace_command): Add "no-filters" option parsing. (_initialize_stack): Alter help to reflect "no-filters" option. * Makefile.in (SUBDIR_PYTHON_OBS): Add py-framefilter.o (SUBDIR_PYTHON_SRCS): Add py-framefilter.c (py-frame.o): Add target * data-directory/Makefile.in (PYTHON_DIR): Add Python frame filter files. * python/python.h: Add new frame filter constants, and flag enum. (apply_frame_filter): Add definition. * python/python.c (apply_frame_filter): New non-Python enabled function. * python/py-utils.c (py_xdecref): New function. (make_cleanup_py_xdecref): Ditto. * python/py-objfile.c: Declare frame_filters dictionary. (objfpy_dealloc): Add frame_filters dealloc. (objfpy_new): Initialize frame_filters attribute. (objfile_to_objfile_object): Ditto. (objfpy_get_frame_filters): New function. (objfpy_set_frame_filters): New function. * python/py-progspace.c: Declare frame_filters dictionary. (pspy_dealloc): Add frame_filters dealloc. (pspy_new): Initialize frame_filters attribute. (pspacee_to_pspace_object): Ditto. (pspy_get_frame_filters): New function. (pspy_set_frame_filters): New function. * python/py-framefilter.c: New file. * python/lib/gdb/command/frame_filters.py: New file. * python/lib/gdb/frames.py: New file. * python/lib/gdb/__init__.py: Initialize global frame_filters dictionary * python/lib/gdb/FrameDecorator.py: New file. * python/lib/gdb/FrameIterator.py: New file. * mi/mi-cmds.c (mi_cmds): Add frame filters command. * mi/mi-cmds.h: Declare. * mi/mi-cmd-stack.c (mi_cmd_stack_list_frames): Add --no-frame-filter logic, and Python frame filter logic. (stack_enable_frame_filters): New function. (parse_no_frame_option): Ditto. (mi_cmd_stack_list_frames): Add --no-frame-filter and Python frame filter logic. (mi_cmd_stack_list_locals): Ditto. (mi_cmd_stack_list_args): Ditto. (mi_cmd_stack_list_variables): Ditto. * NEWS: Add frame filter note. 2013-05-10 Phil Muldoon <pmuldoon@redhat.com> * gdb.python/py-framefilter.py: New File. * gdb.python/py-framefilter-mi.exp: Ditto. * gdb.python/py-framefilter.c: Ditto. * gdb.python/py-framefilter-mi.exp: Ditto. * gdb.python/py-framefilter-mi.c: Ditto, * gdb.python/py-framefilter-gdb.py.in: Ditto. 2013-05-10 Phil Muldoon <pmuldoon@redhat.com> * gdb.texinfo (Backtrace): Add "no-filter" argument. (Python API): Add Frame Filters API, Frame Wrapper API, Writing a Frame Filter/Wrapper, Managing Management of Frame Filters chapter entries. (Frame Filters API): New Node. (Frame Wrapper API): New Node. (Writing a Frame Filter): New Node. (Managing Frame Filters): New Node. (Progspaces In Python): Add note about frame_filters attribute. (Objfiles in Python): Ditto. (GDB/MI Stack Manipulation): Add -enable-frame-filters command, @anchors and --no-frame-filters option to -stack-list-variables, -stack-list-frames, -stack-list-locals and -stack-list-arguments commands.
2013-03-12 * mi/mi-cmds.h (mi_execute_command): Make "cmd" const.Keith Seitz1-1/+1
* mi/mi-interp.c (mi_interpreter_exec): Make "command" const. Remove temporary copy of input string. (mi_execute_command_wrapper): Make "cmd" const. * mi/mi-main.c (mi_execute_command): Make "string_ptr" const. * mi/mi-parse.c (mi_parse_argv): Make "args" const. Use const strings. (mi_parse): Make "cmd" const. Use const strings. * mi/mi-parse.h (mi_parse): Make "cmd" const.
2013-01-01Update years in copyright notice for the GDB files.Joel Brobecker1-2/+1
Two modifications: 1. The addition of 2013 to the copyright year range for every file; 2. The use of a single year range, instead of potentially multiple year ranges, as approved by the FSF.
2012-12-12MI: add the -catch-load and -catch-unload commandsMircea Gherzan1-0/+2
They are equivalent to "catch load" and "catch unload" from CLI. Rationale: GUIs might be interested in catching solib load or unload events. 2012-11-16 Mircea Gherzan <mircea.gherzan@intel.com> * Makefile.in (SUBDIR_MI_OBS): Add mi-cmd-catch.o. (SUBDIR_MI_SRCS): Add mi/mi-cmd-catch.c. * breakpoint.c (add_solib_catchpoint): New function that can be used by both CLI and MI, factored out from catch_load_or_unload. (catch_load_or_unload): Strip it down and make it use the new add_solib_catchpoint. * breakpoint.h (add_solib_catchpoint): Declare it. * mi/mi-cmd-break.h: New file. * mi/mi-cmd-break.c: Include mi-cmd-break.h. (setup_breakpoint_reporting): New function used for both catchpoints and breakpoints. (mi_cmd_break_insert): Use setup_breakpoint_reporting. * mi/mi-cmd-catch.c: New file. * mi/mi-cmds.c (mi_cmds): Add the handlers for -catch-load and -catch-unload. * mi/mi-cmds.h: Declare the handlers for -catch-load and -catch-unload.
2012-08-31gdb/Yao Qi1-0/+6
* mi/mi-cmds.c (mi_cmds): New macros DEF_MI_CMD_CLI DEF_MI_CMD_MI DEF_MI_CMD_CLI_1 and DEF_MI_CMD_CLI_1. Update some commands. * mi/mi-cmds.h (struct mi_cmd) <suppress_notification>: New field. * mi/mi-main.c (mi_cmd_execute): Set '*parse->cmd->suppress_notification' to 1.
2012-05-242012-05-23 Stan Shebs <stan@codesourcery.com>Stan Shebs1-0/+1
Kwok Cheung Yeung <kcy@codesourcery.com> * Makefile.in (SUBDIR_MI_OBS): Add mi-cmd-info.o. (SUBDIR_MI_SRCS): Add mi-cmd-info.c. (mi-cmd-info.o): New rule. * osdata.h (info_osdata_command): New declaration. * osdata.c (info_osdata_command): Change to non-static. * mi/mi-cmds.h (mi_cmd_info_os): New declaration. * mi/mi-cmds.c (mi_cmds): Add -info-os MI command. * mi/mi-cmd-info.c: New file. * gdb.texinfo (Miscellaneous GDB/MI Commands): Document -info-os. * gdb.mi/mi-info-os.exp: New file.
2012-03-06 * mi/mi-cmd-break.c: Enforce coding standards, fix comments.Stan Shebs1-4/+5
* mi/mi-cmd-disas.c: Ditto. * mi/mi-cmd-env.c: Ditto. * mi/mi-cmd-file.c: Ditto. * mi/mi-cmd-stack.c: Ditto. * mi/mi-cmd-target.c: Ditto. * mi/mi-cmd-var.c: Ditto. * mi/mi-cmds.c: Ditto. * mi/mi-cmds.h: Ditto. * mi/mi-console.c: Ditto. * mi/mi-getopt.c: Ditto. * mi/mi-getopt.h: Ditto. * mi/mi-interp.c: Ditto. * mi/mi-main.c: Ditto. * mi/mi-out.c: Ditto. * mi/mi-parse.c: Ditto. * mi/mi-parse.h: Ditto. * mi/mi-symbol-cmds.c: Ditto. * mi/mi-getopt.h: Move mi_opt struct up. * mi/mi-main.c (captured_mi_execute_command): Remove redundant return. * mi/mi-out.c (_initialize_mi_out): Remove empty initialize.
2012-01-04Copyright year update in most files of the GDB Project.Joel Brobecker1-2/+2
gdb/ChangeLog: Copyright year update in most files of the GDB Project.
2011-10-03[Ada] New GDB/MI command: -ada-tasks-infoJoel Brobecker1-0/+1
This patch introduces a new GDB/MI command: -ada-tasks-info, which is meant to be the MI equivalent of the CLI `info tasks' command. This new command returns an array, with each row corresponding to one task. For now, the columns of the array corresponds to the columns displayed in the CLI output. gdb/ChangeLog: * ada-lang.h (struct inferior): Declare. (print_ada_task_info): Add declaration. * ada-tasks.c (print_ada_task_info): Make non-static. * mi/mi-cmds.c (mi_cmds): Add "ada-task-info". * mi/mi-cmds.h (mi_cmd_ada_task_info): Add declaration. * mi/mi-main.c: #include "ada-lang.h". (mi_cmd_list_features): Add "ada-task-info" to the list of supported features. (mi_cmd_ada_task_info): New function.
2011-01-01run copyright.sh for 2011.Joel Brobecker1-1/+1
2010-08-13 Easier and more stubborn MI memory read commands.Vladimir Prus1-0/+2
* mi/mi-cmds.c (mi_cmds): Register data-read-memory-bytes and data-write-memory-bytes. * mi/mi-cmds.h (mi_cmd_data_read_memory_bytes) (mi_cmd_data_write_memory_bytes): New. * mi/mi-main.c (mi_cmd_data_read_memory): Use regular target_read. (mi_cmd_data_read_memory_bytes, mi_cmd_data_write_memory_bytes): New. (mi_cmd_list_features): Add "data-read-memory-bytes" feature. * target.c (target_read_until_error): Remove. (read_whatever_is_readable, free_memory_read_result_vector) (read_memory_robust): New. * target.h (target_read_until_error): Remove. (struct memory_read_result, free_memory_read_result_vector) (read_memory_robust): New.