Similar to lookup_global_symbol, except that it checks the
STATIC_SCOPE.
gdb/ChangeLog:
2019-07-30 Christian Biesinger <cbiesinger@google.com>
PR/24474: Add a function to lookup static variables.
* NEWS: Mention this new function.
* python/py-symbol.c (gdbpy_lookup_static_symbol): New function.
* python/python-internal.h (gdbpy_lookup_static_symbol): New function.
* python/python.c (python_GdbMethods): Add new function.
gdb/doc/ChangeLog:
2019-07-30 Christian Biesinger <cbiesinger@google.com>
* python.texi (Symbols In Python): Document new function
gdb.lookup_static_symbol.
gdb/testsuite/ChangeLog:
2019-07-30 Christian Biesinger <cbiesinger@google.com>
* gdb.python/py-symbol.c: Add a static variable and one in an anonymous
namespace.
* gdb.python/py-symbol.exp: Test gdb.lookup_static_symbol.
This is essentially the inverse of Symbol.objfile. This allows
handling different symbols with the same name (but from different
objfiles) and can also be faster if the objfile is known.
gdb/ChangeLog:
2019-07-29 Christian Biesinger <cbiesinger@google.com>
* NEWS: Mention new functions Objfile.lookup_{global,static}_symbol.
* python/py-objfile.c (objfpy_lookup_global_symbol): New function.
(objfpy_lookup_static_symbol): New function.
(objfile_object_methods): Add new functions.
gdb/doc/ChangeLog:
2019-07-29 Christian Biesinger <cbiesinger@google.com>
* python.texi (Objfiles In Python): Document new functions
Objfile.lookup_{global,static}_symbol.
gdb/testsuite/ChangeLog:
2019-07-29 Christian Biesinger <cbiesinger@google.com>
* gdb.python/py-objfile.c: Add global and static vars.
* gdb.python/py-objfile.exp: Test new functions Objfile.
lookup_global_symbol and lookup_static_symbol.
gdb/ChangeLog
2019-06-19 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* NEWS: Mention 'set|show print frame-info'. Mention new
'presence' value for 'frame-arguments'. Mention new '-frame-info'
backtrace argument. Mention that python frame filtering code
is now consistent with what 'backtrace' command prints.
gdb/doc/ChangeLog
2019-07-29 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* gdb.texinfo (Backtrace): Document the new '-frame-info'
backtrace option. Reference 'set print frame-info'.
(Print Settings): Document 'set|show print frame-info'.
Document new 'presence' value for 'set print frame-arguments.
Adds a new -q flag to "info types" using the gdb::option framework.
This -q flag is similar to the -q flag already present for "info
variables" and "info functions".
gdb/ChangeLog:
* NEWS: Mention adding -q option to "info types".
* symtab.c (struct info_types_options): New struct.
(info_types_options_defs): New variable.
(make_info_types_options_def_group): New function.
(info_types_command): Use gdb::option framework to parse options.
(info_types_command_completer): New function.
(_initialize_symtab): Extend the help text on "info types" and
register command completer.
gdb/doc/ChangeLog:
* gdb.texinfo (Symbols): Add information about -q flag to "info
types".
Add command completion for info variables, functions, args, and
locals. This completer only completes the command line options as
these commands all take a regexp which GDB can't really offer
completions for.
gdb/ChangeLog:
* cli/cli-utils.c (info_print_command_completer): New function.
* cli/cli-utils.h: Add 'completer.h' include, and forward
declaration for 'struct cmd_list_element'.
(info_print_command_completer): Declare.
* stack.c (_initialize_stack): Add completer for 'info locals' and
'info args'.
* symtab.c (_initialize_symtab): Add completer for 'info
variables' and 'info functions'.
* NEWS: Mention completion for additional info commands.
Without this patch, GDB printf command calls malloc on the target,
writes the convenience var content to the target,
re-reads the content from the target, and then locally printf the string.
This implies inferior calls, and does not work when there is no running
inferior, or when the inferior is a core dump.
With this patch, printf command can printf string convenience variables
without inferior function calls.
Ada string convenience variables can also be printed.
gdb/ChangeLog
2019-07-08 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* NEWS: Mention that GDB printf and eval commands can now print
C-style and Ada-style convenience var strings without
calling the inferior.
* printcmd.c (printf_c_string): Locally print GDB internal var
instead of transiting via the inferior.
(printf_wide_c_string): Likewise.
gdb/testsuite/ChangeLog
2019-07-08 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* gdb.base/printcmds.exp: Test printing C string and
C wide string convenience vars without transiting via the inferior.
Also make test names unique.
( See original discussion and prototype here:
https://sourceware.org/ml/gdb-patches/2019-05/msg00570.html )
(gdb) help with
Temporarily set SETTING to VALUE, run COMMAND, and restore SETTING.
Usage: with SETTING [VALUE] [-- COMMAND]
Usage: w SETTING [VALUE] [-- COMMAND]
With no COMMAND, repeats the last executed command.
SETTING is any setting you can change with the "set" subcommands.
E.g.:
with language pascal -- print obj
with print elements unlimited -- print obj
As can be seen above, the "with" command is just like "set", but
instead of setting the setting permanently, it sets the setting, runs
a command and then restores the setting.
(gdb) p g_s
$1 = {a = 1, b = 2, c = 3}
(gdb) with language ada -- print g_s
$2 = (a => 1, b => 2, c => 3)
Warning: the current language does not match this frame.
(gdb) show language
The current source language is "auto; currently c".
(gdb) with print elements 100 -- with print object on -- print 1
$3 = 1
You can shorten things a bit though, as long as unambiguous. So this:
(gdb) with print elements 100 -- with print object off -- print 1
is the same as:
(gdb) w p el 100 -- w p o 0 -- p 1
Note that the patch adds a "w" alias for "with", as "w" is not
currently taken:
(gdb) w
Ambiguous command "w": watch, wh, whatis, where, while, while-stepping, winheight, ws.
Let me know if you'd prefer to reserve "w" for one of the other
commands above. IMHO, this command will end up being used frequently
enough that it deserves the "w" shorthand.
A nice feature is that this is fully integrated with TAB-completion:
(gdb) with p[TAB]
pagination print prompt python
(gdb) with print [TAB]
address max-depth static-members
array max-symbolic-offset symbol
array-indexes null-stop symbol-filename
asm-demangle object symbol-loading
demangle pascal_static-members thread-events
elements pretty type
entry-values raw union
frame-arguments repeats vtbl
inferior-events sevenbit-strings
(gdb) with print [TAB]
(gdb) with print elements unlimited -- thread apply all -[TAB]
-ascending -c -q -s
(gdb) with print elements unlimited -- print -[TAB]
-address -max-depth -repeats -vtbl
-array -null-stop -static-members
-array-indexes -object -symbol
-elements -pretty -union
The main advantage of this new command compared to command options,
like the new "print -OPT", is that this command works with any
setting, and, it works nicely when you want to override a setting
while running a user-defined command, like:
(gdb) with print pretty -- usercmd
The disadvantage is that it isn't as compact or easy to type. I think
of command options and this command as complementary. I think that
even with this new command, it makes sense to continue developing the
command options in the direction of exposing most-oft-used settings as
command options.
Inspired by Philippe's "/" command proposal, if no command is
specified, then the last command is re-invoked, under the overridden
setting:
(gdb) p g_s
$1 = {a = 1, b = 2, c = 3}
(gdb) with language ada
$2 = (a => 1, b => 2, c => 3)
Warning: the current language does not match this frame.
Note: "with" requires "--" to separate the setting from the command.
It might be possible to do without that, but, I haven't tried it yet,
and I think that this can go in without it. We can always downgrade
to making "--" optional if we manage to make it work.
On to the patch itself, the implementation of the command is simpler
than one might expect. A few details:
- I factored out a bit from pipe_command into repeat_previous
directly, because otherwise I'd need to copy&paste the same code and
same error message in the with command.
- The parse_cli_var_uinteger / parse_cli_var_zuinteger_unlimited /
do_set_command changes are necessary since we can now pass an empty
string as argument.
- do_show_command was split in two, as a FIXME comment suggests, but
for a different reason: we need to get a string version of a "set"
command's value, and we already had code for that in
do_show_command. That code is now factored out to the new
get_setshow_command_value_string function.
- There's a new "maint with" command added too:
(gdb) help maint with
Like "with", but works with "maintenance set" variables.
Usage: maintenance with SETTING [VALUE] [-- COMMAND]
With no COMMAND, repeats the last executed command.
SETTING is any setting you can change with the "maintenance set"
subcommands.
"with" and "maint with" share 99% of the implementation.
This might be useful on its own, but it's also useful for testing,
since with this, we can use the "maint set/show test-settings"
settings for exercising the "with" machinery with all the command
type variants (all enum var_types). This is done in the new
gdb/base/with.exp testcase.
The documentation bits are originally based on Philippe's docs for the
"/" command, hence the attribution in the ChangeLog.
gdb/ChangeLog:
2019-07-03 Pedro Alves <palves@redhat.com>
* NEWS (New commands): Mention "with" and "maint with".
* cli/cli-cmds.c (with_command_1, with_command_completer_1)
(with_command, with_command_completer): New.
(pipe_command): Adjust to new repeat_previous
interface.
(_initialize_cli_cmds): Install the "with" command and its "w"
alias.
* cli/cli-cmds.h (with_command_1, with_command_completer_1): New
declarations.
* cli/cli-setshow.c (parse_cli_var_uinteger)
(parse_cli_var_zuinteger_unlimited, do_set_command): Handle empty
argument strings for all var_types.
(get_setshow_command_value_string): New, factored out from ...
(do_show_command): ... this.
* cli/cli-setshow.h: Include <string>.
(get_setshow_command_value_string): Declare.
* command.h (repeat_previous): Now returns const char *. Adjust
comment.
* maint.c: Include "cli/cli-cmds.h".
(maintenance_with_cmd, maintenance_with_cmd_completer): New.
(_initialize_maint_cmds): Register the "maintenance with" command.
* top.c (repeat_previous): Move bits from pipe_command here:
Return the saved command line, if any; error out if there's no
command to relaunch.
gdb/doc/ChangeLog:
2019-07-03 Pedro Alves <palves@redhat.com>
Philippe Waroquiers <philippe.waroquiers@skynet.be>
* gdb.texinfo (Command Settings): New node documenting the general
concept of settings, how to change them, and the new "with"
command.
(Maintenance Commands): Document "maint with".
gdb/testsuite/ChangeLog:
2019-07-03 Pedro Alves <palves@redhat.com>
* gdb.base/with.c: New file.
* gdb.base/with.exp: New file.
This commit renames "maint test-settings set/show" to "maint set/show
test-settings".
This helps the following patch, which introduce a "maint with" command
what works with all "maint set" settings.
gdb/ChangeLog:
2019-07-03 Pedro Alves <palves@redhat.com>
* NEWS (New commands): Mention "maint set/show test-settings"
instead of "maint test-settings".
* maint-test-settings.c (maintenance_test_settings_list): Delete.
(maintenance_test_settings_set_list): Rename to ...
(maintenance_set_test_settings_list): ... this.
(maintenance_test_settings_show_list): Rename to ...
(maintenance_show_test_settings_list): ... this.
(maintenance_test_settings_cmd): Delete.
(maintenance_test_settings_set_cmd): ...
(maintenance_set_test_settings_cmd): ... this.
(maintenance_test_settings_show_cmd): ...
(maintenance_show_test_settings_cmd): ... this.
(maintenance_test_settings_show_value_cmd):
(maintenance_show_test_settings_value_cmd): ... this.
(_initialize_maint_test_settings): No longer install the "maint
test-settings" prefix command. Rename "maint test-settings set"
to "maint set test-settings", and "maint test-settings show" to
"maint show test-settings". Adjust all subcommands.
gdb/doc/ChangeLog:
2019-07-03 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Maintenance Commands): Document "maint set/show
test-settings" instead of "maint test-settings set/show".
gdb/testsuite/ChangeLog:
2019-07-03 Pedro Alves <palves@redhat.com>
* gdb.base/settings.exp: Replace all references to "maint
test-settings set" with references to "maint set test-settings",
and all references to "maint test-settings show" with references
to "maint show test-settings".
This makes "info threads" use the gdb::option framework to process
options. There's only one option today (-gid), and it isn't used much
frequently unless you're looking at matching MI output. Still, this
was in the neighborhood of "thread apply" so I had converted it.
The main advantage is that TAB completion now shows you the available
options, and gives you a hint to what the command accepts as operand
argument, including showing a metasyntactic variable:
(gdb) info threads [TAB]
-gid ID
(gdb) help info threads
Display currently known threads.
Usage: info threads [OPTION]... [ID]...
Options:
-gid
Show global thread IDs.
If ID is given, it is a space-separated list of IDs of threads to display.
Otherwise, all threads are displayed.
(gdb)
gdb/ChangeLog:
2019-07-02 Pedro Alves <palves@redhat.com>
* NEWS (Completion improvements): Mention "info threads".
* thread.c (struct info_threads_opts, info_threads_option_defs)
(make_info_threads_options_def_group): New.
(info_threads_command): Use gdb::option::process_options.
(info_threads_command_completer): New.
(_initialize_thread): Use gdb::option::build_help to build the
help text for "info threads".
gdb/testsuite/ChangeLog:
2019-07-02 Pedro Alves <palves@redhat.com>
* gdb.base/options.exp (test-info-threads): New procedure.
(top level): Call it.
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.
I noticed that a NEWS item about Python scripting changes appeared
between an item about a convenience function and an item about a
convenience variable. I think it's better for the latter to be next
to each other.
gdb/ChangeLog
2019-06-14 Tom Tromey <tromey@adacore.com>
* NEWS: Move convenience variable news above Python news.
gdb/ChangeLog:
2019-06-13 Pedro Alves <palves@redhat.com>
* NEWS (New commands): Mention "maint test-options
require-delimiter", "maint test-options unknown-is-error", "maint
test-options unknown-is-operand" and "maint show
test-options-completion-result".
(New command options, command completion): New section.
(Completion improvements): New section.
Mention that you can abbreviate "unlimited".
gdb/doc/ChangeLog:
2019-06-13 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Command Completion): Mention command options too.
(Command Options): New node.
(Threads): Add anchors. Extend descriptions of the "taas" and
"tfaas" commands.
(Backtrace): Describe new options of the "backtrace" command. Add
anchors.
(Frame Apply): Describe new options of the "frame apply" and
"faas" commands. Add anchors.
(Data): Describe new options of the "print" command. Add anchors.
(Compiling and Injecting Code): Mention options of the "compile
print" command.
(Maintenance Commands): Mention "maint test-options" subcommands
and the "maint show test-options-completion-result" command.
A following patch will introduce options for the "backtrace" command,
based on some "set print" and "set backtrace" settings. There's one
setting in particular that is a bit annoying if we want to describe
the backtrace options and the settings commands using the same data
structures:
"set print raw frame-arguments"
The problem is that space between "raw" and "frame-arguments".
Calling the option
"bt -raw frame-arguments"
would be odd. So I'm calling the option
"bt -raw-frame-arguments"
instead.
And for consistency, this patch renames the set/show commands to:
"set print raw-frame-arguments"
"show print raw-frame-arguments"
I.e., dash instead of space. The old commands are left in place, but
marked deprecated.
We need to adjust a couple testcases, because the relevant tests use
gdb_test_no_output and the old commands are no longer silent:
(gdb) set print raw frame-arguments on
Warning: command 'set print raw frame-arguments' is deprecated.
Use 'set print raw-frame-arguments'.
gdb/ChangeLog:
2019-06-13 Pedro Alves <palves@redhat.com>
* NEWS (Changed commands): Mention set/show print raw-frame-arguments,
and that "set/show print raw frame-arguments" are now deprecated.
* cli/cli-decode.c (add_setshow_boolean_cmd): Now returns the
command.
* command.h (add_setshow_boolean_cmd): Return cmd_list_element *.
* stack.c (_initialize_stack): Install "set/show print
raw-frame-arguments", and deprecate "set/show print raw
frame-arguments".
* valprint.c (_initialize_valprint): Deprecate "set/show print
raw".
gdb/doc/ChangeLog:
2019-06-13 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Print Settings): Document "set/show print
raw-frame-arguments" instead of "set/show print raw
frame-arguments".
gdb/testsuite/ChangeLog:
2019-06-13 Pedro Alves <palves@redhat.com>
* gdb.guile/scm-frame-args.exp: Use "set print
raw-frame-arguments" instead of "set print raw frame-arguments".
* gdb.python/py-frame-args.exp: Likewise.
This commit adds new representative commands for all types of settings
commands supported by gdb (enum var_types), and then uses them to
exercise settings parsing and completion.
(gdb) maint test-settings s[TAB]
set show
(gdb) maint test-settings set [TAB]
auto-boolean integer uinteger
boolean optional-filename zinteger
enum string zuinteger
filename string-noescape zuinteger-unlimited
(gdb) maint test-settings set enum [TAB]
xxx yyy zzz
etc.
This is basically unit testing, except that it goes fully via GDB. It
must be done this way in order to exercise TAB completion properly,
which must go via readline.
gdb/ChangeLog:
2019-06-13 Pedro Alves <palves@redhat.com>
* Makefile.in (COMMON_SFILES): Add maint-test-settings.c.
* NEWS: Mention maint test-settings KIND.
* maint-test-settings.c: New file.
gdb/doc/ChangeLog:
2019-06-13 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Maintenance Commands): Document "maint
test-settings" commands.
gdb/testsuite/ChangeLog:
2019-06-13 Pedro Alves <palves@redhat.com>
* gdb.base/settings.c: New file.
* gdb.base/settings.exp: New file.
This allows users of the Python API to find the objfile where a type
was defined.
gdb/ChangeLog:
gdb/ChangeLog
2019-06-04 Christian Biesinger <cbiesinger@google.com>
Add objfile property to gdb.Type.
* gdb/NEWS: Mention Python API addition.
* gdb/python/py-type.c (typy_get_objfile): New method.
gdb/doc/ChangeLog
2019-06-04 Christian Biesinger <cbiesinger@google.com>
* gdb/doc/python.texi: Document new gdb.Type.objfile property.
gdb/testsuite/ChangeLog
2019-06-04 Christian Biesinger <cbiesinger@google.com>
* gdb/testsuite/gdb.python/py-type.exp: Test for new
gdb.Type.objfile property.
A user wanted to be able to disable the display of the value when
using "finish" -- but still have the value entered into the value
history in case it was useful later on. Part of the rationale here is
that sometimes the value might be quite large, or expensive to display
(in their case this was compounded by a rogue pretty-printer).
This patch implements this idea.
gdb/ChangeLog
2019-05-29 Tom Tromey <tromey@adacore.com>
* NEWS: Add entry.
* infcmd.c (print_return_value_1): Handle finish_print
option.
(show_print_finish): New function.
(_initialize_infcmd): Add "set/show print finish" commands.
* valprint.c (user_print_options): Initialize new member.
* valprint.h (struct value_print_options) <finish_print>: New
member.
gdb/doc/ChangeLog
2019-05-29 Tom Tromey <tromey@adacore.com>
* gdb.texinfo (Continuing and Stepping): Document new
commands.
gdb/testsuite/ChangeLog
2019-05-29 Tom Tromey <tromey@adacore.com>
* gdb.base/finish.exp (finish_no_print): New proc.
(finish_tests): Call it.
Add missing documentation for the debugredirect setting.
Add description and uses of gdb.in/gdb.cmd to the testsuite README.
Mention this in the NEWS file.
gdb/ChangeLog:
* NEWS: Add debugredirect and testsuite sections.
gdb/doc/ChangeLog:
* gdb.texinfo (Shell Commands): Add debugredirect.
gdb/testsuite/ChangeLog:
* README (Re-running Tests Outside The Testsuite): New section.
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.
Commit 2e62ab400f added a second 'New commands' section to the NEWS
file, this commit merges the two together.
gdb/ChangeLog:
* NEWS: Merge two 'New commands' sections.
Introduce a new print setting max-depth which can be set with 'set
print max-depth DEPTH'. The default value of DEPTH is 20, but this
can also be set to unlimited.
When GDB is printing a value containing nested structures GDB will
stop descending at depth DEPTH. Here is a small example:
typedef struct s1 { int a; } s1;
typedef struct s2 { s1 b; } s2;
typedef struct s3 { s2 c; } s3;
typedef struct s4 { s3 d; } s4;
s4 var = { { { { 3 } } } };
The following table shows how various depth settings affect printing
of 'var':
| Depth Setting | Result of 'p var' |
|---------------+--------------------------------|
| Unlimited | $1 = {d = {c = {b = {a = 3}}}} |
| 4 | $1 = {d = {c = {b = {a = 3}}}} |
| 3 | $1 = {d = {c = {b = {...}}}} |
| 2 | $1 = {d = {c = {...}}} |
| 1 | $1 = {d = {...}} |
| 0 | $1 = {...} |
Only structures, unions, and arrays are replaced in this way, scalars
and strings are not replaced.
The replacement is counted from the level at which you print, not from
the top level of the structure. So, consider the above example and
this GDB session:
(gdb) set print max-depth 2
(gdb) p var
$1 = {d = {c = {...}}}
(gdb) p var.d
$2 = {c = {b = {...}}}
(gdb) p var.d.c
$3 = {b = {a = 3}}
Setting the max-depth to 2 doesn't prevent the user from exploring
deeper into 'var' by asking for specific sub-fields to be printed.
The motivation behind this feature is to try and give the user more
control over how much is printed when examining large, complex data
structures.
The default max-depth of 20 means that there is a change in GDB's
default behaviour. Someone printing a data structure with 20 levels
of nesting will now see '{...}' instead of their data, they would need
to adjust the max depth, or call print again naming a specific field
in order to dig deeper into their data structure. If this is
considered a problem then we could increase the default, or even make
the default unlimited.
This commit relies on the previous commit, which added a new field to
the language structure, this new field was a string that contained the
pattern that should be used when a structure/union/array is replaced
in the output, this allows languages to use a syntax that is more
appropriate, mostly this will be selecting the correct types of
bracket '(...)' or '{...}', both of which are currently in use.
This commit should have no impact on MI output, expressions are
printed through the MI using -var-create and then -var-list-children.
As each use of -var-list-children only ever displays a single level of
an expression then the max-depth setting will have no impact.
This commit also adds the max-depth mechanism to the scripting
language pretty printers following basically the same rules as for the
built in value printing.
One quirk is that when printing a value using the display hint 'map',
if the keys of the map are structs then GDB will hide the keys one
depth level after it hides the values, this ensures that GDB produces
output like this:
$1 = map_object = {[{key1}] = {...}, [{key2}] = {...}}
Instead of this less helpful output:
$1 = map_object = {[{...}] = {...}, [{...}] = {...}}
This is covered by the new tests in gdb.python/py-nested-maps.exp.
gdb/ChangeLog:
* cp-valprint.c (cp_print_value_fields): Allow an additional level
of depth when printing anonymous structs or unions.
* guile/scm-pretty-print.c (gdbscm_apply_val_pretty_printer):
Don't print either the top-level value, or the children if the
max-depth is exceeded.
(ppscm_print_children): When printing the key of a map, allow one
extra level of depth.
* python/py-prettyprint.c (gdbpy_apply_val_pretty_printer): Don't
print either the top-level value, or the children if the max-depth
is exceeded.
(print_children): When printing the key of a map, allow one extra
level of depth.
* python/py-value.c (valpy_format_string): Add max_depth keyword.
* valprint.c: (PRINT_MAX_DEPTH_DEFAULT): Define.
(user_print_options): Initialise max_depth field.
(val_print_scalar_or_string_type_p): New function.
(val_print): Check to see if the max depth has been reached.
(val_print_check_max_depth): Define new function.
(show_print_max_depth): New function.
(_initialize_valprint): Add 'print max-depth' option.
* valprint.h (struct value_print_options) <max_depth>: New field.
(val_print_check_max_depth): Declare new function.
* NEWS: Document new feature.
gdb/doc/ChangeLog:
* gdb.texinfo (Print Settings): Document 'print max-depth'.
* guile.texi (Guile Pretty Printing API): Document that 'print
max-depth' can effect the display of a values children.
* python.texi (Pretty Printing API): Likewise.
(Values From Inferior): Document max_depth keyword.
gdb/testsuite/ChangeLog:
* gdb.base/max-depth.c: New file.
* gdb.base/max-depth.exp: New file.
* gdb.python/py-nested-maps.c: New file.
* gdb.python/py-nested-maps.exp: New file.
* gdb.python/py-nested-maps.py: New file.
* gdb.python/py-format-string.exp (test_max_depth): New proc.
(test_all_common): Call test_max_depth.
* gdb.fortran/max-depth.exp: New file.
* gdb.fortran/max-depth.f90: New file.
* gdb.go/max-depth.exp: New file.
* gdb.go/max-depth.go: New file.
* gdb.modula2/max-depth.exp: New file.
* gdb.modula2/max-depth.c: New file.
* lib/gdb.exp (get_print_expr_at_depths): New proc.
Inferior function calls are powerful but might lead to undesired
results such as crashes when calling nested functions (frequently
used in particular in Ada).
This implements a GDB setting to disable calling inferior functions.
Note: the idea is that if/when the 'slash command' patch is pushed,
that this setting can be changed e.g. by using the shortcut /c.
This is version 2 of the patch. It handles all the received comments,
mostly replace 'can-call' by 'may-call', and avoid using
'inferior function call' in factor of 'calling function in the program'.
2019-04-26 Philippe Waroquiers <philippe.waroquiers@skynet.be>
gdb/ChangeLog
* NEWS: Mention the new set|show may-call-functions.
* infcall.c (may_call_functions_p): New variable.
(show_may_call_functions_p): New function.
(call_function_by_hand_dummy): Throws an error if not
may-call-functions.
(_initialize_infcall): Call add_setshow_boolean_cmd for
may-call-functions.
gdb/testsuite/ChangeLog
* gdb.base/callexit.exp: Test may-call-functions off.
gdb/doc/ChangeLog
* gdb.texinfo (Calling): Document the new
set|show may-call-functions.
Add two new internal functions $_cimag and $_creal that extract the
imaginary and real parts of a complex value.
These internal functions can take a complex value of any type 'float
complex', 'double complex', or 'long double complex' and return a
suitable floating point value 'float', 'double', or 'long double'.
So we can now do this:
(gdb) p z1
$1 = 1.5 + 4.5 * I
(gdb) p $_cimag (z1)
$4 = 4.5
(gdb) p $_creal (z1)
$4 = 1.5
The components of a complex value are not strictly named types in
DWARF, as the complex type is itself the base type. However, once we
are able to extract the components it makes sense to be able to ask
what the type of these components is and get a sensible answer back,
rather than the error we would currently get. Currently GDB says:
(gdb) ptype z1
type = complex double
(gdb) p $_cimag (z1)
$4 = 4.5
(gdb) ptype $
type = <invalid type code 9>
With the changes in dwarf2read.c, GDB now says:
(gdb) ptype z1
type = complex double
(gdb) p $_cimag (z1)
$4 = 4.5
(gdb) ptype $
type = double
Which seems to make more sense.
gdb/ChangeLog:
* NEWS: Mention new internal functions.
* dwarf2read.c (dwarf2_init_complex_target_type): New function.
(read_base_type): Use dwarf2_init_complex_target_type.
* value.c (creal_internal_fn): New function.
(cimag_internal_fn): New function.
(_initialize_values): Register new internal functions.
gdb/doc/ChangeLog:
* gdb.texinfo (Convenience Funs): Document '$_creal' and
'$_cimag'.
gdb/testsuite/ChangeLog:
* gdb.base/complex-parts.c: New file.
* gdb.base/complex-parts.exp: New file.
The str () function, called on a gdb.Value instance, produces a string
representation similar to what can be achieved with the print command,
but it doesn't allow to specify additional formatting settings, for
instance disabling pretty printers.
This patch introduces a new format_string () method to gdb.Value which
allows specifying more formatting options, thus giving access to more
features provided by the internal C function common_val_print ().
gdb/ChangeLog:
2019-04-01 Marco Barisione <mbarisione@undo.io>
Add gdb.Value.format_string ().
* python/py-value.c (copy_py_bool_obj):
(valpy_format_string): Add gdb.Value.format_string ().
* NEWS: Document the addition of gdb.Value.format_string ().
gdb/doc/ChangeLog:
2019-04-01 Marco Barisione <mbarisione@undo.io>
* python.texi (Values From Inferior): Document
gdb.Value.format_string ().
gdb/testsuite/ChangeLog:
2019-04-01 Marco Barisione <mbarisione@undo.io>
Test gdb.Value.format_string ().
* gdb.python/py-format-string.exp: New test.
* gdb.python/py-format-string.c: New file.
* gdb.python/py-format-string.py: New file.
New in v2:
- Addressed comments about doc, updated the MI version table
- New doc for the Breakpoint information format
- New -fix-multi-location-breakpoint-output command, with associated
doc, test and NEWS updated accordingly
- Fixed the output, the locations list is now actually in the tuple
representing the breakpoint.
Various MI commands or events related to breakpoints output invalid MI
records when printing information about a multi-location breakpoint.
For example:
-break-insert allo
^done,bkpt={...,addr="<MULTIPLE>",...},{number="1.1",...},{number="1.2",...}
The problem is that according to the syntax [1], the top-level elements
are of type "result" and should be of the form "variable=value".
This patch changes the output to wrap the locations in a list:
^done,bkpt={...,addr="<MULTIPLE>",locations=[{number="1.1",...},{number="1.2",...}]}
The events =breakpoint-created, =breakpoint-modified, as well as the
-break-info command also suffer from this (and maybe others I didn't
find).
Since this is a breaking change for MI, we have to deal somehow with
backwards compatibility. The approach taken by this patch is to bump
the MI version, use the new syntax in MI3 while retaining the old syntax
in MI2. Frontends are expected to use a precise MI version (-i=mi2), so
if they do that they should be unaffected.
The patch also adds the command -fix-multi-location-breakpoint-output,
which front ends can use to enable this behavior with MI <= 2.
[1] https://sourceware.org/gdb/onlinedocs/gdb/GDB_002fMI-Output-Syntax.html#GDB_002fMI-Output-Syntax
gdb/ChangeLog:
* NEWS: Mention that the new default MI version is 3. Mention
changes to the output of commands and events that deal with
multi-location breakpoints.
* breakpoint.c: Include "mi/mi-out.h".
(print_one_breakpoint): Change output syntax if using MI version
>= 3.
* mi/mi-main.h (mi_cmd_fix_multi_location_breakpoint_output):
New.
(mi_multi_location_breakpoint_output_fixed): New.
* mi/mi-main.c (fix_multi_location_breakpoint_output): New.
(mi_cmd_fix_multi_location_breakpoint_output): New.
(mi_multi_location_breakpoint_output_fixed): New.
* mi/mi-cmds.c (mi_cmds): Register command
-fix-multi-location-breakpoint-output.
* mi/mi-out.c (mi_out_new): Instantiate version 3 when using
interpreter "mi".
gdb/testsuite/ChangeLog:
* mi-breakpoint-location-ena-dis.exp: Rename to ...
* mi-breakpoint-multiple-locations.exp: ... this.
(make_breakpoints_pattern): New proc.
(do_test): Add mi_version parameter, test -break-insert,
-break-info and =breakpoint-created.
gdb/doc/ChangeLog:
* gdb.texinfo (Mode Options): Mention mi3.
(Interpreters): Likewise.
(GDB/MI Development and Front Ends): Add entry for MI 3 in
version table. Document -fix-multi-location-breakpoint-output.
(GDB/MI Breakpoint Information): Document format of breakpoint
location output.
gdb/ChangeLog:
* NEWS: Mention two argument form of gdb.Value constructor.
gdb/doc/ChangeLog:
* python.texi (Values From Inferior): Document second form
of Value.__init__.
2019-01-09 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* NEWS: Move the description of the changed "frame", "select-frame",
and "info frame" commands to the Changed commands section.
An upcoming sync with gcc's libiberty [1] will remove support for old
mangling schemes (GNU v2, Lucid, ARM, HP and EDG). It will remove the
cplus_demangle_opname function, so we need to get rid of its usages in
GDB (it's a GNU v2 specific function).
I think the changes are mostly relatively obvious, some hacks that were
necessary to support overloaded operators with GNU v2 mangling are not
needed anymore.
The change in stabsread.c is perhaps less obvious. I think we could get
rid of more code in that region that is specific to old mangling
schemes, but I chose to do only the minimal changes required to remove
the cplus_demangle_opname uses. There is also a detailed comment just
above that explaining how GNU v2 and v3 mangled symbols are handled, I
decided to leave it as-is, since I wasn't sure which part to remove,
change or leave there.
[1] The commit "Remove support for demangling GCC 2.x era mangling
schemes.", specifically.
gdb/ChangeLog:
* gdbtypes.c (check_stub_method_group): Remove handling of old
mangling schemes.
* linespec.c (find_methods): Likewise.
* stabsread.c (read_member_functions): Likewise.
* valops.c (search_struct_method): Likewise.
(value_struct_elt_for_reference): Likewise.
* NEWS: Mention this change.
gdb/testsuite/ChangeLog:
* gdb.cp/demangle.exp (test_gnu_style_demangling): Rename to...
(test_gnuv3_style_demangling): ... this.
(test_lucid_style_demangling): Remove.
(test_arm_style_demangling): Remove.
(test_hp_style_demangling): Remove.
(do_tests): Remove calls to the above.
gdb/doc/ChangeLog:
* gdb.texinfo (Print Settings): Remove mention of specific
demangle-style values, just refer to the in-process help.
This documents the new "set style" commands.
gdb/ChangeLog
2018-12-28 Tom Tromey <tom@tromey.com>
* NEWS: Mention terminal styling.
gdb/doc/ChangeLog
2018-12-28 Tom Tromey <tom@tromey.com>
* gdb.texinfo (Output Styling): New node.
When setting a syscall catchpoint by name, catch syscalls whose name
or alias matches the requested string.
When the ABI of a system call is changed in the FreeBSD kernel, this
is implemented by leaving a compatibility system call using the old
ABI at the existing "slot" and allocating a new system call for the
version using the new ABI. For example, new fields were added to the
'struct kevent' used by the kevent() system call in FreeBSD 12. The
previous kevent() system call in FreeBSD 12 kernels is now called
freebsd11_kevent() and is still used by older binaries compiled
against the older ABI. The freebsd11_kevent() system call can be
tagged with an "alias" attribute of "kevent" permitting 'catch syscall
kevent' to catch both system calls and providing the expected user
behavior for both old and new binaries. It also provides the expected
behavior if GDB is compiled on an older host (such as a FreeBSD 11
host).
gdb/ChangeLog:
* NEWS: Add entry documenting system call aliases.
* break-catch-syscall.c (catch_syscall_split_args): Pass 'result'
to get_syscalls_by_name.
* gdbarch.sh (UNKNOWN_SYSCALL): Remove.
* gdbarch.h: Regenerate.
* syscalls/gdb-syscalls.dtd (syscall): Add alias attribute.
* xml-syscall.c [!HAVE_LIBEXPAT] (get_syscalls_by_name): Rename
from get_syscall_by_name. Now accepts a pointer to a vector of
integers and returns a bool.
[HAVE_LIBEXPAT] (struct syscall_desc): Add alias member.
(syscall_create_syscall_desc): Add alias parameter and pass it to
syscall_desc constructor.
(syscall_start_syscall): Handle alias attribute.
(syscall_attr): Add alias attribute.
(xml_get_syscalls_by_name): Rename from xml_get_syscall_number.
Now accepts a pointer to a vector of integers and returns a
bool. Add syscalls whose alias or name matches the requested
name.
(get_syscalls_by_name): Rename from get_syscall_by_name. Now
accepts a pointer to a vector of integers and returns a bool.
* xml-syscall.h (get_syscalls_by_name): Likewise.
gdb/doc/ChangeLog:
* gdb.texinfo (Set Catchpoints): Add an anchor for 'catch syscall'.
(Native): Add a FreeBSD subsection.
(FreeBSD): Document use of system call aliases for compatibility
system calls.
This commit adds target description support for riscv.
I've used the split feature approach for specifying the architectural
features, and the CSR feature is auto-generated from the riscv-opc.h
header file.
If the target doesn't provide a suitable target description then GDB
will build one by looking at the bfd headers.
This commit does not implement target description creation for the
Linux or FreeBSD native targets, both of these will need to add
read_description methods into their respective target classes, which
probe the target features, and then call
riscv_create_target_description to build a suitable target
description. Until this is done Linux and FreeBSD will get the same
default target description based on the bfd that bare-metal targets
get.
I've only added feature descriptions for 32 and 64 bit registers, 128
bit registers (for RISC-V) are not supported in the reset of GDB yet.
This commit removes the special reading of the MISA register in order
to establish the target features, this was only used for figuring out
the f-register size, and even that wasn't done consistently. We now
rely on the target to tell us what size of registers it has (or look
in the BFD as a last resort). The result of this is that we should
now support RV64 targets with 32-bit float, though I have not
extensively tested this combination yet.
* Makefile.in (ALL_TARGET_OBS): Add arch/riscv.o.
(HFILES_NO_SRCDIR): Add arch/riscv.h.
* arch/riscv.c: New file.
* arch/riscv.h: New file.
* configure.tgt: Add cpu_obs list of riscv, move riscv-tdep.o into
this list, and add arch/riscv.o.
* features/Makefile: Add riscv features.
* features/riscv/32bit-cpu.c: New file.
* features/riscv/32bit-cpu.xml: New file.
* features/riscv/32bit-csr.c: New file.
* features/riscv/32bit-csr.xml: New file.
* features/riscv/32bit-fpu.c: New file.
* features/riscv/32bit-fpu.xml: New file.
* features/riscv/64bit-cpu.c: New file.
* features/riscv/64bit-cpu.xml: New file.
* features/riscv/64bit-csr.c: New file.
* features/riscv/64bit-csr.xml: New file.
* features/riscv/64bit-fpu.c: New file.
* features/riscv/64bit-fpu.xml: New file.
* features/riscv/rebuild-csr-xml.sh: New file.
* riscv-tdep.c: Add 'arch/riscv.h' include.
(riscv_gdb_reg_names): Delete.
(csr_reggroup): New global.
(struct riscv_register_alias): Delete.
(struct riscv_register_feature): New structure.
(riscv_register_aliases): Delete.
(riscv_xreg_feature): New global.
(riscv_freg_feature): New global.
(riscv_virtual_feature): New global.
(riscv_csr_feature): New global.
(riscv_create_csr_aliases): New function.
(riscv_read_misa_reg): Delete.
(riscv_has_feature): Delete.
(riscv_isa_xlen): Simplify, just return cached xlen.
(riscv_isa_flen): Simplify, just return cached flen.
(riscv_has_fp_abi): Update for changes in struct gdbarch_tdep.
(riscv_register_name): Update to make use of tdesc_register_name.
Look up xreg and freg names in the new globals riscv_xreg_feature
and riscv_freg_feature. Don't supply csr aliases here.
(riscv_fpreg_q_type): Delete.
(riscv_register_type): Use tdesc_register_type in almost all
cases, override the returned type in a few specific cases only.
(riscv_print_one_register_info): Handle errors reading registers.
(riscv_register_reggroup_p): Use tdesc_register_in_reggroup_p for
registers that are otherwise unknown to GDB. Also check the
csr_reggroup.
(riscv_print_registers_info): Remove assert about upper register
number, and use gdbarch_register_reggroup_p instead of
short-cutting.
(riscv_find_default_target_description): New function.
(riscv_check_tdesc_feature): New function.
(riscv_add_reggroups): New function.
(riscv_setup_register_aliases): New function.
(riscv_init_reggroups): New function.
(_initialize_riscv_tdep): Add calls to setup CSR aliases, and
setup register groups. Register new riscv debug variable.
* riscv-tdep.h: Add 'arch/riscv.h' include.
(struct gdbarch_tdep): Remove abi union, and add
riscv_gdbarch_features field. Remove cached quad floating point
type, and provide initialisation for double type field.
* target-descriptions.c (maint_print_c_tdesc_cmd): Add riscv to
the list of targets using the feature based target descriptions.
* NEWS: Mention target description support.
gdb/doc/ChangeLog:
* gdb.texinfo (Standard Target Features): Add RISC-V Features
sub-section.
gdb/ChangeLog
2018-11-20 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* NEWS: Document the language choice done by
'info [types|functions|variables]|rbreak'.
This patch adds support for debugging Ravenscar tasks, similar to what
is done for ppc and sparc.
gdb/ChangeLog:
* aarch64-ravenscar-thread.h, aarch64-ravenscar-thread.c:
New files.
* aarch64-tdep.c: #include "aarch64-ravenscar-thread.h".
(aarch64_gdbarch_init): Add call to register_aarch64_ravenscar_ops.
* Makefile.in (ALL_64_TARGET_OBS): Add aarch64-ravenscar-thread.o.
(HFILES_NO_SRCDIR): Add aarch64-ravenscar-thread.h.
(ALLDEPFILES): Add aarch64-ravenscar-thread.c.
* configure.tgt (cpu_obs) [aarch64*-*-*]: Add ravenscar-thread.o
and aarch64-ravenscar-thread.o.
* NEWS: Add entry documenting Ravenscar tasking support
on AArch64 ELF.
Announce changes in NEWS to info [args|functions|locals|variables]
gdb/ChangeLog
2018-10-27 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* NEWS: Mention changes to 'info [args|functions|locals|variables]'
This patch adds support for Hardware Transactional Memory registers
for the powerpc linux native and core file targets, and for the
pwoerpc linux server stub.
These registers include both the HTM special-purpose registers (TFHAR,
TEXASR and TFIAR) as well as the set of registers that are
checkpointed (saved) when a transaction is initiated, which the
processor restores in the event of a transaction failure.
The set of checkpointed general-purpose registers is returned by the
linux kernel in the same format as the regular general-purpose
registers, defined in struct pt_regs. However, the architecture
specifies that only some of the registers present in pt_regs are
checkpointed (GPRs 0-31, CR, XER, LR and CTR). The kernel fills the
slots for MSR and NIP with other info. The other fields usually don't
have meaningful values. GDB doesn't define registers that are not
checkpointed in the architecture, but when generating a core file, GDB
fills the slot for the checkpointed MSR with the regular MSR. These
are usually similar, although some bits might be different, and in
some cases the checkpointed MSR will have a value of 0 in a
kernel-generated core-file. The checkpointed NIP is filled with TFHAR
by GDB in the core-file, which is what the kernel does. The other
fields are set to 0 by GDB.
Core files generated by the kernel have a note section for
checkpointed GPRs with the same size for both 32-bit and 64-bit
threads, and the values for the registers of a 32-bit thread are
squeezed in the first half, with no useful data in the second half.
GDB generates a smaller note section for 32-bit threads, but can read
both sizes.
The checkpointed XER is required to be 32-bit in the target
description documentation, even though the more recent ISAs define it
as 64-bit wide, since the high-order 32-bits are reserved, and because
in Linux there is no way to get a 64-bit checkpointed XER for 32-bit
threads. If this changes in the future, the target description
feature requirement can be relaxed to allow for a 64-bit checkpointed
XER.
Access to the checkpointed CR (condition register) can be confusing.
The architecture only specifies that CR fields 1 to 7 (the 24 least
significant bits) are checkpointed, but the kernel provides all 8
fields (32 bits). The value of field 0 is not masked by ptrace, so it
will sometimes show the result of some kernel operation, probably
treclaim., which sets this field.
The checkpointed registers are marked not to be saved and restored.
Inferior function calls during an active transaction don't work well,
and it's unclear what should be done in this case. TEXASR and TFIAR
can be altered asynchronously, during transaction failure recording,
so they are also not saved and restored. For consistency neither is
TFHAR.
Record and replay also doesn't work well when transactions are
involved. This patch doesn't address this, so the values of the HTM
SPRs will sometimes be innacurate when the record/relay target is
enabled. For instance, executing a "tbegin." alters TFHAR and TEXASR,
but these changes are not currently recorded.
Because the checkpointed registers are only available when a
transaction is active (or suspended), ptrace can return ENODATA when
gdb tries to read these registers and the inferior is not in a
transactional state. The registers are set to the unavailable state
when this happens. When gbd tries to write to one of these registers,
and it is unavailable, an error is raised.
The "fill" functions for checkpointed register sets in the server stub
are not implemented for the same reason as for the EBB register set,
since ptrace can also return ENODATA for checkpointed regsets. The
same issues with 'G' packets apply here.
Just like for the EBB registers, tracepoints will not mark the
checkpointed registers as unavailable if the inferior was not in a
transaction, so their content will also show 0 instead of
<unavailable> when inspecting trace data.
The new tests record the values of the regular registers before
stepping the inferior through a "tbegin." instruction to start a
transaction, then the checkpointed registers are checked against the
recorded pre-transactional values. New values are written to the
checkpointed registers and recorded, the inferior continues until the
transaction aborts (which is usually immediately when it is resumed),
and the regular registers are checked against the recorded values,
because the abort should have reverted the registers to these values.
Like for the EBB registers, target_store_registers will ignore the
checkpointed registers when called with -1 as the regno
argument (store all registers in one go).
gdb/ChangeLog:
2018-10-26 Edjunior Barbosa Machado <emachado@linux.vnet.ibm.com>
Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
* arch/ppc-linux-tdesc.h (tdesc_powerpc_isa207_htm_vsx32l)
(tdesc_powerpc_isa207_htm_vsx64l): Declare.
* arch/ppc-linux-common.h (PPC_LINUX_SIZEOF_TM_SPRREGSET)
(PPC32_LINUX_SIZEOF_CGPRREGSET, PPC64_LINUX_SIZEOF_CGPRREGSET)
(PPC_LINUX_SIZEOF_CFPRREGSET, PPC_LINUX_SIZEOF_CVMXREGSET)
(PPC_LINUX_SIZEOF_CVSXREGSET, PPC_LINUX_SIZEOF_CPPRREGSET)
(PPC_LINUX_SIZEOF_CDSCRREGSET, PPC_LINUX_SIZEOF_CTARREGSET):
Define.
(struct ppc_linux_features) <htm>: New field.
(ppc_linux_no_features): Add initializer for htm field.
* arch/ppc-linux-common.c (ppc_linux_match_description): Return
new tdescs.
* nat/ppc-linux.h (PPC_FEATURE2_HTM, NT_PPC_TM_CGPR)
(NT_PPC_TM_CFPR, NT_PPC_TM_CVMX, NT_PPC_TM_CVSX)
(NT_PPC_TM_SPR, NT_PPC_TM_CTAR, NT_PPC_TM_CPPR, NT_PPC_TM_CDSCR):
Define if not already defined.
* features/Makefile (WHICH): Add rs6000/powerpc-isa207-htm-vsx32l
and rs6000/powerpc-isa207-htm-vsx64l.
(XMLTOC): Add rs6000/powerpc-isa207-htm-vsx32l.xml and
rs6000/powerpc-isa207-htm-vsx64l.xml.
* features/rs6000/power-htm-spr.xml: New file.
* features/rs6000/power-htm-core.xml: New file.
* features/rs6000/power64-htm-core.xml: New file.
* features/rs6000/power-htm-fpu.xml: New file.
* features/rs6000/power-htm-altivec.xml: New file.
* features/rs6000/power-htm-vsx.xml: New file.
* features/rs6000/power-htm-ppr.xml: New file.
* features/rs6000/power-htm-dscr.xml: New file.
* features/rs6000/power-htm-tar.xml: New file.
* features/rs6000/powerpc-isa207-htm-vsx32l.xml: New file.
* features/rs6000/powerpc-isa207-htm-vsx64l.xml: New file.
* features/rs6000/powerpc-isa207-htm-vsx32l.c: Generate.
* features/rs6000/powerpc-isa207-htm-vsx64l.c: Generate.
* regformats/rs6000/powerpc-isa207-htm-vsx32l.dat: Generate.
* regformats/rs6000/powerpc-isa207-htm-vsx64l.dat: Generate.
* ppc-linux-nat.c (fetch_register, fetch_ppc_registers): Call
fetch_regset with HTM regsets.
(store_register, store_ppc_registers): Call store_regset with HTM
regsets.
(ppc_linux_nat_target::read_description): Set htm field in the
features struct if needed.
* ppc-linux-tdep.c: Include
features/rs6000/powerpc-isa207-htm-vsx32l.c and
features/rs6000/powerpc-isa207-htm-vsx64l.c.
(ppc32_regmap_tm_spr, ppc32_regmap_cgpr, ppc64_le_regmap_cgpr)
(ppc64_be_regmap_cgpr, ppc32_regmap_cfpr, ppc32_le_regmap_cvmx)
(ppc32_be_regmap_cvmx, ppc32_regmap_cvsx, ppc32_regmap_cppr)
(ppc32_regmap_cdscr, ppc32_regmap_ctar): New globals.
(ppc32_linux_tm_sprregset, ppc32_linux_cgprregset)
(ppc64_be_linux_cgprregset, ppc64_le_linux_cgprregset)
(ppc32_linux_cfprregset, ppc32_le_linux_cvmxregset)
(ppc32_be_linux_cvmxregset, ppc32_linux_cvsxregset)
(ppc32_linux_cpprregset, ppc32_linux_cdscrregset)
(ppc32_linux_ctarregset): New globals.
(ppc_linux_cgprregset, ppc_linux_cvmxregset): New functions.
(ppc_linux_collect_core_cpgrregset): New function.
(ppc_linux_iterate_over_regset_sections): Call back with the htm
regsets.
(ppc_linux_core_read_description): Check if the tm spr section is
present and set htm in the features struct.
(_initialize_ppc_linux_tdep): Call
initialize_tdesc_powerpc_isa207_htm_vsx32l and
initialize_tdesc_powerpc_isa207_htm_vsx64l.
* ppc-linux-tdep.h (ppc_linux_cgprregset, ppc_linux_cvmxregset):
Declare.
(ppc32_linux_tm_sprregset, ppc32_linux_cfprregset)
(ppc32_linux_cvsxregset, ppc32_linux_cpprregset)
(ppc32_linux_cdscrregset, ppc32_linux_ctarregset): Declare.
* ppc-tdep.h (struct gdbarch_tdep) <have_htm_spr, have_htm_core>:
New fields.
<have_htm_fpu, have_htm_altivec, have_htm_vsx>:
Likewise.
<ppc_cppr_regnum, ppc_cdscr_regnum, ppc_ctar_regnum>: Likewise.
<ppc_cdl0_regnum, ppc_cvsr0_regnum, ppc_cefpr0_regnum>: Likewise.
(enum) <PPC_TFHAR_REGNUM, PPC_TEXASR_REGNUM, PPC_TFIAR_REGNUM>:
New enum fields.
<PPC_CR0_REGNUM, PPC_CCR_REGNUM, PPC_CXER_REGNUM>: Likewise.
<PPC_CLR_REGNUM, PPC_CCTR_REGNUM, PPC_CF0_REGNUM>: Likewise.
<PPC_CFPSCR_REGNUM, PPC_CVR0_REGNUM, PPC_CVSCR_REGNUM>: Likewise.
<PPC_CVRSAVE_REGNUM, PPC_CVSR0_UPPER_REGNUM>: Likewise.
<PPC_CPPR_REGNUM, PPC_CDSCR_REGNUM>: Likewise.
<PPC_CTAR_REGNUM>: Likewise.
(PPC_IS_TMSPR_REGNUM, PPC_IS_CKPTGP_REGNUM, PPC_IS_CKPTFP_REGNUM)
(PPC_IS_CKPTVMX_REGNUM, PPC_IS_CKPTVSX_REGNUM): Define.
* rs6000-tdep.c (IS_CDFP_PSEUDOREG, IS_CVSX_PSEUDOREG)
(IS_CEFP_PSEUDOREG): Define.
(rs6000_register_name): Hide the upper halves of checkpointed VSX
registers. Return names for the checkpointed DFP, VSX, and EFP
pseudo registers.
(rs6000_pseudo_register_type): Remove initial assert and raise an
internal error in the else clause instead. Return types for the
checkpointed DFP, VSX, and EFP pseudo registers.
(dfp_pseudo_register_read, dfp_pseudo_register_write): Handle
checkpointed DFP pseudo registers.
(vsx_pseudo_register_read, vsx_pseudo_register_write): Handle
checkpointed VSX pseudo registers.
(efp_pseudo_register_read, efp_pseudo_register_write): Rename
from efpr_pseudo_register_read and
efpr_pseudo_register_write. Handle checkpointed EFP pseudo
registers.
(rs6000_pseudo_register_read, rs6000_pseudo_register_write):
Handle checkpointed DFP, VSX, and EFP registers.
(dfp_ax_pseudo_register_collect, vsx_ax_pseudo_register_collect)
(efp_ax_pseudo_register_collect): New functions.
(rs6000_ax_pseudo_register_collect): Move DFP, VSX and EFP pseudo
register logic to new functions. Handle checkpointed DFP, VSX,
and EFP pseudo registers.
(rs6000_gdbarch_init): Look for and validate the htm features.
Include checkpointed DFP, VSX and EFP pseudo-registers.
* NEWS: Mention access to PPR, DSCR, TAR, EBB/PMU registers and
HTM registers.
gdb/gdbserver/ChangeLog:
2018-10-26 Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
* configure.srv (ipa_ppc_linux_regobj): Add
powerpc-isa207-htm-vsx32l-ipa.o and
powerpc-isa207-htm-vsx64l-ipa.o.
(powerpc*-*-linux*): Add powerpc-isa207-htm-vsx32l.o and
powerpc-isa207-htm-vsx64l.o to srv_regobj. Add
rs6000/power-htm-spr.xml, rs6000/power-htm-core.xml,
rs6000/power64-htm-core.xml, rs6000/power-htm-fpu.xml,
rs6000/power-htm-altivec.xml, rs6000/power-htm-vsx.xml,
rs6000/power-htm-ppr.xml, rs6000/power-htm-dscr.xml,
rs6000/power-htm-tar.xml, rs6000/powerpc-isa207-htm-vsx32l.xml,
and rs6000/powerpc-isa207-htm-vsx64l.xml to srv_xmlfiles.
* linux-ppc-tdesc-init.h (enum ppc_linux_tdesc)
<PPC_TDESC_ISA207_HTM_VSX>: New enum value.
(init_registers_powerpc_isa207_htm_vsx32l)
(init_registers_powerpc_isa207_htm_vsx64l): Declare.
* linux-ppc-low.c (ppc_fill_tm_sprregset, ppc_store_tm_sprregset)
(ppc_store_tm_cgprregset, ppc_store_tm_cfprregset)
(ppc_store_tm_cvrregset, ppc_store_tm_cvsxregset)
(ppc_store_tm_cpprregset, ppc_store_tm_cdscrregset)
(ppc_store_tm_ctarregset): New functions.
(ppc_regsets): Add entries for HTM regsets.
(ppc_arch_setup): Set htm in features struct when needed. Set
sizes for the HTM regsets.
(ppc_get_ipa_tdesc_idx): Return PPC_TDESC_ISA207_HTM_VSX.
(initialize_low_arch): Call
init_registers_powerpc_isa207_htm_vsx32l and
init_registers_powerpc_isa207_htm_vsx64l.
* linux-ppc-ipa.c (get_ipa_tdesc): Handle
PPC_TDESC_ISA207_HTM_VSX.
(initialize_low_tracepoint): Call
init_registers_powerpc_isa207_htm_vsx32l and
init_registers_powerpc_isa207_htm_vsx64l.
gdb/testsuite/ChangeLog:
2018-10-26 Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
* gdb.arch/powerpc-htm-regs.c: New file.
* gdb.arch/powerpc-htm-regs.exp: New file.
gdb/doc/ChangeLog:
2018-10-26 Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
* gdb.texinfo (PowerPC Features): Describe new features
"org.gnu.gdb.power.htm.spr", "org.gnu.gdb.power.htm.core",
"org.gnu.gdb.power.htm.fpu", "org.gnu.gdb.power.htm.altivec",
"org.gnu.gdb.power.htm.vsx", "org.gnu.gdb.power.htm.ppr",
"org.gnu.gdb.power.htm.dscr", "org.gnu.gdb.power.htm.tar".