From: David Blaikie <dblaikie@gmail.com>
To: gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [patch] [gdb/testsuite] include a use of the definition of a type to cause clang to emit debug info
Date: Sun, 13 Apr 2014 07:52:00 -0000 [thread overview]
Message-ID: <CAENS6EuydtwiGdk5EK7USRLphkz_0nHG-E+KtWJjC57jDAHehA@mail.gmail.com> (raw)
In-Reply-To: <CAENS6EvK8+AUQrj_0q2vAz0JH-5Pt0Z=cRWtW--4pyyUTP3WfQ@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1956 bytes --]
Oh, and there was one other instance of the same issue (I believe
these are the only two cases)
This test case (gdb.cp/pr10728) seems like it could probably be
simplified a great deal, down to:
struct foo;
foo *f, *g;
int main() {
} // break and print f - g
if I'm not mistaken... - but I've made a relatively small change for
now. If preferred, I can make the more substantial simplification
suggested. Or otherwise appease clang (by introducing a use of the
original 'x' type definition in some other way - dereferencing a
pointer, etc).
- David
On Sat, Apr 12, 2014 at 11:43 PM, David Blaikie <dblaikie@gmail.com> wrote:
> Clang has an optimization that causes a the debug info to only include
> the declaration of a type if the type is referenced but never used in
> a context that requires a definition (eg: pointers are handed around
> but never deferenced).
>
> This patch introduces a variable to one test file to cause clang to
> emit the full definition of the type as well as fixing up a related
> typo in the test message of the associated expect file.
>
> Like the difference between GCC and Clang in the emission of unused
> static entities, I think this case is also a matter of degrees - both
> GCC and Clang implement other similar optimizations* to the one
> outlined here and the GDB test suite has managed to pass without
> disabling those optimizations in GCC and I hope it's suitable to do
> the same for Clang.
>
> Though admittedly I don't have much of the context of the history of
> the testsuite, its priorities/preferences when it comes to
> distinguishing testing compiler behavior versus debugger behavior,
> etc.
>
> * the one I know of involves dynamic types: both GCC and Clang only
> emit the debug info definition of such a type in any translation unit
> that emits the key function. This means in many contexts where a full
> definition is provided in the source only a declaration is provided in
> the debug info.
[-- Attachment #2: pr10728-full-type.diff --]
[-- Type: text/plain, Size: 1812 bytes --]
commit 24a8810a97155710d3c53b401eb8729bc4f80c00
Author: David Blaikie <dblaikie@gmail.com>
Date: Sun Apr 13 00:48:45 2014 -0700
Return by value to coax Clang into emitting the full definition of a test type.
gdb/testsuite/
* gdb.cp/pr10728-x.cc: Return by value instead of pointer to coax
Clang into emitting the definition of the type.
* gdb.cp/pr10728-x.h: Ditto.
* gdb.cp/pr10728-y.cc: Ditto.
diff --git gdb/testsuite/ChangeLog gdb/testsuite/ChangeLog
index 730c116..1d15721 100644
--- gdb/testsuite/ChangeLog
+++ gdb/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2014-04-12 David Blaikie <dblaikie@gmail.com>
+
+ * gdb.cp/pr10728-x.cc: Return by value instead of pointer to coax
+ Clang into emitting the definition of the type.
+ * gdb.cp/pr10728-x.h: Ditto.
+ * gdb.cp/pr10728-y.cc: Ditto.
+
2014-04-12 Siva Chandra Reddy <sivachandra@google.com>
Doug Evans <xdje42@gmail.com>
diff --git gdb/testsuite/gdb.cp/pr10728-x.cc gdb/testsuite/gdb.cp/pr10728-x.cc
index 7623c0b..d6b7666 100644
--- gdb/testsuite/gdb.cp/pr10728-x.cc
+++ gdb/testsuite/gdb.cp/pr10728-x.cc
@@ -2,6 +2,6 @@
int main()
{
- X* x = y();
+ X x = y();
return 0; // marker 1
}
diff --git gdb/testsuite/gdb.cp/pr10728-x.h gdb/testsuite/gdb.cp/pr10728-x.h
index 63737d9..0ba58bb 100644
--- gdb/testsuite/gdb.cp/pr10728-x.h
+++ gdb/testsuite/gdb.cp/pr10728-x.h
@@ -5,5 +5,5 @@ struct X
Y* y2;
};
-X* y();
+X y();
diff --git gdb/testsuite/gdb.cp/pr10728-y.cc gdb/testsuite/gdb.cp/pr10728-y.cc
index 84b222d..d8a932a 100644
--- gdb/testsuite/gdb.cp/pr10728-y.cc
+++ gdb/testsuite/gdb.cp/pr10728-y.cc
@@ -1,11 +1,11 @@
#include "pr10728-x.h"
struct Y{};
-X* y()
+X y()
{
- static X xx;
+ X xx;
static Y yy;
xx.y1 = &yy;
xx.y2 = xx.y1+1;
- return &xx;
+ return xx;
}
next prev parent reply other threads:[~2014-04-13 7:52 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-13 6:43 David Blaikie
2014-04-13 7:52 ` David Blaikie [this message]
2014-04-23 23:04 ` Doug Evans
2014-04-14 13:10 ` Joel Brobecker
2014-04-14 15:53 ` Eric Christopher
2014-04-14 18:16 ` Joel Brobecker
2014-04-14 18:35 ` David Blaikie
2014-04-14 22:47 ` Joel Brobecker
2014-04-23 23:46 ` Pedro Alves
2014-04-24 0:20 ` Doug Evans
2014-04-24 0:29 ` Doug Evans
2014-04-24 12:36 ` Joel Brobecker
2014-04-25 5:32 ` David Blaikie
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=CAENS6EuydtwiGdk5EK7USRLphkz_0nHG-E+KtWJjC57jDAHehA@mail.gmail.com \
--to=dblaikie@gmail.com \
--cc=gdb-patches@sourceware.org \
/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