Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Issue 10311 - GDB prints wrong value for variable updated from closure #4063

Closed
wants to merge 1 commit into from

Conversation

tramker
Copy link
Contributor

@tramker tramker commented Oct 12, 2014

https://issues.dlang.org/show_bug.cgi?id=10311

The main problem is how to get the offset data from toir.c to dwarf.c. I have modified struct Symbol to do this, not sure if it is the proper approach. Comment please.

@tramker tramker changed the title Fix Issue 10311 - GDB prints wrong value for variable updated from closuse Fix Issue 10311 - GDB prints wrong value for variable updated from closure Oct 12, 2014
@WalterBright
Copy link
Member

A closure is implemented as a struct with fields for each variable. Would that work better?

@ibuclaw
Copy link
Member

ibuclaw commented Oct 13, 2014

This seems to be correct based on what GDC does. We emit frames/closures as structs, and in the debug codegen alias the var decl to the field offset.

So in the following example:

auto outer()
{
  int val;
  int inner() { return val * 2; }
  return &inner;
}

We have the closure (at fbreg -40):

 <4><84>: Abbrev Number: 7 (DW_TAG_variable)
    <85>   DW_AT_name        : (indirect string, offset: 0xc5): __closptr
    <8d>   DW_AT_location    : 2 byte block: 91 58      (DW_OP_fbreg: -40)

The field in the closure (at position 8):

 <2><125>: Abbrev Number: 19 (DW_TAG_member)
    <126>   DW_AT_name        : val
    <130>   DW_AT_data_member_location: 8

And the variable proper which has it's location pointing to the offset in the closure.

 <4><73>: Abbrev Number: 6 (DW_TAG_variable)
    <74>   DW_AT_name        : val
    <7e>   DW_AT_location    : 5 byte block: 91 58 6 23 8       (DW_OP_fbreg: -40; DW_OP_deref; DW_OP_plus_uconst: 8)

@tramker - does this get emitted for parameters too? (You shouldn't need to).

@tramker
Copy link
Contributor Author

tramker commented Oct 14, 2014

I need more time on this issue, I'm closing for now.

@tramker
Copy link
Contributor Author

tramker commented Oct 18, 2014

Iain, I'm not sure what you mean by "in the debug codegen alias the var decl to the field offset" or how to do it, so if you can point me to the GDC source, it would be helpful.

@ibuclaw
Copy link
Member

ibuclaw commented Oct 18, 2014

@tramker - I describe it in the post above. See the DW_AT_location. You are doing it in this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants