mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-05-31 18:20:12 +08:00
Add address keyword to Value.format_string
This makes it possible to disable the address in the result string: const char *str = "alpha"; (gdb) py print(gdb.parse_and_eval("str").format_string()) 0x404000 "alpha" (gdb) py print(gdb.parse_and_eval("str").format_string(address=False)) "alpha" gdb/ChangeLog: 2020-12-18 Hannes Domani <ssbssa@yahoo.de> * python/py-value.c (valpy_format_string): Implement address keyword. gdb/doc/ChangeLog: 2020-12-18 Hannes Domani <ssbssa@yahoo.de> * python.texi (Values From Inferior): Document the address keyword. gdb/testsuite/ChangeLog: 2020-12-18 Hannes Domani <ssbssa@yahoo.de> * gdb.python/py-format-string.exp: Add tests for address keyword.
This commit is contained in:
@ -1,3 +1,7 @@
|
|||||||
|
2020-12-18 Hannes Domani <ssbssa@yahoo.de>
|
||||||
|
|
||||||
|
* python/py-value.c (valpy_format_string): Implement address keyword.
|
||||||
|
|
||||||
2020-12-18 Hannes Domani <ssbssa@yahoo.de>
|
2020-12-18 Hannes Domani <ssbssa@yahoo.de>
|
||||||
|
|
||||||
* python/py-type.c (typy_get_composite): Add TYPE_CODE_METHOD.
|
* python/py-type.c (typy_get_composite): Add TYPE_CODE_METHOD.
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
2020-12-18 Hannes Domani <ssbssa@yahoo.de>
|
||||||
|
|
||||||
|
* python.texi (Values From Inferior): Document the address keyword.
|
||||||
|
|
||||||
2020-12-17 Simon Marchi <simon.marchi@polymtl.ca>
|
2020-12-17 Simon Marchi <simon.marchi@polymtl.ca>
|
||||||
|
|
||||||
PR gdb/27088
|
PR gdb/27088
|
||||||
|
@ -906,6 +906,11 @@ corresponding symbol name (if one exists), @code{False} if it shouldn't
|
|||||||
should be expanded, @code{False} if they shouldn't (see @code{set print
|
should be expanded, @code{False} if they shouldn't (see @code{set print
|
||||||
union} in @ref{Print Settings}).
|
union} in @ref{Print Settings}).
|
||||||
|
|
||||||
|
@item address
|
||||||
|
@code{True} if the string representation of a pointer should include the
|
||||||
|
address, @code{False} if it shouldn't (see @code{set print address} in
|
||||||
|
@ref{Print Settings}).
|
||||||
|
|
||||||
@item deref_refs
|
@item deref_refs
|
||||||
@code{True} if C@t{++} references should be resolved to the value they
|
@code{True} if C@t{++} references should be resolved to the value they
|
||||||
refer to, @code{False} (the default) if they shouldn't. Note that, unlike
|
refer to, @code{False} (the default) if they shouldn't. Note that, unlike
|
||||||
|
@ -617,6 +617,7 @@ valpy_format_string (PyObject *self, PyObject *args, PyObject *kw)
|
|||||||
"array_indexes", /* See set print array-indexes on|off. */
|
"array_indexes", /* See set print array-indexes on|off. */
|
||||||
"symbols", /* See set print symbol on|off. */
|
"symbols", /* See set print symbol on|off. */
|
||||||
"unions", /* See set print union on|off. */
|
"unions", /* See set print union on|off. */
|
||||||
|
"address", /* See set print address on|off. */
|
||||||
/* C++ options. */
|
/* C++ options. */
|
||||||
"deref_refs", /* No corresponding setting. */
|
"deref_refs", /* No corresponding setting. */
|
||||||
"actual_objects", /* See set print object on|off. */
|
"actual_objects", /* See set print object on|off. */
|
||||||
@ -660,13 +661,14 @@ valpy_format_string (PyObject *self, PyObject *args, PyObject *kw)
|
|||||||
PyObject *array_indexes_obj = NULL;
|
PyObject *array_indexes_obj = NULL;
|
||||||
PyObject *symbols_obj = NULL;
|
PyObject *symbols_obj = NULL;
|
||||||
PyObject *unions_obj = NULL;
|
PyObject *unions_obj = NULL;
|
||||||
|
PyObject *address_obj = NULL;
|
||||||
PyObject *deref_refs_obj = NULL;
|
PyObject *deref_refs_obj = NULL;
|
||||||
PyObject *actual_objects_obj = NULL;
|
PyObject *actual_objects_obj = NULL;
|
||||||
PyObject *static_members_obj = NULL;
|
PyObject *static_members_obj = NULL;
|
||||||
char *format = NULL;
|
char *format = NULL;
|
||||||
if (!gdb_PyArg_ParseTupleAndKeywords (args,
|
if (!gdb_PyArg_ParseTupleAndKeywords (args,
|
||||||
kw,
|
kw,
|
||||||
"|O!O!O!O!O!O!O!O!O!IIIs",
|
"|O!O!O!O!O!O!O!O!O!O!IIIs",
|
||||||
keywords,
|
keywords,
|
||||||
&PyBool_Type, &raw_obj,
|
&PyBool_Type, &raw_obj,
|
||||||
&PyBool_Type, &pretty_arrays_obj,
|
&PyBool_Type, &pretty_arrays_obj,
|
||||||
@ -674,6 +676,7 @@ valpy_format_string (PyObject *self, PyObject *args, PyObject *kw)
|
|||||||
&PyBool_Type, &array_indexes_obj,
|
&PyBool_Type, &array_indexes_obj,
|
||||||
&PyBool_Type, &symbols_obj,
|
&PyBool_Type, &symbols_obj,
|
||||||
&PyBool_Type, &unions_obj,
|
&PyBool_Type, &unions_obj,
|
||||||
|
&PyBool_Type, &address_obj,
|
||||||
&PyBool_Type, &deref_refs_obj,
|
&PyBool_Type, &deref_refs_obj,
|
||||||
&PyBool_Type, &actual_objects_obj,
|
&PyBool_Type, &actual_objects_obj,
|
||||||
&PyBool_Type, &static_members_obj,
|
&PyBool_Type, &static_members_obj,
|
||||||
@ -696,6 +699,8 @@ valpy_format_string (PyObject *self, PyObject *args, PyObject *kw)
|
|||||||
return NULL;
|
return NULL;
|
||||||
if (!copy_py_bool_obj (&opts.unionprint, unions_obj))
|
if (!copy_py_bool_obj (&opts.unionprint, unions_obj))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
if (!copy_py_bool_obj (&opts.addressprint, address_obj))
|
||||||
|
return NULL;
|
||||||
if (!copy_py_bool_obj (&opts.deref_ref, deref_refs_obj))
|
if (!copy_py_bool_obj (&opts.deref_ref, deref_refs_obj))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (!copy_py_bool_obj (&opts.objectprint, actual_objects_obj))
|
if (!copy_py_bool_obj (&opts.objectprint, actual_objects_obj))
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
2020-12-18 Hannes Domani <ssbssa@yahoo.de>
|
||||||
|
|
||||||
|
* gdb.python/py-format-string.exp: Add tests for address keyword.
|
||||||
|
|
||||||
2020-12-18 Hannes Domani <ssbssa@yahoo.de>
|
2020-12-18 Hannes Domani <ssbssa@yahoo.de>
|
||||||
|
|
||||||
* gdb.python/py-type.exp: Add tests for TYPE_CODE_METHOD.
|
* gdb.python/py-type.exp: Add tests for TYPE_CODE_METHOD.
|
||||||
|
@ -487,6 +487,48 @@ proc test_unions {} {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Test the address option for gdb.Value.format_string.
|
||||||
|
proc test_address {} {
|
||||||
|
global undefined
|
||||||
|
global current_lang
|
||||||
|
|
||||||
|
check_var_with_bool_opt "address" "a_point_t"
|
||||||
|
check_var_with_bool_opt "address" "a_point_t_pointer" \
|
||||||
|
$undefined \
|
||||||
|
""
|
||||||
|
check_var_with_bool_opt "address" "another_point"
|
||||||
|
check_var_with_bool_opt "symbols" "a_struct_with_union"
|
||||||
|
check_var_with_bool_opt "address" "an_enum"
|
||||||
|
check_var_with_bool_opt "address" "a_string" \
|
||||||
|
$undefined \
|
||||||
|
"\"hello world\""
|
||||||
|
check_var_with_bool_opt "address" "a_binary_string" \
|
||||||
|
$undefined \
|
||||||
|
"\"hello\""
|
||||||
|
check_var_with_bool_opt "address" "a_binary_string_array"
|
||||||
|
check_var_with_bool_opt "address" "a_big_string"
|
||||||
|
check_var_with_bool_opt "address" "an_array"
|
||||||
|
check_var_with_bool_opt "address" "an_array_with_repetition"
|
||||||
|
check_var_with_bool_opt "address" "a_symbol_pointer" \
|
||||||
|
$undefined \
|
||||||
|
"<global_symbol>"
|
||||||
|
|
||||||
|
if { $current_lang == "c++" } {
|
||||||
|
check_var_with_bool_opt "address" "a_point_t_ref"
|
||||||
|
check_var_with_bool_opt "address" "a_base_ref" \
|
||||||
|
$undefined \
|
||||||
|
""
|
||||||
|
}
|
||||||
|
|
||||||
|
with_temp_option "set print address off" "set print address on" {
|
||||||
|
check_var_with_no_opts "a_string" \
|
||||||
|
"\"hello world\""
|
||||||
|
check_var_with_bool_opt "address" "a_string" \
|
||||||
|
$undefined \
|
||||||
|
"\"hello world\""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Test the deref_refs option for gdb.Value.format_string.
|
# Test the deref_refs option for gdb.Value.format_string.
|
||||||
proc test_deref_refs {} {
|
proc test_deref_refs {} {
|
||||||
global current_lang
|
global current_lang
|
||||||
@ -943,6 +985,7 @@ proc test_all_common {} {
|
|||||||
test_array_indexes
|
test_array_indexes
|
||||||
test_symbols
|
test_symbols
|
||||||
test_unions
|
test_unions
|
||||||
|
test_address
|
||||||
test_deref_refs
|
test_deref_refs
|
||||||
test_actual_objects
|
test_actual_objects
|
||||||
test_static_members
|
test_static_members
|
||||||
|
Reference in New Issue
Block a user