This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[unavailable values part 1, 14/17] make value repeat handle unavailableness
- From: Pedro Alves <pedro at codesourcery dot com>
- To: gdb-patches at sourceware dot org
- Date: Mon, 7 Feb 2011 14:34:25 +0000
- Subject: [unavailable values part 1, 14/17] make value repeat handle unavailableness
Given this uncollected array:
(gdb) p globalarr
$1 = {0, <unavailable> <repeats 15 times>}
bad:
(gdb) print *globalarr@2
Cannot access memory at address 0x6010a0
good:
(gdb) print *globalarr@2
$2 = {0, <unavailable>}
This patch fixes it by using the new read_value_memory function
instead of read_memory --- the former wraps the latter, but
understands unavailableness. New test included.
--
Pedro Alves
2011-02-07 Pedro Alves <pedro@codesourcery.com>
gdb/
* valops.c (value_repeat): Use read_value_memory instead of
read_memory.
gdb/testsuite/
* gdb.trace/unavailable.exp (gdb_collect_globals_test): Test that
value repeat handles unavailableness.
---
gdb/testsuite/gdb.trace/unavailable.exp | 3 +++
gdb/valops.c | 7 ++++---
2 files changed, 7 insertions(+), 3 deletions(-)
Index: src/gdb/testsuite/gdb.trace/unavailable.exp
===================================================================
--- src.orig/gdb/testsuite/gdb.trace/unavailable.exp 2011-02-07 13:18:21.426706000 +0000
+++ src/gdb/testsuite/gdb.trace/unavailable.exp 2011-02-07 13:22:15.776706000 +0000
@@ -155,6 +155,9 @@ proc gdb_collect_globals_test { } {
gdb_test_no_output "set print repeat 10"
+ # Check that value repeat handles unavailable-ness.
+ gdb_test "print *tarray@3" " = \\{\\{a = 0, b = <unavailable>\\}, \\{a = 0, b = <unavailable>\\}, \\{a = <unavailable>, b = <unavailable>\\}\\}"
+
# Static fields
gdb_test "print struct_b.static_struct_a" \
Index: src/gdb/valops.c
===================================================================
--- src.orig/gdb/valops.c 2011-02-07 13:18:21.426706000 +0000
+++ src/gdb/valops.c 2011-02-07 13:22:15.776706000 +0000
@@ -1456,12 +1456,13 @@ value_repeat (struct value *arg1, int co
val = allocate_repeat_value (value_enclosing_type (arg1), count);
- read_memory (value_address (arg1),
- value_contents_all_raw (val),
- TYPE_LENGTH (value_enclosing_type (val)));
VALUE_LVAL (val) = lval_memory;
set_value_address (val, value_address (arg1));
+ read_value_memory (val, 0, value_stack (val), value_address (val),
+ value_contents_all_raw (val),
+ TYPE_LENGTH (value_enclosing_type (val)));
+
return val;
}