Hi Samuel,

In the attached patch, I redefined z as a struct variable and added a test for 
"p z" that does trigger the assert below.  I believe this is already captured 
by http://llvm.org/bugs/show_bug.cgi?id=15036, so I cross-referenced the 
failure accordingly.

I also added a passing test to cover the error path when trying to deference a 
null pointer to a struct (*pz in the attached patch), and a passing test for "p 
z.y" so we have some test coverage.

In general, the assert occurs because lldb fails to generate the external AST 
layout that clang expects while parsing the DIE tree.  This could have to do 
with the order in which the DIE tree is parsed.  The attached tests also 
exercise different nests of anonymous structs and break variously with clang, 
gcc and icc.  I've commented on bugzilla 15036 which mentioned other related 
failures.

I expect that some of these tests will fail on Darwin as well.  Again, the test 
case is much appreciated,

- Ashok

-----Original Message-----
From: [email protected] [mailto:[email protected]] On 
Behalf Of Malea, Daniel
Sent: Tuesday, April 16, 2013 5:59 PM
To: Samuel Jacob; lldb-dev
Subject: Re: [lldb-dev] ASSERT when building record layout for anonymous 
structures.

Are you on the trunk revision? I'm unable to reproduce your crash (although I 
do recall seeing a crash like that a few months ago). Here's what I see:

(lldb) p *((type_z*)0)
error: Couldn't dematerialize struct : Couldn't read a composite type from the 
target: Input/output error Errored out in Execute: Couldn't 
FinalizeJITExpression



Which makes sense, although the error message is not too user friendly, the 
phrase 'couldn't read a composite type from the target' implies the pointer was 
not dereferenced properly.

BTW, I am using GCC 4.7.2 (from Ubuntu 12.10)


Dan

On 2013-04-16 5:33 PM, "Samuel Jacob" <[email protected]> wrote:

>Hi,
>
>lldb asserts when inspecting a simple structure.
>
>Here is the simple test case. I already filed a bug 
>report(http://llvm.org/bugs/show_bug.cgi?id=15591).
>
>In my project a main base structure has anonymous field which makes 
>lldb unusable(since it asserts for any structure access). Can somebody 
>please take a look at this bug?
>
>$ cat test.c
>
>typedef struct {
>    int dummy;
>}type_y;
>
>typedef struct {
>    type_y y;
>}type_z;
>
>int main(int argc, char *argv[])
>{
>    type_z *z = 0;
>    return 0;
>}
>
>$ gcc -O0 -g3 ./test.c
>
>$ lldb a.out
>Current executable set to 'a.out' (x86_64).
>(lldb) p *((type_z *)0)
>lldb: llvm/tools/clang/lib/AST/RecordLayoutBuilder.cpp:2271: uint64_t 
><anonymous
>namespace>::RecordLayoutBuilder::updateExternalFieldOffset(const
>clang::FieldDecl *, uint64_t): Assertion
>`ExternalFieldOffsets.find(Field) != ExternalFieldOffsets.end() && 
>"Field does not have an external offset"' failed.
>
>Thanks
>Samuel
>_______________________________________________
>lldb-dev mailing list
>[email protected]
>http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev


_______________________________________________
lldb-dev mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev

Attachment: test-anonymous.patch
Description: test-anonymous.patch

_______________________________________________
lldb-dev mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev

Reply via email to