From: Felix Lee <felix@specifixinc.com>
To: gdb-patches@sources.redhat.com
Subject: stabsread, struct wipeout, missing type
Date: Thu, 01 Apr 2004 14:23:00 -0000 [thread overview]
Message-ID: <20040401142319.08335145@grayscale.canids> (raw)
sometimes "ptype foo" will print "struct <unknown>" when it
should be "char *".
consider a program that has these files
ace.h:
typedef struct ace ace_t;
ace2.h:
#include "ace.h"
struct ace { const char * a_name; };
bit.c:
typedef const char * bit_t;
#include "ace2.h"
cap.c:
#include "ace2.h"
typedef const char * cap_t;
after linking, the stabs look like this:
23 BINCL 0 0 000008ab 1 bit.c
24 LSYM 0 0 00000000 767 bit_t:t(1,1)=(1,2)=*(0,2)
25 BINCL 0 0 000007f7 793 ace2.h
26 BINCL 0 0 000006cf 800 ace.h
27 LSYM 0 0 00000000 806 ace_t:t(3,1)=(3,2)=xsace:
28 EINCL 0 0 00000000 0
29 LSYM 0 0 00000000 832 ace:T(3,2)=s4a_name:(1,2),0,32;;
30 EINCL 0 0 00000000 0
56 BINCL 0 0 0000077e 878 cap.c
57 BINCL 0 0 0000090c 793 ace2.h
58 EXCL 0 0 000006cf 800 ace.h
59 LSYM 0 0 00000000 884 ace:T(3,2)=s4a_name:(2,1)=*(0,2),0,32;;
60 EINCL 0 0 00000000 0
61 LSYM 0 0 00000000 924 cap_t:t(1,1)=(2,1)
note that ace.h got EXCL'd, but ace2.h didn't,
because the stabs for ace2.h are different,
because they depend on who mentions "const char *" first.
when gdb sees the second occurrence of struct ace,
it looks up the type number (3,2),
which refers to ace.h,
which is the same as the earlier ace.h,
so gdb reuses the previously-defined ace type.
then gdb complains about struct wipeout and ignores the second definition,
which means it misses the type definition (2,1)=*(0,2),
which means cap_t uses an undefined type,
so "ptype cap_t" prints "struct <unknown>" instead of "char *".
2004-04-01 Felix Lee <felix+log1@specifixinc.com>
* stabsread.c (read_struct_type): Always read struct types,
so we don't miss any type definitions.
--- stabsread.c.~1.76.~ 2004-03-29 09:48:14.000000000 -0800
+++ stabsread.c 2004-03-30 08:56:05.000000000 -0800
@@ -3334,14 +3334,18 @@ read_struct_type (char **pp, struct type
Obviously, GDB can't fix this by itself, but it can at least avoid
scribbling on existing structure type objects when new definitions
- appear. */
+ appear.
+
+ GDB has to read the struct type in any case, since it may contain
+ definitions of other types that will be needed elsewhere. Creating a
+ new type is not really the right thing to do, but it's better than
+ nothing. */
+
if (! (TYPE_CODE (type) == TYPE_CODE_UNDEF
|| TYPE_STUB (type)))
{
complain_about_struct_wipeout (type);
-
- /* It's probably best to return the type unchanged. */
- return type;
+ type = alloc_type (TYPE_OBJFILE (type));
}
back_to = make_cleanup (null_cleanup, 0);
next reply other threads:[~2004-04-01 14:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-04-01 14:23 Felix Lee [this message]
2004-04-01 20:22 ` Jim Blandy
2004-04-02 22:17 ` Jim Blandy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040401142319.08335145@grayscale.canids \
--to=felix@specifixinc.com \
--cc=gdb-patches@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox