[Lldb-commits] [PATCH] D84008: [DWARFYAML] Refactor emitDebugInfo() to make the length be inferred.

2020-07-23 Thread Xing GUO via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG92874d286695: [DWARFYAML] Refactor emitDebugInfo() to make 
the length be inferred. (authored by Higuoxing).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84008

Files:
  lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.cpp
  llvm/include/llvm/ObjectYAML/DWARFEmitter.h
  llvm/include/llvm/ObjectYAML/DWARFYAML.h
  llvm/lib/ObjectYAML/CMakeLists.txt
  llvm/lib/ObjectYAML/DWARFEmitter.cpp
  llvm/lib/ObjectYAML/DWARFVisitor.cpp
  llvm/lib/ObjectYAML/DWARFVisitor.h
  llvm/lib/ObjectYAML/DWARFYAML.cpp
  llvm/test/tools/yaml2obj/ELF/DWARF/debug-info.yaml
  llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
  llvm/unittests/DebugInfo/DWARF/DWARFDieTest.cpp

Index: llvm/unittests/DebugInfo/DWARF/DWARFDieTest.cpp
===
--- llvm/unittests/DebugInfo/DWARF/DWARFDieTest.cpp
+++ llvm/unittests/DebugInfo/DWARF/DWARFDieTest.cpp
@@ -48,7 +48,7 @@
   - Value:   25
   )";
   Expected>> Sections =
