public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH PR gdb/20057] Internal error on trying to set {char[]}$pc="string"
@ 2018-01-25  2:12 Weimin Pan
  2018-01-25  4:14 ` Joel Brobecker
  0 siblings, 1 reply; 16+ messages in thread
From: Weimin Pan @ 2018-01-25  2:12 UTC (permalink / raw)
  To: gdb-patches

To support C99 VLA, function value_from_contents_and_address() was
modified to add a call to resolve_dynamic_type(), which in turn
calls resolve_dynamic_array() to resolve the dynamic array bounds
to static values. But the problem arises when function copy_type(),
called by resolve_dynamic_array(), expects the type to be copied
to have an associated objfile from which the new type is allocated,
or asserts. Since type char[] doesn't have an associated objfile
when the following gdb command:

(gdb) set {char[]}$pc="hello"

was issued, gdb asserts.

The gdb_assert (TYPE_OBJFILE_OWNED (type)) line in copy_type() doesn't
look necessary or correct since space needed for the new type could be
allocated from either the type's objfile if it exists or gdbarch if
it doesn't, similar to what alloc_type_copy(), which is called after
gdb_assert() in copy_type(), does. Removing gdb_assert() fixes the
problem.

Tested on aarch64-linux-gnu. No regressions.
---
 gdb/ChangeLog  |    5 +++++
 gdb/gdbtypes.c |    7 +------
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 238bcba..5758207 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2018-01-09  Weimin Pan  <weimin.pan@oracle.com>
+
+	* gdbtypes.c: (copy_type) Do not assert when a type is not associated
+	with an object file.
+
 2018-01-08  Samuel Thibault  <samuel.thibault@ens-lyon.org>
 
 	* gdb/gnu-nat.c: Include <elf.h> and <link.h>.
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 7ba62df..e017b6a 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -4870,18 +4870,13 @@ copy_type_recursive (struct objfile *objfile,
 }
 
 /* Make a copy of the given TYPE, except that the pointer & reference
-   types are not preserved.
-   
-   This function assumes that the given type has an associated objfile.
-   This objfile is used to allocate the new type.  */
+   types are not preserved.  */
 
 struct type *
 copy_type (const struct type *type)
 {
   struct type *new_type;
 
-  gdb_assert (TYPE_OBJFILE_OWNED (type));
-
   new_type = alloc_type_copy (type);
   TYPE_INSTANCE_FLAGS (new_type) = TYPE_INSTANCE_FLAGS (type);
   TYPE_LENGTH (new_type) = TYPE_LENGTH (type);
-- 
1.7.1

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2018-11-30 17:31 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-25  2:12 [PATCH PR gdb/20057] Internal error on trying to set {char[]}$pc="string" Weimin Pan
2018-01-25  4:14 ` Joel Brobecker
2018-01-25 22:24   ` Wei-min Pan
2018-01-31  7:45     ` Joel Brobecker
2018-02-01  1:46       ` Wei-min Pan
2018-02-01  8:00         ` Joel Brobecker
2018-02-02  1:14           ` Wei-min Pan
2018-11-14 23:38           ` Wei-min Pan
2018-11-14 23:51             ` Joel Brobecker
2018-11-15  0:16               ` Wei-min Pan
2018-11-29 19:18                 ` Tom Tromey
2018-11-29 21:10                   ` Wei-min Pan
2018-11-29 21:52                     ` Tom Tromey
2018-11-29 23:26                       ` Wei-min Pan
2018-11-30 15:37                         ` Tom Tromey
2018-11-30 17:31                           ` Wei-min Pan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).