[PATCH] D41698: [DebugInfo] Enable debug information for C99 VLA types

Carlos Alberto Enciso via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 9 05:15:17 PST 2018


CarlosAlbertoEnciso added a comment.

Hi @sdesmalen!

First of all my apologies for commenting after the issue has been closed, but I do not have an account to add a comment to the associated bugzilla.

I have found what it seems to be an issue with the current implementation.

For the given test case

  int main() {
    int size = 2;
  
    int vla_expr[size];
    vla_expr[1] = 1;
  
    return 0;
  }

and while debugging with LLDB, the following error is generated:

  (lldb) n
  Process 21014 stopped
  * thread #1, name = 'bad.out', stop reason = step over
      frame #0: 0x0000000000400502 bad.out`main at vla_2.cpp:7
     4   	  int vla_expr[size];
     5   	  vla_expr[1] = 1;
     6   	
  -> 7   	  return 0;
     8   	}
  
  (lldb) p vla_expr
  (unsigned long) $0 = 2
  
  (lldb) p vla_expr[1]
  error: subscripted value is not an array, pointer, or vector
  
  (lldb) 

Looking at the DWARF generated, there are 2 variables with the same name at the same scope

  DW_TAG_subprogram "main"
    ...
    DW_TAG_variable "size"
    DW_TAG_variable "vla_expr"
    DW_TAG_variable "vla_expr"

I think there are 2 issues:

The compiler generated variable 'vla_expr'

- should be flagged as artificial (DW_AT_artificial)
- its name should start with double underscore to avoid conflicting with user-defined names.

Thanks,
Carlos


Repository:
  rL LLVM

https://reviews.llvm.org/D41698





More information about the cfe-commits mailing list