[PATCH] D75485: Support DW_FORM_strx* in llvm-dwp.
Ali Tamur via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 3 18:30:33 PST 2020
tamur updated this revision to Diff 248079.
tamur added a comment.
Simplified the test. llvm-dwp and llvm-dwarfdump works fine for this simple test, but in any case I don't want to overspecify the output.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D75485/new/
https://reviews.llvm.org/D75485
Files:
llvm/test/tools/llvm-dwp/Inputs/handle_strx/main.dwo
llvm/test/tools/llvm-dwp/X86/handle_strx.test
llvm/test/tools/llvm-dwp/X86/invalid_string_form.test
llvm/tools/llvm-dwp/llvm-dwp.cpp
Index: llvm/tools/llvm-dwp/llvm-dwp.cpp
===================================================================
--- llvm/tools/llvm-dwp/llvm-dwp.cpp
+++ llvm/tools/llvm-dwp/llvm-dwp.cpp
@@ -121,10 +121,30 @@
uint64_t &InfoOffset, StringRef StrOffsets, StringRef Str) {
if (Form == dwarf::DW_FORM_string)
return InfoData.getCStr(&InfoOffset);
- if (Form != dwarf::DW_FORM_GNU_str_index)
+ uint64_t StrIndex;
+ switch (Form) {
+ case dwarf::DW_FORM_strx1:
+ StrIndex = InfoData.getU8(&InfoOffset);
+ break;
+ case dwarf::DW_FORM_strx2:
+ StrIndex = InfoData.getU16(&InfoOffset);
+ break;
+ case dwarf::DW_FORM_strx3:
+ StrIndex = InfoData.getU24(&InfoOffset);
+ break;
+ case dwarf::DW_FORM_strx4:
+ StrIndex = InfoData.getU32(&InfoOffset);
+ break;
+ case dwarf::DW_FORM_strx:
+ case dwarf::DW_FORM_GNU_str_index:
+ StrIndex = InfoData.getULEB128(&InfoOffset);
+ break;
+ default:
return make_error<DWPError>(
- "string field encoded without DW_FORM_string or DW_FORM_GNU_str_index");
- auto StrIndex = InfoData.getULEB128(&InfoOffset);
+ "string field must be encoded with one of the following: "
+ "DW_FORM_string, DW_FORM_strx, DW_FORM_strx1, DW_FORM_strx2, "
+ "DW_FORM_strx3, DW_FORM_strx4, or DW_FORM_GNU_str_index.");
+ }
DataExtractor StrOffsetsData(StrOffsets, true, 0);
uint64_t StrOffsetsOffset = 4 * StrIndex;
uint64_t StrOffset = StrOffsetsData.getU32(&StrOffsetsOffset);
Index: llvm/test/tools/llvm-dwp/X86/invalid_string_form.test
===================================================================
--- llvm/test/tools/llvm-dwp/X86/invalid_string_form.test
+++ llvm/test/tools/llvm-dwp/X86/invalid_string_form.test
@@ -1,3 +1,5 @@
+RUN: not llvm-dwp %p/../Inputs/invalid_string_form.dwo -o %t 2>&1 | xargs echo
RUN: not llvm-dwp %p/../Inputs/invalid_string_form.dwo -o %t 2>&1 | FileCheck %s
-CHECK: error: {{.*}}invalid_string_form.dwo': string field encoded without DW_FORM_string or DW_FORM_GNU_str_index
+CHECK: error: {{.*}}: string field must be encoded with one of the following:
+CHECK: DW_FORM_string, DW_FORM_strx, DW_FORM_strx1, DW_FORM_strx2, DW_FORM_strx3, DW_FORM_strx4, or DW_FORM_GNU_str_index.
Index: llvm/test/tools/llvm-dwp/X86/handle_strx.test
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-dwp/X86/handle_strx.test
@@ -0,0 +1,19 @@
+RUN: llvm-dwp %p/../Inputs/handle_strx/main.dwo -o %t 2>/dev/null
+RUN: llvm-dwarfdump --verbose %t 2>/dev/null | FileCheck %s
+
+To build main.dwo from source:
+main.cc:
+#include "a.h"
+
+int main() {
+ f1();
+ return 0;
+}
+
+$ clang++ -gdwarf-5 -gsplit-dwarf -c a.cc
+$ clang++ -gdwarf-5 -gsplit-dwarf -c main.cc
+
+Check that llvm-dwp succeeds and handles DW_FORM_strx1
+
+CHECK: DW_AT_producer [DW_FORM_strx1]
+
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75485.248079.patch
Type: text/x-patch
Size: 2893 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200304/81433d7c/attachment.bin>
More information about the llvm-commits
mailing list