-  DWARFYAML::emitDebugSections(StringRef(yamldata), /*ApplyFixups=*/true,
+  DWARFYAML::emitDebugSections(StringRef(yamldata),
/*IsLittleEndian=*/true);
   ASSERT_THAT_EXPECTED(Sections, Succeeded());
   std::vector Loclists{
Index: llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
===
--- llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
+++ llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
@@ -1377,7 +1377,7 @@
  "  - AbbrCode:0x\n"
  "Values:\n";
 
-  auto ErrOrSections = DWARFYAML::emitDebugSections(StringRef(yamldata), true);
+  auto ErrOrSections = DWARFYAML::emitDebugSections(StringRef(yamldata));
   ASSERT_TRUE((bool)ErrOrSections);
   std::unique_ptr DwarfContext =
   DWARFContext::create(*ErrOrSections, 8);
Index: llvm/test/tools/yaml2obj/ELF/DWARF/debug-info.yaml
===
--- llvm/test/tools/yaml2obj/ELF/DWARF/debug-info.yaml
+++ llvm/test/tools/yaml2obj/ELF/DWARF/debug-info.yaml
@@ -735,3 +735,110 @@
   AbbrOffset: 0x1234
   AddrSize:   8
   Entries:[]
+
+## k) Test that yaml2obj is able to emit a correct length for compilation units.
+
+# RUN: yaml2obj --docnum=13 %s -o %t13.o
+# RUN: llvm-readelf --hex-dump=.debug_info %t13.o | \
+# RUN:   FileCheck %s --check-prefix=INFER-LENGTH
+
+#  INFER-LENGTH: Hex dump of section '.debug_info':
+# INFER-LENGTH-NEXT: 0x 3700 0400 0801  7...
+##  ^---unit_length (0x37)
+##   ^---   version (2-byte)
+##   ^  debug_abbrev_offset (4-byte)
+##^-address_size (1-byte)
+##  ^-  abbrev code (ULEB128) 0x01
+## ^--- Form: DW_FORM_strp (4-byte)
+# INFER-LENGTH-NEXT: 0x0010 0c001600  1e00 2011 .. .
+##  ^---Form: DW_FORM_data2 (2-byte)
+##  ^   Form: DW_FORM_strp (4-byte)
+##   ^  Form: DW_FORM_sec_offset (4-byte)
+##^ Form: DW_FORM_strp (4-byte)
+## ^--- Form: DW_FORM_addr (8-byte)
+# INFER-LENGTH-NEXT: 0x0020  3300 0220 1100 ..3 
+##  -
+##   ^  Form: DW_FORM_data4 (4-byte)
+##^-abbrev code (ULEB128) 0x02
+##  ^-- Form: DW_FORM_addr (8-byte)
+# INFER-LENGTH-NEXT: 0x0030 0006 0038 00...8...
+##  --
+##^ Form: DW_FORM_data4 (4-byte)
+## ^Form: DW_FORM_strp (4-byte)
+
+## The handwritten DIEs should look like:
+
+## 0x000b: DW_TAG_compile_unit [1] *
+##   DW_AT_producer [DW_FORM_strp]( .debug_str[0x] = "clang version 10.0.0 ")
+##   DW_AT_language [DW_FORM_data2]   (DW_LANG_C99)
+##   DW_AT_name [DW_FORM_strp]( 

[Lldb-commits] [PATCH] D84008: [DWARFYAML] Refactor emitDebugInfo() to make the length be inferred.

2020-07-23 Thread Xing GUO via Phabricator via lldb-commits
Higuoxing marked an inline comment as done.
Higuoxing added inline comments.



Comment at: llvm/lib/ObjectYAML/DWARFEmitter.cpp:380-382
+  cantFail(writeVariableSizedInteger(Unit.AbbrOffset,
+ Unit.Format == dwarf::DWARF64 ? 8 : 4,
+ OS, DI.IsLittleEndian));

jhenderson wrote:
> labath wrote:
> > a writeDwarfOffset function might be handy.
> I'm guessing the new function can be used elsewhere too (I expect in places 
> like .debug_aranges for example). In another patch, please consider looking 
> at that.
Yeah, it can be used in the 
.debug_str_offsets/debug_rnglists/debug_loclists/debug_aranges sections, etc. 
I've applied it in this patch and will apply it to other sections in a 
follow-up patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84008



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D84008: [DWARFYAML] Refactor emitDebugInfo() to make the length be inferred.

2020-07-23 Thread James Henderson via Phabricator via lldb-commits
jhenderson added inline comments.



Comment at: llvm/lib/ObjectYAML/DWARFEmitter.cpp:380-382
+  cantFail(writeVariableSizedInteger(Unit.AbbrOffset,
+ Unit.Format == dwarf::DWARF64 ? 8 : 4,
+ OS, DI.IsLittleEndian));

labath wrote:
> a writeDwarfOffset function might be handy.
I'm guessing the new function can be used elsewhere too (I expect in places 
like .debug_aranges for example). In another patch, please consider looking at 
that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84008



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D84008: [DWARFYAML] Refactor emitDebugInfo() to make the length be inferred.

2020-07-23 Thread Xing GUO via Phabricator via lldb-commits
Higuoxing added inline comments.



Comment at: llvm/lib/ObjectYAML/DWARFEmitter.cpp:207-215
+static unsigned getOffsetSize(const DWARFYAML::Unit ) {
+  return Unit.Format == dwarf::DWARF64 ? 8 : 4;
+}
 
