<div dir="ltr"><div>Thanks for the suggestions but it doesn't appear to be working correctly for me. I tried building the below after seeing the results with "clang -g -std=c99 test.c" and got the same result</div><div><br></div><div>LLDB thinks MyArray is 81 elements long even though 81 and 80 doesn't show up anywhere in the llvm-ir (I tried again using an llvm ir file made by clang -g -std=c99 test.c -S -emit-llvm and clang -g test.ll)</div><div><br></div><div>$ cat test.c </div>int foo(int s) {<br> int MyArray[s];<br> int i;<br> for (i = 0; i < s; ++i)<br> MyArray[i] = s;<br> return 0;<br>}<br><br>int main(){<br> foo(5);<br> return 0;<br>}<br>$ clang -g test.c <br>$ lldb ./a.out <br>(lldb) target create "./a.out"<br>Current executable set to './a.out' (x86_64).<br>(lldb) break set -f test.c -l 6<br>Breakpoint 1: where = a.out`foo + 101 at test.c:7, address = 0x0000000000400505<br>(lldb) r<br>Process 3205 launched: './a.out' (x86_64)<br>Process 3205 stopped<br>* thread #1, name = 'a.out', stop reason = breakpoint 1.1<br> frame #0: 0x0000000000400505 a.out`foo(s=5) at test.c:7<br> 4 for (i = 0; i < s; ++i)<br> 5 MyArray[i] = s;<br> 6 return 0;<br>-> 7 }<br> 8 <br> 9 int main(){<br> 10 foo(5);<br>(lldb) frame variable<br>(int) s = 5<br>(unsigned long) __vla_expr0 = 5<br>(int) i = 5<br>(int [81]) MyArray = {<br> [0] = 5<br> [1] = 5<br> [2] = 5<br> [3] = 5<br> [4] = 5<br> [5] = 0<br> [6] = -136481184<br> [7] = 32767<br> [8] = -8408<br> [9] = 32767<br> [10] = -8544<br> [11] = 32767<br> [12] = 1<br> [13] = 5<br> [14] = 5<br> [15] = 0<br> [16] = -8512<br> [17] = 32767<br> [18] = 0<br> [19] = 5<br> [20] = -8432<br> [21] = 32767<br> [22] = 4195641<br> [23] = 0<br> [24] = -8208<br> [25] = 32767<br> [26] = 0<br> [27] = 0<br> [28] = 4195664<br> [29] = 0<br> [30] = -140485737<br> [31] = 32767<br> [32] = 0<br> [33] = 32<br> [34] = -8200<br> [35] = 32767<br> [36] = 0<br> [37] = 1<br> [38] = 4195616<br> [39] = 0<br> [40] = 0<br> [41] = 0<br> [42] = -1953144313<br> [43] = 1284291557<br> [44] = 4195248<br> [45] = 0<br> [46] = -8208<br> [47] = 32767<br> [48] = 0<br> [49] = 0<br> [50] = 0<br> [51] = 0<br> [52] = 1064657415<br> [53] = -1284291430<br> [54] = 933978631<br> [55] = -1284287451<br> [56] = 0<br> [57] = 32767<br> [58] = 0<br> [59] = 0<br> [60] = 0<br> [61] = 0<br> [62] = -136423629<br> [63] = 32767<br> [64] = -136530376<br> [65] = 32767<br> [66] = 386784<br> [67] = 0<br> [68] = 0<br> [69] = 0<br> [70] = 0<br> [71] = 0<br> [72] = 0<br> [73] = 0<br> [74] = 4195248<br> [75] = 0<br> [76] = -8208<br> [77] = 32767<br> [78] = 4195290<br> [79] = 0<br> [80] = -8216<br>}<br><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 13, 2020 at 3:53 PM Adrian Prantl <<a href="mailto:aprantl@apple.com">aprantl@apple.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;">Take a look at the IR clang produces for C99 variable-length arrays.<div><br></div><div>-- adrian<br><div><br><blockquote type="cite"><div>On Feb 13, 2020, at 10:03 AM, Levo DeLellis via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:</div><br><div><div dir="ltr"><div>Hi. I searched and the closest thing I could find was this <a href="http://lists.llvm.org/pipermail/llvm-dev/2018-February/121348.html" target="_blank">http://lists.llvm.org/pipermail/llvm-dev/2018-February/121348.html</a></div><div><br></div><div>Currently a known sized array looks and debugs as expected. I use llvm.dbg.declare with DICompositeType tag: DW_TAG_array_type and the size field. In my language arrays are always passed around with a pointer and size pair. I'd like debugging to show up as nicely instead of a pointer addr with no information about the elements. How would I do this? I don't use the C API, I output llvm-ir directly. I was hoping I can call <code><span>llvm.dbg.declare/addr/<code><span>value to specify the pointer, name and size of the variable but I really have no idea how to pass the size to the debugger.</span></code></span></code></div><div><code><span><code><span><br></span></code></span></code></div></div>
_______________________________________________<br>LLVM Developers mailing list<br><a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br><a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br></div></blockquote></div><br></div></div></blockquote></div>