[Lldb-commits] [PATCH] D86615: [lldb/DWARF] Fix handling of variables with both location and const_value attributes

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Aug 27 06:02:55 PDT 2020


labath marked 3 inline comments as done.
labath added inline comments.


================
Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:3134
   if ((tag == DW_TAG_variable) || (tag == DW_TAG_constant) ||
       (tag == DW_TAG_formal_parameter && sc.function)) {
     DWARFAttributes attributes;
----------------
aprantl wrote:
> Would be nice to early-exit here, too.
I'll do that in a separate patch.


================
Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:3257
+        } else if (const char *str = const_value_form.AsCString()) {
+          uint32_t string_length = strlen(str) + 1;
+          location = DWARFExpression(
----------------
aprantl wrote:
> shafik wrote:
> > aprantl wrote:
> > > If we do this a lot a StringRef DWARFFormValue::AsCStringRef() call would make sense...
> > Why `+1`?
> The NUL-terminator?
Yeah, this is supposed to create a memory view of a C string, so it (probably) needs to include the nul terminator. But that actually speaks against the `AsCStringRef` function, as I wouldn't expect that one to include the null terminator.

I say "probably" because I haven't been able to actually find a producer that would produce this kind of attribute. The closest I got was gfortran, which could emit emit DW_AT_const_value for string variables. However, it used block forms for that.

To my great surprise, my synthetic test case in that patch actually worked and using a string DW_AT_const_value for char arrays in C seems somewhat reasonable, so I kept that code. However, I could be easily convinced to delete this.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86615/new/

https://reviews.llvm.org/D86615



More information about the lldb-commits mailing list