-  void onValue(const uint16_t U) override {
-writeInteger(U, OS, DebugInfo.IsLittleEndian);
-  }
+static unsigned getRefSize(const DWARFYAML::Unit ) {
+  if (Unit.Version == 2)
+return Unit.AddrSize;

labath wrote:
> Maybe this is for a separate patch, since you're just moving these, but this 
> code already exists in BinaryFormat/Dwarf.h. It would be nice if 
> DWARFYaml::Unit had a dwarf::FormParams field or a getter, and then these 
> things could be retrieved by querying that object...
Thanks! I'll do it in a separate patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84008



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D84008: [DWARFYAML] Refactor emitDebugInfo() to make the length be inferred.

2020-07-23 Thread Xing GUO via Phabricator via lldb-commits
Higuoxing updated this revision to Diff 280116.
Higuoxing marked 3 inline comments as done.
Higuoxing added a comment.

Address comments. Thanks for reviewing!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84008

Files:
  lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.cpp
  llvm/include/llvm/ObjectYAML/DWARFEmitter.h
  llvm/include/llvm/ObjectYAML/DWARFYAML.h
  llvm/lib/ObjectYAML/CMakeLists.txt
  llvm/lib/ObjectYAML/DWARFEmitter.cpp
  llvm/lib/ObjectYAML/DWARFVisitor.cpp
  llvm/lib/ObjectYAML/DWARFVisitor.h
  llvm/lib/ObjectYAML/DWARFYAML.cpp
  llvm/test/tools/yaml2obj/ELF/DWARF/debug-info.yaml
  llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
  llvm/unittests/DebugInfo/DWARF/DWARFDieTest.cpp

Index: llvm/unittests/DebugInfo/DWARF/DWARFDieTest.cpp
===
--- llvm/unittests/DebugInfo/DWARF/DWARFDieTest.cpp
+++ llvm/unittests/DebugInfo/DWARF/DWARFDieTest.cpp
@@ -48,7 +48,7 @@
   - Value:   25
   )";
   Expected>> Sections =
