[LLVMdev] Value of structure passed byval to a recurse function not initialized when accessed through GDB

David Blaikie dblaikie at gmail.com
Tue Dec 4 12:15:59 PST 2012


This seems to be another case of PR13303 - since GDB can't figure out
where to break for this function based on the debug info (you'll
notice when you "break recurse" that it's not breaking on a line or
source file, just an address) it's breaking at the very start, before
the prologue

I'm about to commit a fix to this.

On Tue, Dec 4, 2012 at 5:34 AM, Karthik Bhat <karthikthecool at gmail.com> wrote:
> Hi All,
>
> I was debugging a clang binary when i found this problem. The
> following code is complied with clang.
>
> typedef struct s
> {
>   short s;
> } SVAL;
>
>
> void recurse (SVAL a, int depth)
> {
>   a.s = --depth;
>   if (depth == 0)
>     return;
>   else
>    recurse(a,depth);
> }
>
> int main ()
> {
>   SVAL s; s.s = 5;
>   recurse (s, 5);
>   return 0;
> }
>
> When i try to access value of a.s in function recurse through gdb(i.e
> gdb > p a.s) it gives me an uninitialized value.
> The problem occurs only when we have a function call within function
> to which we have passed a structure.
>
> Could someone guide me were can i look to fix this issue.
>
> I have started with LowerFormalArguments in X86ISelLowering.cpp file.
>
> Thanks
> Karthik
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev



More information about the llvm-dev mailing list