diff options
author | Tom Tromey <tromey@adacore.com> | 2023-08-31 13:58:49 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2023-09-07 14:04:53 -0600 |
commit | d1369de649a9d19abae1012ef805aaa674314c0c (patch) | |
tree | 4938931225e3f7155ca257c9fcbe74133d2e5e52 /gdb | |
parent | 78dfcce3174dbb9bd9d3a5898e57a9019dcc38d9 (diff) | |
download | gdb-d1369de649a9d19abae1012ef805aaa674314c0c.zip gdb-d1369de649a9d19abae1012ef805aaa674314c0c.tar.gz gdb-d1369de649a9d19abae1012ef805aaa674314c0c.tar.bz2 |
Fix bug in -var-evaluate-expression
This bug points out that if one uses -var-set-visualizer with "None"
-- to disable a pretty-printer for a varobj -- then
-var-evaluate-expression will still use pretty-printing.
This is a combination of bugs. First, setting the visualizer does not
update the display text; and second, computing the display text should
use "raw" when Python is available but no visualizer is desired.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=11738
Reviewed-by: Keith Seitz <keiths@redhat.com>
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/testsuite/gdb.python/py-varobj.c | 2 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-varobj.exp | 12 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-varobj.py | 4 | ||||
-rw-r--r-- | gdb/varobj.c | 9 |
4 files changed, 26 insertions, 1 deletions
diff --git a/gdb/testsuite/gdb.python/py-varobj.c b/gdb/testsuite/gdb.python/py-varobj.c index 894ce8f..88d0e74 100644 --- a/gdb/testsuite/gdb.python/py-varobj.c +++ b/gdb/testsuite/gdb.python/py-varobj.c @@ -21,6 +21,8 @@ struct test { struct test tval = {23}; +struct test *test_ptr = &tval; + int main () { return 0; } diff --git a/gdb/testsuite/gdb.python/py-varobj.exp b/gdb/testsuite/gdb.python/py-varobj.exp index 0e09783..f1eb352 100644 --- a/gdb/testsuite/gdb.python/py-varobj.exp +++ b/gdb/testsuite/gdb.python/py-varobj.exp @@ -47,3 +47,15 @@ mi_gdb_test "-var-create tval * tval" \ mi_gdb_test "-var-list-children --all-values tval" \ ".*value=.*flicker.*" + +mi_gdb_test "-var-create test_ptr * test_ptr" \ + "\\^done.*" + +mi_gdb_test "-var-evaluate-expression test_ptr" \ + "\\^done,value=\"map\"" +mi_gdb_test "-var-set-visualizer test_ptr None" \ + "\\^done.*" +# mi_gdb_test "-var-update test_ptr" ".*" +mi_gdb_test "-var-evaluate-expression test_ptr" \ + "\\^done,value=\"$hex.*\"" \ + "evaluate without visualizer" diff --git a/gdb/testsuite/gdb.python/py-varobj.py b/gdb/testsuite/gdb.python/py-varobj.py index bc31a19..578ad14 100644 --- a/gdb/testsuite/gdb.python/py-varobj.py +++ b/gdb/testsuite/gdb.python/py-varobj.py @@ -12,6 +12,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +import gdb import gdb.printing @@ -30,6 +31,7 @@ def str_lookup_function(val): lookup_tag = val.type.tag if lookup_tag == "test": return TestPrinter(val) - + if val.type.code == gdb.TYPE_CODE_PTR and val.type.target().tag == "test": + return TestPrinter(val.dereference()) gdb.printing.register_pretty_printer(None, str_lookup_function) diff --git a/gdb/varobj.c b/gdb/varobj.c index 3ae8d72..a4fcbff 100644 --- a/gdb/varobj.c +++ b/gdb/varobj.c @@ -1393,6 +1393,9 @@ varobj_set_visualizer (struct varobj *var, const char *visualizer) /* If there are any children now, wipe them. */ varobj_delete (var, 1 /* children only */); var->num_children = -1; + + /* Also be sure to reset the print value. */ + varobj_set_display_format (var, var->format); #else error (_("Python support required")); #endif @@ -2212,6 +2215,12 @@ varobj_value_get_print_value (struct value *value, return "{...}"; } } + else + { + /* If we've made it here, we don't want a pretty-printer -- + if we had one, it would already have been used. */ + opts.raw = true; + } } #endif |