- Fixup "bad type" internal error, import from FSF GDB.

- archer-jankratochvil-fedora12 commit:
    2ba2bc451eb832182ef84c3934115de7a329da7c
This commit is contained in:
Jan Kratochvil 2009-08-19 16:19:15 +00:00
parent 6370c17fdf
commit 0435006f87
3 changed files with 274 additions and 23 deletions

View File

@ -0,0 +1,237 @@
http://sourceware.org/ml/gdb-patches/2009-08/msg00310.html
http://sourceware.org/ml/gdb-cvs/2009-08/msg00092.html
2009-08-19 Ulrich Weigand <uweigand@de.ibm.com>
* value.c (enum internalvar_kind): Replace INTERNALVAR_SCALAR by
INTERNALVAR_INTEGER and INTERNALVAR_POINTER.
(union internalvar_data): Replace "scalar" member by "integer"
and "pointer".
(value_of_internalvar): Handle INTERNALVAR_INTEGER and
INTERNALVAR_POINTER instead of INTERNALVAR_SCALAR.
(get_internalvar_integer): Likewise.
(set_internalvar): Likewise.
(set_internalvar_integer): Likewise.
(preserve_one_internalvar): Likewise.
(value_from_pointer): Handle typedef'd pointer types.
2009-08-19 Doug Evans <dje@google.com>
* gdb.base/gdbvars.c: New file.
* gdb.base/gdbvars.exp: Test convenience vars with program variables.
--- src/gdb/value.c 2009/08/13 18:39:20 1.92
+++ src/gdb/value.c 2009/08/19 13:00:28 1.93
@@ -920,8 +920,11 @@
/* The internal variable holds a GDB internal convenience function. */
INTERNALVAR_FUNCTION,
- /* The variable holds a simple scalar value. */
- INTERNALVAR_SCALAR,
+ /* The variable holds an integer value. */
+ INTERNALVAR_INTEGER,
+
+ /* The variable holds a pointer value. */
+ INTERNALVAR_POINTER,
/* The variable holds a GDB-provided string. */
INTERNALVAR_STRING,
@@ -944,19 +947,22 @@
int canonical;
} fn;
- /* A scalar value used with INTERNALVAR_SCALAR. */
+ /* An integer value used with INTERNALVAR_INTEGER. */
struct
{
/* If type is non-NULL, it will be used as the type to generate
a value for this internal variable. If type is NULL, a default
integer type for the architecture is used. */
struct type *type;
- union
- {
- LONGEST l; /* Used with TYPE_CODE_INT and NULL types. */
- CORE_ADDR a; /* Used with TYPE_CODE_PTR types. */
- } val;
- } scalar;
+ LONGEST val;
+ } integer;
+
+ /* A pointer value used with INTERNALVAR_POINTER. */
+ struct
+ {
+ struct type *type;
+ CORE_ADDR val;
+ } pointer;
/* A string value used with INTERNALVAR_STRING. */
char *string;
@@ -1082,16 +1088,16 @@
val = allocate_value (builtin_type (gdbarch)->internal_fn);
break;
- case INTERNALVAR_SCALAR:
- if (!var->u.scalar.type)
+ case INTERNALVAR_INTEGER:
+ if (!var->u.integer.type)
val = value_from_longest (builtin_type (gdbarch)->builtin_int,
- var->u.scalar.val.l);
- else if (TYPE_CODE (var->u.scalar.type) == TYPE_CODE_INT)
- val = value_from_longest (var->u.scalar.type, var->u.scalar.val.l);
- else if (TYPE_CODE (var->u.scalar.type) == TYPE_CODE_PTR)
- val = value_from_pointer (var->u.scalar.type, var->u.scalar.val.a);
+ var->u.integer.val);
else
- internal_error (__FILE__, __LINE__, "bad type");
+ val = value_from_longest (var->u.integer.type, var->u.integer.val);
+ break;
+
+ case INTERNALVAR_POINTER:
+ val = value_from_pointer (var->u.pointer.type, var->u.pointer.val);
break;
case INTERNALVAR_STRING:
@@ -1145,14 +1151,9 @@
{
switch (var->kind)
{
- case INTERNALVAR_SCALAR:
- if (var->u.scalar.type == NULL
- || TYPE_CODE (var->u.scalar.type) == TYPE_CODE_INT)
- {
- *result = var->u.scalar.val.l;
- return 1;
- }
- /* Fall through. */
+ case INTERNALVAR_INTEGER:
+ *result = var->u.integer.val;
+ return 1;
default:
return 0;
@@ -1224,15 +1225,15 @@
break;
case TYPE_CODE_INT:
- new_kind = INTERNALVAR_SCALAR;
- new_data.scalar.type = value_type (val);
- new_data.scalar.val.l = value_as_long (val);
+ new_kind = INTERNALVAR_INTEGER;
+ new_data.integer.type = value_type (val);
+ new_data.integer.val = value_as_long (val);
break;
case TYPE_CODE_PTR:
- new_kind = INTERNALVAR_SCALAR;
- new_data.scalar.type = value_type (val);
- new_data.scalar.val.a = value_as_address (val);
+ new_kind = INTERNALVAR_POINTER;
+ new_data.pointer.type = value_type (val);
+ new_data.pointer.val = value_as_address (val);
break;
default:
@@ -1269,9 +1270,9 @@
/* Clean up old contents. */
clear_internalvar (var);
- var->kind = INTERNALVAR_SCALAR;
- var->u.scalar.type = NULL;
- var->u.scalar.val.l = l;
+ var->kind = INTERNALVAR_INTEGER;
+ var->u.integer.type = NULL;
+ var->u.integer.val = l;
}
void
@@ -1426,10 +1427,16 @@
{
switch (var->kind)
{
- case INTERNALVAR_SCALAR:
- if (var->u.scalar.type && TYPE_OBJFILE (var->u.scalar.type) == objfile)
- var->u.scalar.type
- = copy_type_recursive (objfile, var->u.scalar.type, copied_types);
+ case INTERNALVAR_INTEGER:
+ if (var->u.integer.type && TYPE_OBJFILE (var->u.integer.type) == objfile)
+ var->u.integer.type
+ = copy_type_recursive (objfile, var->u.integer.type, copied_types);
+ break;
+
+ case INTERNALVAR_POINTER:
+ if (TYPE_OBJFILE (var->u.pointer.type) == objfile)
+ var->u.pointer.type
+ = copy_type_recursive (objfile, var->u.pointer.type, copied_types);
break;
case INTERNALVAR_VALUE:
@@ -2164,7 +2171,7 @@
value_from_pointer (struct type *type, CORE_ADDR addr)
{
struct value *val = allocate_value (type);
- store_typed_address (value_contents_raw (val), type, addr);
+ store_typed_address (value_contents_raw (val), check_typedef (type), addr);
return val;
}
--- src/gdb/testsuite/gdb.base/gdbvars.c
+++ src/gdb/testsuite/gdb.base/gdbvars.c 2009-08-19 15:10:47.270783000 +0000
@@ -0,0 +1,16 @@
+/* Simple program to help exercise gdb's convenience variables. */
+
+typedef void *ptr;
+
+ptr p = &p;
+
+int
+main ()
+{
+#ifdef usestubs
+ set_debug_traps ();
+ breakpoint ();
+#endif
+
+ return 0;
+}
--- src/gdb/testsuite/gdb.base/gdbvars.exp 2009/01/03 05:58:03 1.6
+++ src/gdb/testsuite/gdb.base/gdbvars.exp 2009/08/19 13:00:29 1.7
@@ -22,6 +22,15 @@
set prms_id 0
set bug_id 0
+set testfile "gdbvars"
+set srcfile ${testfile}.c
+set binfile ${objdir}/${subdir}/${testfile}
+
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
+ untested gdbvars.exp
+ return -1
+}
+
proc test_convenience_variables {} {
global gdb_prompt
@@ -101,13 +110,23 @@
"Use value-history element in arithmetic expression"
}
+proc test_with_program {} {
+ global hex
+ gdb_test "set \$prog_var = p" "" \
+ "Set a new convenience variable to a program variable"
+ gdb_test "print /x \$prog_var" " = $hex" \
+ "Print contents of new convenience variable of program variable"
+}
+
# Start with a fresh gdb.
gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
send_gdb "set print sevenbit-strings\n" ; gdb_expect -re ".*$gdb_prompt $"
test_value_history
test_convenience_variables
+test_with_program

View File

@ -2,7 +2,7 @@ http://sourceware.org/gdb/wiki/ProjectArcher
http://sourceware.org/gdb/wiki/ArcherBranchManagement
GIT snapshot:
commit 850e3cb38a25cb7fdfa4cef667626ffbde51bcac
commit 2ba2bc451eb832182ef84c3934115de7a329da7c
branch `archer' - the merge of branches:
archer-tromey-call-frame-cfa
@ -27214,10 +27214,10 @@ index bf9915c..233206c 100644
extern long ui_file_read (struct ui_file *file, char *buf, long length_buf);
diff --git a/gdb/utils.c b/gdb/utils.c
index 5fa2f26..f985fa9 100644
index 16ad084..3021a43 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -2604,7 +2604,10 @@ fprintf_symbol_filtered (struct ui_file *stream, char *name,
@@ -2610,7 +2610,10 @@ fprintf_symbol_filtered (struct ui_file *stream, char *name,
As an extra hack, string1=="FOO(ARGS)" matches string2=="FOO".
This "feature" is useful when searching for matching C++ function names
(such as if the user types 'break FOO', where FOO is a mangled C++
@ -27229,7 +27229,7 @@ index 5fa2f26..f985fa9 100644
int
strcmp_iw (const char *string1, const char *string2)
@@ -2629,7 +2632,7 @@ strcmp_iw (const char *string1, const char *string2)
@@ -2635,7 +2638,7 @@ strcmp_iw (const char *string1, const char *string2)
string2++;
}
}
@ -27732,7 +27732,7 @@ index cbb5d94..cf35bf0 100644
++reps;
++rep1;
diff --git a/gdb/value.c b/gdb/value.c
index 97f236c..8af6ae1 100644
index 48fedfd..5c207e3 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -37,8 +37,10 @@
@ -27857,7 +27857,7 @@ index 97f236c..8af6ae1 100644
/* Internal variables. These are variables within the debugger
that hold values assigned by debugger commands.
@@ -1363,6 +1413,37 @@ call_internal_function (struct gdbarch *gdbarch,
@@ -1364,6 +1414,40 @@ call_internal_function (struct gdbarch *gdbarch,
return (*ifn->handler) (gdbarch, language, ifn->cookie, argc, argv);
}
@ -27876,10 +27876,13 @@ index 97f236c..8af6ae1 100644
+ type_mark_used (value_type (var->u.value));
+ break;
+
+ case INTERNALVAR_SCALAR:
+ type_mark_used (var->u.scalar.type);
+ case INTERNALVAR_INTEGER:
+ type_mark_used (var->u.integer.type);
+ break;
+
+ case INTERNALVAR_POINTER:
+ type_mark_used (var->u.pointer.type);
+ break;
+ }
+
+ for (chunk = value_history_chain; chunk != NULL; chunk = chunk->next)
@ -27895,7 +27898,7 @@ index 97f236c..8af6ae1 100644
/* The 'function' command. This does nothing -- it is just a
placeholder to let "help function NAME" work. This is also used as
the implementation of the sub-command that is created when
@@ -1410,11 +1491,10 @@ preserve_one_value (struct value *value, struct objfile *objfile,
@@ -1411,11 +1495,10 @@ preserve_one_value (struct value *value, struct objfile *objfile,
htab_t copied_types)
{
if (TYPE_OBJFILE (value->type) == objfile)
@ -27909,16 +27912,23 @@ index 97f236c..8af6ae1 100644
copied_types);
}
@@ -1429,7 +1509,7 @@ preserve_one_internalvar (struct internalvar *var, struct objfile *objfile,
case INTERNALVAR_SCALAR:
if (var->u.scalar.type && TYPE_OBJFILE (var->u.scalar.type) == objfile)
var->u.scalar.type
- = copy_type_recursive (objfile, var->u.scalar.type, copied_types);
+ = copy_type_recursive (var->u.scalar.type, copied_types);
@@ -1430,13 +1513,13 @@ preserve_one_internalvar (struct internalvar *var, struct objfile *objfile,
case INTERNALVAR_INTEGER:
if (var->u.integer.type && TYPE_OBJFILE (var->u.integer.type) == objfile)
var->u.integer.type
- = copy_type_recursive (objfile, var->u.integer.type, copied_types);
+ = copy_type_recursive (var->u.integer.type, copied_types);
break;
case INTERNALVAR_POINTER:
if (TYPE_OBJFILE (var->u.pointer.type) == objfile)
var->u.pointer.type
- = copy_type_recursive (objfile, var->u.pointer.type, copied_types);
+ = copy_type_recursive (var->u.pointer.type, copied_types);
break;
case INTERNALVAR_VALUE:
@@ -1831,6 +1911,8 @@ value_change_enclosing_type (struct value *val, struct type *new_encl_type)
@@ -1838,6 +1921,8 @@ value_change_enclosing_type (struct value *val, struct type *new_encl_type)
val->contents =
(gdb_byte *) xrealloc (val->contents, TYPE_LENGTH (new_encl_type));
@ -27927,7 +27937,7 @@ index 97f236c..8af6ae1 100644
val->enclosing_type = new_encl_type;
return val;
}
@@ -1895,6 +1977,8 @@ value_primitive_field (struct value *arg1, int offset,
@@ -1902,6 +1987,8 @@ value_primitive_field (struct value *arg1, int offset,
memcpy (value_contents_all_raw (v), value_contents_all_raw (arg1),
TYPE_LENGTH (value_enclosing_type (arg1)));
}
@ -27936,7 +27946,7 @@ index 97f236c..8af6ae1 100644
v->type = type;
v->offset = value_offset (arg1);
v->embedded_offset = (offset + value_embedded_offset (arg1)
@@ -2145,6 +2229,42 @@ pack_long (gdb_byte *buf, struct type *type, LONGEST num)
@@ -2152,6 +2239,42 @@ pack_long (gdb_byte *buf, struct type *type, LONGEST num)
}
@ -27979,7 +27989,7 @@ index 97f236c..8af6ae1 100644
/* Convert C numbers into newly allocated values. */
struct value *
@@ -2158,6 +2278,19 @@ value_from_longest (struct type *type, LONGEST num)
@@ -2165,6 +2288,19 @@ value_from_longest (struct type *type, LONGEST num)
}
@ -27999,7 +28009,7 @@ index 97f236c..8af6ae1 100644
/* Create a value representing a pointer of type TYPE to the address
ADDR. */
struct value *
@@ -2316,4 +2449,8 @@ VARIABLE is already initialized."));
@@ -2323,4 +2459,8 @@ VARIABLE is already initialized."));
add_prefix_cmd ("function", no_class, function_command, _("\
Placeholder command for showing help on convenience functions."),
&functionlist, "function ", 0, &cmdlist);

View File

@ -14,7 +14,7 @@ Version: 6.8.50.20090818
# The release always contains a leading reserved number, start it at 1.
# `upstream' is not a part of `name' to stay fully rpm dependencies compatible for the testing.
Release: 3%{?_with_upstream:.upstream}%{?dist}
Release: 4%{?_with_upstream:.upstream}%{?dist}
License: GPLv3+
Group: Development/Debuggers
@ -219,7 +219,7 @@ Patch229: gdb-6.3-bz140532-ppc-unwinding-test.patch
Patch231: gdb-6.3-bz202689-exec-from-pthread-test.patch
# Backported post gdb-6.8.50.20090818 snapshot fixups.
#Patch232: gdb-6.8.50.20090818-upstream.patch
Patch232: gdb-6.8.50.20090818-upstream.patch
# Testcase for PPC Power6/DFP instructions disassembly (BZ 230000).
Patch234: gdb-6.6-bz230000-power6-disassembly-test.patch
@ -444,7 +444,7 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c
%if 0%{!?_with_upstream:1}
#patch232 -p1
%patch232 -p1
%patch349 -p1
%patch1 -p1
%patch3 -p1
@ -821,6 +821,10 @@ fi
%endif
%changelog
* Wed Aug 19 2009 Jan Kratochvil <jan.kratochvil@redhat.com> - 6.8.50.20090818-4
- Fixup "bad type" internal error, import from FSF GDB.
- archer-jankratochvil-fedora12 commit: 2ba2bc451eb832182ef84c3934115de7a329da7c
* Tue Aug 18 2009 Jan Kratochvil <jan.kratochvil@redhat.com> - 6.8.50.20090818-3
- archer-jankratochvil-fedora12 commit: 850e3cb38a25cb7fdfa4cef667626ffbde51bcac
- Fix the hardware watchpoints.