-  DWARFYAML::emitDebugSections(StringRef(yamldata), /*ApplyFixups=*/true,
+  DWARFYAML::emitDebugSections(StringRef(yamldata),
/*IsLittleEndian=*/true);
   ASSERT_THAT_EXPECTED(Sections, Succeeded());
   std::vector Loclists{
Index: llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
===
--- llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
+++ llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
@@ -1377,7 +1377,7 @@
  "  - AbbrCode:0x\n"
  "Values:\n";
 
-  auto ErrOrSections = DWARFYAML::emitDebugSections(StringRef(yamldata), true);
+  auto ErrOrSections = DWARFYAML::emitDebugSections(StringRef(yamldata));
   ASSERT_TRUE((bool)ErrOrSections);
   std::unique_ptr DwarfContext =
   DWARFContext::create(*ErrOrSections, 8);
Index: llvm/test/tools/yaml2obj/ELF/DWARF/debug-info.yaml
===
--- llvm/test/tools/yaml2obj/ELF/DWARF/debug-info.yaml
+++ llvm/test/tools/yaml2obj/ELF/DWARF/debug-info.yaml
@@ -735,3 +735,110 @@
   AbbrOffset: 0x1234
   AddrSize:   8
   Entries:[]
+
+## k) Test that yaml2obj is able to emit a correct length for compilation units.
+
+# RUN: yaml2obj --docnum=13 %s -o %t13.o
+# RUN: llvm-readelf --hex-dump=.debug_info %t13.o | \
+# RUN:   FileCheck %s --check-prefix=INFER-LENGTH
+
+#  INFER-LENGTH: Hex dump of section '.debug_info':
+# INFER-LENGTH-NEXT: 0x 3700 0400 0801  7...
+##  ^---unit_length (0x37)
+##   ^---   version (2-byte)
+##   ^  debug_abbrev_offset (4-byte)
+##^-address_size (1-byte)
+##  ^-  abbrev code (ULEB128) 0x01
+## ^--- Form: DW_FORM_strp (4-byte)
+# INFER-LENGTH-NEXT: 0x0010 0c001600  1e00 2011 .. .
+##  ^---Form: DW_FORM_data2 (2-byte)
+##  ^   Form: DW_FORM_strp (4-byte)
+##   ^  Form: DW_FORM_sec_offset (4-byte)
+##^ Form: DW_FORM_strp (4-byte)
+## ^--- Form: DW_FORM_addr (8-byte)
+# INFER-LENGTH-NEXT: 0x0020  3300 0220 1100 ..3 
+##  -
+##   ^  Form: DW_FORM_data4 (4-byte)
+##^-abbrev code (ULEB128) 0x02
+##  ^-- Form: DW_FORM_addr (8-byte)
+# INFER-LENGTH-NEXT: 0x0030 0006 0038 00...8...
+##  --
+##^ Form: DW_FORM_data4 (4-byte)
+## ^Form: DW_FORM_strp (4-byte)
+
+## The handwritten DIEs should look like:
+
+## 0x000b: DW_TAG_compile_unit [1] *
+##   DW_AT_producer [DW_FORM_strp]( .debug_str[0x] = "clang version 10.0.0 ")
+##   DW_AT_language [DW_FORM_data2]   (DW_LANG_C99)
+##   DW_AT_name [DW_FORM_strp]( .debug_str[0x0016] = "hello.c")
+##

[Lldb-commits] [PATCH] D84008: [DWARFYAML] Refactor emitDebugInfo() to make the length be inferred.

2020-07-23 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.

Yeah, looks good. Some small suggestions inline, though some of them may be 
better off as separate patches...




Comment at: llvm/lib/ObjectYAML/DWARFEmitter.cpp:207-215
+static unsigned getOffsetSize(const DWARFYAML::Unit ) {
+  return Unit.Format == dwarf::DWARF64 ? 8 : 4;
+}
 
-  void onValue(const uint16_t U) override {
-writeInteger(U, OS, DebugInfo.IsLittleEndian);
-  }
+static unsigned getRefSize(const DWARFYAML::Unit ) {
+  if (Unit.Version == 2)
+return Unit.AddrSize;

Maybe this is for a separate patch, since you're just moving these, but this 
code already exists in BinaryFormat/Dwarf.h. It would be nice if 
DWARFYaml::Unit had a dwarf::FormParams field or a getter, and then these 
things could be retrieved by querying that object...



Comment at: llvm/lib/ObjectYAML/DWARFEmitter.cpp:349-353
+// sizeof(version) 2 + sizeof(address_size) 1 = 3
+// sizeof(unit_type) = 1 (DWARFv5) or 0
+// sizeof(debug_abbrev_offset) = 4 (DWARF32) or 8 (DWARF64)
+uint64_t Length = 3 + (Unit.Version >= 5 ? 1 : 0) +
+  (Unit.Format == dwarf::DWARF64 ? 8 : 4);

Since the comments repeat the entire expression, it would be less repetitive to 
just structure the code in a way that comments can be attached to the actual 
expressions. Maybe something like:
```
Lenght = 3; // version + address_size
Length += (Unit.Version >= 5 ? 1 : 0); // unit_type
Length += Unit.getFormParams().getDwarfOffsetByteSize(); // abbrev_offset
```



Comment at: llvm/lib/ObjectYAML/DWARFEmitter.cpp:380-382
+  cantFail(writeVariableSizedInteger(Unit.AbbrOffset,
+ Unit.Format == dwarf::DWARF64 ? 8 : 4,
+ OS, DI.IsLittleEndian));

a writeDwarfOffset function might be handy.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84008



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D84008: [DWARFYAML] Refactor emitDebugInfo() to make the length be inferred.

2020-07-23 Thread James Henderson via Phabricator via lldb-commits
jhenderson accepted this revision.
jhenderson added a comment.
This revision is now accepted and ready to land.

LGTM, thanks, but might be best to get a second opinion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84008



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D84008: [DWARFYAML] Refactor emitDebugInfo() to make the length be inferred.

2020-07-22 Thread Xing GUO via Phabricator via lldb-commits
Higuoxing added inline comments.



Comment at: llvm/test/tools/yaml2obj/ELF/DWARF/debug-info.yaml:743
+# RUN: llvm-readelf --hex-dump=.debug_info %t13.o | \
+# RUN:   FileCheck %s --check-prefix=LENGTH
+

jhenderson wrote:
> Should this be INFER-LENGTH? (The test is currently failing...)
Oops, sorry, I forget to modify this line.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84008



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D84008: [DWARFYAML] Refactor emitDebugInfo() to make the length be inferred.

2020-07-22 Thread Xing GUO via Phabricator via lldb-commits
Higuoxing updated this revision to Diff 280020.
Higuoxing marked 3 inline comments as done.
Higuoxing added a comment.

Address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84008

Files:
  lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.cpp
  llvm/include/llvm/ObjectYAML/DWARFEmitter.h
  llvm/include/llvm/ObjectYAML/DWARFYAML.h
  llvm/lib/ObjectYAML/CMakeLists.txt
  llvm/lib/ObjectYAML/DWARFEmitter.cpp
  llvm/lib/ObjectYAML/DWARFVisitor.cpp
  llvm/lib/ObjectYAML/DWARFVisitor.h
  llvm/lib/ObjectYAML/DWARFYAML.cpp
  llvm/test/tools/yaml2obj/ELF/DWARF/debug-info.yaml
  llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
  llvm/unittests/DebugInfo/DWARF/DWARFDieTest.cpp

Index: llvm/unittests/DebugInfo/DWARF/DWARFDieTest.cpp
===
--- llvm/unittests/DebugInfo/DWARF/DWARFDieTest.cpp
+++ llvm/unittests/DebugInfo/DWARF/DWARFDieTest.cpp
@@ -48,7 +48,7 @@
   - Value:   25
   )";
   Expected>> Sections =
-  DWARFYAML::emitDebugSections(StringRef(yamldata), /*ApplyFixups=*/true,
+  DWARFYAML::emitDebugSections(StringRef(yamldata),
/*IsLittleEndian=*/true);
   ASSERT_THAT_EXPECTED(Sections, Succeeded());
   std::vector Loclists{
Index: llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
===
--- llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
+++ llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
@@ -1377,7 +1377,7 @@
  "  - AbbrCode:0x\n"
  "Values:\n";
 
-  auto ErrOrSections = DWARFYAML::emitDebugSections(StringRef(yamldata), true);
+  auto ErrOrSections = DWARFYAML::emitDebugSections(StringRef(yamldata));
   ASSERT_TRUE((bool)ErrOrSections);
   std::unique_ptr DwarfContext =
   DWARFContext::create(*ErrOrSections, 8);
Index: llvm/test/tools/yaml2obj/ELF/DWARF/debug-info.yaml
===
--- llvm/test/tools/yaml2obj/ELF/DWARF/debug-info.yaml
+++ llvm/test/tools/yaml2obj/ELF/DWARF/debug-info.yaml
@@ -735,3 +735,110 @@
   AbbrOffset: 0x1234
   AddrSize:   8
   Entries:[]
+
+## k) Test that yaml2obj is able to emit a correct length for compilation units.
+
+# RUN: yaml2obj --docnum=13 %s -o %t13.o
+# RUN: llvm-readelf --hex-dump=.debug_info %t13.o | \
+# RUN:   FileCheck %s --check-prefix=INFER-LENGTH
+
+#  INFER-LENGTH: Hex dump of section '.debug_info':
+# INFER-LENGTH-NEXT: 0x 3700 0400 0801  7...
+##  ^---unit_length (0x37)
+##   ^---   version (2-byte)
+##   ^  debug_abbrev_offset (4-byte)
+##^-address_size (1-byte)
+##  ^-  abbrev code (ULEB128) 0x01
+## ^--- Form: DW_FORM_strp (4-byte)
+# INFER-LENGTH-NEXT: 0x0010 0c001600  1e00 2011 .. .
+##  ^---Form: DW_FORM_data2 (2-byte)
+##  ^   Form: DW_FORM_strp (4-byte)
+##   ^  Form: DW_FORM_sec_offset (4-byte)
+##^ Form: DW_FORM_strp (4-byte)
+## ^--- Form: DW_FORM_addr (8-byte)
+# INFER-LENGTH-NEXT: 0x0020  3300 0220 1100 ..3 
+##  -
+##   ^  Form: DW_FORM_data4 (4-byte)
+##^-abbrev code (ULEB128) 0x02
+##  ^-- Form: DW_FORM_addr (8-byte)
+# INFER-LENGTH-NEXT: 0x0030 0006 0038 00...8...
+##  --
+##^ Form: DW_FORM_data4 (4-byte)
+## ^Form: DW_FORM_strp (4-byte)
+
+## The handwritten DIEs should look like:
+
+## 0x000b: DW_TAG_compile_unit [1] *
+##   DW_AT_producer [DW_FORM_strp]( .debug_str[0x] = "clang version 10.0.0 ")
+##   DW_AT_language [DW_FORM_data2]   (DW_LANG_C99)
+##   DW_AT_name [DW_FORM_strp]( .debug_str[0x0016] = "hello.c")
+##   DW_AT_stmt_list 

[Lldb-commits] [PATCH] D84008: [DWARFYAML] Refactor emitDebugInfo() to make the length be inferred.

2020-07-22 Thread James Henderson via Phabricator via lldb-commits
jhenderson added inline comments.



Comment at: llvm/test/tools/yaml2obj/ELF/DWARF/debug-info.yaml:743
+# RUN: llvm-readelf --hex-dump=.debug_info %t13.o | \
+# RUN:   FileCheck %s --check-prefix=LENGTH
+

Should this be INFER-LENGTH? (The test is currently failing...)



Comment at: llvm/test/tools/yaml2obj/ELF/DWARF/debug-info.yaml:748-750
+##   ^---   4-byte 
(accumulated length 0x04)
+##^---  4-byte 
(accumulated length 0x08)
+## ^--- 4-byte 
(accumulated length 0x0c)

I don't think these comments are particularly helpful, since they can be 
inferred from the byte-count/offset at the start of the line. I think if you 
want comments, you should say what the bytes represent, like you do elsewhere.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84008



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D84008: [DWARFYAML] Refactor emitDebugInfo() to make the length be inferred.

2020-07-17 Thread Xing GUO via Phabricator via lldb-commits
Higuoxing added a comment.

I'll add some tests later.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84008



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D84008: [DWARFYAML] Refactor emitDebugInfo() to make the length be inferred.

2020-07-17 Thread Xing GUO via Phabricator via lldb-commits
Higuoxing created this revision.
Higuoxing added reviewers: jhenderson, grimar, MaskRay.
Herald added subscribers: llvm-commits, lldb-commits, hiraditya, mgorny.
Herald added projects: LLDB, LLVM.

This patch refactors `emitDebugInfo()` to make the length field be
inferred from its content. Besides, the `Visitor` class is removed in
this patch. The original `Visitor` class helps us determine an
appropriate length and emit the .debug_info section. These two
processes can be merged into one process. Besides, the length field
should be inferred when it's missing rather than when it's zero.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84008

Files:
  lldb/unittests/Expression/DWARFExpressionTest.cpp
  lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
  lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.cpp
  llvm/include/llvm/ObjectYAML/DWARFEmitter.h
  llvm/include/llvm/ObjectYAML/DWARFYAML.h
  llvm/lib/ObjectYAML/CMakeLists.txt
  llvm/lib/ObjectYAML/DWARFEmitter.cpp
  llvm/lib/ObjectYAML/DWARFVisitor.cpp
  llvm/lib/ObjectYAML/DWARFVisitor.h
  llvm/lib/ObjectYAML/DWARFYAML.cpp
  llvm/test/ObjectYAML/MachO/DWARF-debug_info.yaml
  llvm/test/ObjectYAML/MachO/DWARF2-AddrSize8-FormValues.yaml
  llvm/test/ObjectYAML/MachO/DWARF5-debug_info.yaml
  llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
  llvm/unittests/DebugInfo/DWARF/DWARFDieTest.cpp

Index: llvm/unittests/DebugInfo/DWARF/DWARFDieTest.cpp
===
--- llvm/unittests/DebugInfo/DWARF/DWARFDieTest.cpp
+++ llvm/unittests/DebugInfo/DWARF/DWARFDieTest.cpp
@@ -34,8 +34,7 @@
   - Attribute:   DW_AT_call_data_location
 Form:DW_FORM_sec_offset
 debug_info:
-  - Length:  0
-Version: 5
+  - Version: 5
 UnitType:DW_UT_compile
 AbbrOffset:  0
 AddrSize:4
@@ -49,7 +48,7 @@
   - Value:   25
   )";
   Expected>> Sections =
-  DWARFYAML::emitDebugSections(StringRef(yamldata), /*ApplyFixups=*/true,
+  DWARFYAML::emitDebugSections(StringRef(yamldata),
/*IsLittleEndian=*/true);
   ASSERT_THAT_EXPECTED(Sections, Succeeded());
   std::vector Loclists{
Index: llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
===
--- llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
+++ llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
@@ -1368,8 +1368,7 @@
  "Children:DW_CHILDREN_yes\n"
  "Attributes:\n"
  "debug_info:\n"
- "  - Length:  0\n"
- "Version: 4\n"
+ "  - Version: 4\n"
  "AbbrOffset:  0\n"
  "AddrSize:8\n"
  "Entries:\n"
@@ -1378,7 +1377,7 @@
  "  - AbbrCode:0x\n"
  "Values:\n";
 
-  auto ErrOrSections = DWARFYAML::emitDebugSections(StringRef(yamldata), true);
+  auto ErrOrSections = DWARFYAML::emitDebugSections(StringRef(yamldata));
   ASSERT_TRUE((bool)ErrOrSections);
   std::unique_ptr DwarfContext =
   DWARFContext::create(*ErrOrSections, 8);
Index: llvm/test/ObjectYAML/MachO/DWARF5-debug_info.yaml
===
--- llvm/test/ObjectYAML/MachO/DWARF5-debug_info.yaml
+++ llvm/test/ObjectYAML/MachO/DWARF5-debug_info.yaml
@@ -513,7 +513,7 @@
 
 #  DWARF32: DWARF:
 #  DWARF32:   debug_info:
-# DWARF32-NEXT: - Length: 118
+# DWARF32-NEXT: - Length: 0x0076
 # DWARF32-NEXT:   Version:5
 # DWARF32-NEXT:   UnitType:   DW_UT_compile
 # DWARF32-NEXT:   AbbrOffset: 0
@@ -585,7 +585,7 @@
 # RUN:   obj2yaml | FileCheck %s --check-prefix=DWARF32-YAML
 
 #  DWARF32-YAML: debug_info:
-# DWARF32-YAML-NEXT:   - Length: 12
+# DWARF32-YAML-NEXT:   - Length: 0x000C
 # DWARF32-YAML-NEXT: Version:5
 # DWARF32-YAML-NEXT: UnitType:   DW_UT_compile
 # DWARF32-YAML-NEXT: AbbrOffset: 0x
@@ -669,7 +669,7 @@
 
 #  DWARF64-YAML: debug_info:
 # DWARF64-YAML-NEXT:   - Format: DWARF64
-# DWARF64-YAML-NEXT: Length: 20
+# DWARF64-YAML-NEXT: Length: 0x0014
 # DWARF64-YAML-NEXT: Version:5
 # DWARF64-YAML-NEXT: UnitType:   DW_UT_compile
 # DWARF64-YAML-NEXT: AbbrOffset: 0x
Index: llvm/test/ObjectYAML/MachO/DWARF2-AddrSize8-FormValues.yaml
===
--- llvm/test/ObjectYAML/MachO/DWARF2-AddrSize8-FormValues.yaml
+++ llvm/test/ObjectYAML/MachO/DWARF2-AddrSize8-FormValues.yaml
@@ -415,7 +415,7 @@
 ...
 
 #CHECK:   debug_info: