[Lldb-commits] [PATCH] D127164: [WebAssembly] Add WASM_SEC_LAST_KNOWN to BinaryFormat section types list [NFC]

2022-06-06 Thread Derek Schuff via Phabricator via lldb-commits
dschuff created this revision.
dschuff added reviewers: aheejin, sbc100.
Herald added subscribers: pmatos, asb, wingo, ecnelises, sunfish, hiraditya, 
jgravelle-google.
Herald added a reviewer: jhenderson.
Herald added a project: All.
dschuff requested review of this revision.
Herald added subscribers: llvm-commits, lldb-commits, MaskRay.
Herald added projects: LLDB, LLVM.

There are 3 places where we were using WASM_SEC_TAG as the "last" known
section type, which requires updating (or leaves a bug) when a new known
section type is added. Instead add a "last type" to the enum for this
purpose.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127164

Files:
  lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
  llvm/include/llvm/BinaryFormat/Wasm.h
  llvm/lib/ObjCopy/wasm/WasmReader.cpp
  llvm/lib/Object/WasmObjectFile.cpp


Index: llvm/lib/Object/WasmObjectFile.cpp
===
--- llvm/lib/Object/WasmObjectFile.cpp
+++ llvm/lib/Object/WasmObjectFile.cpp
@@ -1729,7 +1729,7 @@
   const WasmSection &S = Sections[Sec.d.a];
   if (S.Type == wasm::WASM_SEC_CUSTOM)
 return S.Name;
-  if (S.Type > wasm::WASM_SEC_TAG)
+  if (S.Type >= wasm::WASM_SEC_LAST_KNOWN)
 return createStringError(object_error::invalid_section_index, "");
   return wasm::sectionTypeToString(S.Type);
 }
Index: llvm/lib/ObjCopy/wasm/WasmReader.cpp
===
--- llvm/lib/ObjCopy/wasm/WasmReader.cpp
+++ llvm/lib/ObjCopy/wasm/WasmReader.cpp
@@ -27,12 +27,8 @@
 // Give known sections standard names to allow them to be selected.
 Section &ReaderSec = Obj->Sections.back();
 if (ReaderSec.SectionType > WASM_SEC_CUSTOM &&
-ReaderSec.SectionType <= WASM_SEC_TAG)
+ReaderSec.SectionType < WASM_SEC_LAST_KNOWN)
   ReaderSec.Name = sectionTypeToString(ReaderSec.SectionType);
-// If the section type is CUSTOM, it has a name already. If it's a new type
-// of section that we don't explicitly handle here, it will have an empty
-// name and objcopy won't be able to select it by name (e.g. for removal
-// or dumping) but it will still be valid and able to be copied.
   }
   return std::move(Obj);
 }
Index: llvm/include/llvm/BinaryFormat/Wasm.h
===
--- llvm/include/llvm/BinaryFormat/Wasm.h
+++ llvm/include/llvm/BinaryFormat/Wasm.h
@@ -252,7 +252,8 @@
   WASM_SEC_CODE = 10,  // Function bodies (code)
   WASM_SEC_DATA = 11,  // Data segments
   WASM_SEC_DATACOUNT = 12, // Data segment count
-  WASM_SEC_TAG = 13// Tag declarations
+  WASM_SEC_TAG = 13,   // Tag declarations
+  WASM_SEC_LAST_KNOWN = 14,// Update this when adding new sections
 };
 
 // Type immediate encodings used in various contexts.
Index: lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
===
--- lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
+++ lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
@@ -192,7 +192,7 @@
 m_sect_infos.push_back(section_info{*offset_ptr + c.tell(), section_length,
 section_id, *sect_name});
 *offset_ptr += (c.tell() + section_length);
-  } else if (section_id <= llvm::wasm::WASM_SEC_TAG) {
+  } else if (section_id < llvm::wasm::WASM_SEC_LAST_KNOWN) {
 m_sect_infos.push_back(section_info{*offset_ptr + c.tell(),
 static_cast(payload_len),
 section_id, ConstString()});


Index: llvm/lib/Object/WasmObjectFile.cpp
===
--- llvm/lib/Object/WasmObjectFile.cpp
+++ llvm/lib/Object/WasmObjectFile.cpp
@@ -1729,7 +1729,7 @@
   const WasmSection &S = Sections[Sec.d.a];
   if (S.Type == wasm::WASM_SEC_CUSTOM)
 return S.Name;
-  if (S.Type > wasm::WASM_SEC_TAG)
+  if (S.Type >= wasm::WASM_SEC_LAST_KNOWN)
 return createStringError(object_error::invalid_section_index, "");
   return wasm::sectionTypeToString(S.Type);
 }
Index: llvm/lib/ObjCopy/wasm/WasmReader.cpp
===
--- llvm/lib/ObjCopy/wasm/WasmReader.cpp
+++ llvm/lib/ObjCopy/wasm/WasmReader.cpp
@@ -27,12 +27,8 @@
 // Give known sections standard names to allow them to be selected.
 Section &ReaderSec = Obj->Sections.back();
 if (ReaderSec.SectionType > WASM_SEC_CUSTOM &&
-ReaderSec.SectionType <= WASM_SEC_TAG)
+ReaderSec.SectionType < WASM_SEC_LAST_KNOWN)
   ReaderSec.Name = sectionTypeToString(ReaderSec.SectionType);
-// If the section type is CUSTOM, it has a name already. If it's a new type
-// of section that we don't explicitly handle here, it will have an empty
-// name and objcopy won't be able to select it by name (e.g. for removal
-// or dumping) but it will still be 

[Lldb-commits] [PATCH] D127164: [WebAssembly] Add WASM_SEC_LAST_KNOWN to BinaryFormat section types list [NFC]

2022-06-06 Thread Derek Schuff via Phabricator via lldb-commits
dschuff added inline comments.



Comment at: llvm/lib/ObjCopy/wasm/WasmReader.cpp:32-35
-// If the section type is CUSTOM, it has a name already. If it's a new type
-// of section that we don't explicitly handle here, it will have an empty
-// name and objcopy won't be able to select it by name (e.g. for removal
-// or dumping) but it will still be valid and able to be copied.

aheejin wrote:
> Why was this removed? It doesn't look like it's related to the last section 
> thing.. It's just explaning custom sections have names already.
Checking against `WASM_SEC_LAST_KNOWN` ensures that there can't be a new type 
of section that we don't explicitly handle here (because no types of known 
sections are explicitly handled or mentioned); any section known to 
`sectionTypeToString` will work.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127164

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


[Lldb-commits] [PATCH] D127164: [WebAssembly] Add WASM_SEC_LAST_KNOWN to BinaryFormat section types list [NFC]

2022-06-06 Thread Derek Schuff via Phabricator via lldb-commits
dschuff updated this revision to Diff 434647.
dschuff added a comment.

- review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127164

Files:
  lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
  llvm/include/llvm/BinaryFormat/Wasm.h
  llvm/lib/ObjCopy/wasm/WasmReader.cpp
  llvm/lib/Object/WasmObjectFile.cpp


Index: llvm/lib/Object/WasmObjectFile.cpp
===
--- llvm/lib/Object/WasmObjectFile.cpp
+++ llvm/lib/Object/WasmObjectFile.cpp
@@ -1729,7 +1729,7 @@
   const WasmSection &S = Sections[Sec.d.a];
   if (S.Type == wasm::WASM_SEC_CUSTOM)
 return S.Name;
-  if (S.Type > wasm::WASM_SEC_TAG)
+  if (S.Type > wasm::WASM_SEC_LAST_KNOWN)
 return createStringError(object_error::invalid_section_index, "");
   return wasm::sectionTypeToString(S.Type);
 }
Index: llvm/lib/ObjCopy/wasm/WasmReader.cpp
===
--- llvm/lib/ObjCopy/wasm/WasmReader.cpp
+++ llvm/lib/ObjCopy/wasm/WasmReader.cpp
@@ -27,12 +27,8 @@
 // Give known sections standard names to allow them to be selected.
 Section &ReaderSec = Obj->Sections.back();
 if (ReaderSec.SectionType > WASM_SEC_CUSTOM &&
-ReaderSec.SectionType <= WASM_SEC_TAG)
+ReaderSec.SectionType <= WASM_SEC_LAST_KNOWN)
   ReaderSec.Name = sectionTypeToString(ReaderSec.SectionType);
-// If the section type is CUSTOM, it has a name already. If it's a new type
-// of section that we don't explicitly handle here, it will have an empty
-// name and objcopy won't be able to select it by name (e.g. for removal
-// or dumping) but it will still be valid and able to be copied.
   }
   return std::move(Obj);
 }
Index: llvm/include/llvm/BinaryFormat/Wasm.h
===
--- llvm/include/llvm/BinaryFormat/Wasm.h
+++ llvm/include/llvm/BinaryFormat/Wasm.h
@@ -252,7 +252,8 @@
   WASM_SEC_CODE = 10,  // Function bodies (code)
   WASM_SEC_DATA = 11,  // Data segments
   WASM_SEC_DATACOUNT = 12, // Data segment count
-  WASM_SEC_TAG = 13// Tag declarations
+  WASM_SEC_TAG = 13,   // Tag declarations
+  WASM_SEC_LAST_KNOWN = WASM_SEC_TAG,
 };
 
 // Type immediate encodings used in various contexts.
Index: lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
===
--- lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
+++ lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
@@ -192,7 +192,7 @@
 m_sect_infos.push_back(section_info{*offset_ptr + c.tell(), section_length,
 section_id, *sect_name});
 *offset_ptr += (c.tell() + section_length);
-  } else if (section_id <= llvm::wasm::WASM_SEC_TAG) {
+  } else if (section_id <= llvm::wasm::WASM_SEC_LAST_KNOWN) {
 m_sect_infos.push_back(section_info{*offset_ptr + c.tell(),
 static_cast(payload_len),
 section_id, ConstString()});


Index: llvm/lib/Object/WasmObjectFile.cpp
===
--- llvm/lib/Object/WasmObjectFile.cpp
+++ llvm/lib/Object/WasmObjectFile.cpp
@@ -1729,7 +1729,7 @@
   const WasmSection &S = Sections[Sec.d.a];
   if (S.Type == wasm::WASM_SEC_CUSTOM)
 return S.Name;
-  if (S.Type > wasm::WASM_SEC_TAG)
+  if (S.Type > wasm::WASM_SEC_LAST_KNOWN)
 return createStringError(object_error::invalid_section_index, "");
   return wasm::sectionTypeToString(S.Type);
 }
Index: llvm/lib/ObjCopy/wasm/WasmReader.cpp
===
--- llvm/lib/ObjCopy/wasm/WasmReader.cpp
+++ llvm/lib/ObjCopy/wasm/WasmReader.cpp
@@ -27,12 +27,8 @@
 // Give known sections standard names to allow them to be selected.
 Section &ReaderSec = Obj->Sections.back();
 if (ReaderSec.SectionType > WASM_SEC_CUSTOM &&
-ReaderSec.SectionType <= WASM_SEC_TAG)
+ReaderSec.SectionType <= WASM_SEC_LAST_KNOWN)
   ReaderSec.Name = sectionTypeToString(ReaderSec.SectionType);
-// If the section type is CUSTOM, it has a name already. If it's a new type
-// of section that we don't explicitly handle here, it will have an empty
-// name and objcopy won't be able to select it by name (e.g. for removal
-// or dumping) but it will still be valid and able to be copied.
   }
   return std::move(Obj);
 }
Index: llvm/include/llvm/BinaryFormat/Wasm.h
===
--- llvm/include/llvm/BinaryFormat/Wasm.h
+++ llvm/include/llvm/BinaryFormat/Wasm.h
@@ -252,7 +252,8 @@
   WASM_SEC_CODE = 10,  // Function bodies (code)
   WASM_SEC_DATA = 11,  // Data segments
   WASM_SEC_DATACOUNT = 12, // Data segment count
-  WASM_SEC_TAG = 13// Tag declarat

[Lldb-commits] [PATCH] D127164: [WebAssembly] Add WASM_SEC_LAST_KNOWN to BinaryFormat section types list [NFC]

2022-06-06 Thread Derek Schuff via Phabricator via lldb-commits
dschuff added inline comments.



Comment at: llvm/include/llvm/BinaryFormat/Wasm.h:256
+  WASM_SEC_TAG = 13,   // Tag declarations
+  WASM_SEC_LAST_KNOWN = 14,// Update this when adding new sections
 };

aheejin wrote:
> - Does this pass clang-format? Because we don't have a space after `,`.
> - 14 is not actually the last section known, because we don't have a section 
> whose section code is 14. How about doing something like
> ```
> WAS_SEC_LAST_KNOWN = WASM_SEC_TAG;
> ```
> ?
ah, no it doesnt pass clang-format.
Also, agreed that LAST_KNOWN should match TAG rather than the one past-the-end. 
Fixed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127164

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


[Lldb-commits] [PATCH] D127164: [WebAssembly] Add WASM_SEC_LAST_KNOWN to BinaryFormat section types list [NFC]

2022-06-06 Thread Derek Schuff via Phabricator via lldb-commits
dschuff updated this revision to Diff 434650.
dschuff added a comment.

- expand comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127164

Files:
  lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
  llvm/include/llvm/BinaryFormat/Wasm.h
  llvm/lib/ObjCopy/wasm/WasmReader.cpp
  llvm/lib/Object/WasmObjectFile.cpp


Index: llvm/lib/Object/WasmObjectFile.cpp
===
--- llvm/lib/Object/WasmObjectFile.cpp
+++ llvm/lib/Object/WasmObjectFile.cpp
@@ -1729,7 +1729,7 @@
   const WasmSection &S = Sections[Sec.d.a];
   if (S.Type == wasm::WASM_SEC_CUSTOM)
 return S.Name;
-  if (S.Type > wasm::WASM_SEC_TAG)
+  if (S.Type > wasm::WASM_SEC_LAST_KNOWN)
 return createStringError(object_error::invalid_section_index, "");
   return wasm::sectionTypeToString(S.Type);
 }
Index: llvm/lib/ObjCopy/wasm/WasmReader.cpp
===
--- llvm/lib/ObjCopy/wasm/WasmReader.cpp
+++ llvm/lib/ObjCopy/wasm/WasmReader.cpp
@@ -24,15 +24,12 @@
 const WasmSection &WS = WasmObj.getWasmSection(Sec);
 Obj->Sections.push_back(
 {static_cast(WS.Type), WS.Name, WS.Content});
-// Give known sections standard names to allow them to be selected.
+// Give known sections standard names to allow them to be selected. (Custom
+// sections already have their names filled in by the parser).
 Section &ReaderSec = Obj->Sections.back();
 if (ReaderSec.SectionType > WASM_SEC_CUSTOM &&
-ReaderSec.SectionType <= WASM_SEC_TAG)
+ReaderSec.SectionType <= WASM_SEC_LAST_KNOWN)
   ReaderSec.Name = sectionTypeToString(ReaderSec.SectionType);
-// If the section type is CUSTOM, it has a name already. If it's a new type
-// of section that we don't explicitly handle here, it will have an empty
-// name and objcopy won't be able to select it by name (e.g. for removal
-// or dumping) but it will still be valid and able to be copied.
   }
   return std::move(Obj);
 }
Index: llvm/include/llvm/BinaryFormat/Wasm.h
===
--- llvm/include/llvm/BinaryFormat/Wasm.h
+++ llvm/include/llvm/BinaryFormat/Wasm.h
@@ -252,7 +252,8 @@
   WASM_SEC_CODE = 10,  // Function bodies (code)
   WASM_SEC_DATA = 11,  // Data segments
   WASM_SEC_DATACOUNT = 12, // Data segment count
-  WASM_SEC_TAG = 13// Tag declarations
+  WASM_SEC_TAG = 13,   // Tag declarations
+  WASM_SEC_LAST_KNOWN = WASM_SEC_TAG,
 };
 
 // Type immediate encodings used in various contexts.
Index: lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
===
--- lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
+++ lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
@@ -192,7 +192,7 @@
 m_sect_infos.push_back(section_info{*offset_ptr + c.tell(), section_length,
 section_id, *sect_name});
 *offset_ptr += (c.tell() + section_length);
-  } else if (section_id <= llvm::wasm::WASM_SEC_TAG) {
+  } else if (section_id <= llvm::wasm::WASM_SEC_LAST_KNOWN) {
 m_sect_infos.push_back(section_info{*offset_ptr + c.tell(),
 static_cast(payload_len),
 section_id, ConstString()});


Index: llvm/lib/Object/WasmObjectFile.cpp
===
--- llvm/lib/Object/WasmObjectFile.cpp
+++ llvm/lib/Object/WasmObjectFile.cpp
@@ -1729,7 +1729,7 @@
   const WasmSection &S = Sections[Sec.d.a];
   if (S.Type == wasm::WASM_SEC_CUSTOM)
 return S.Name;
-  if (S.Type > wasm::WASM_SEC_TAG)
+  if (S.Type > wasm::WASM_SEC_LAST_KNOWN)
 return createStringError(object_error::invalid_section_index, "");
   return wasm::sectionTypeToString(S.Type);
 }
Index: llvm/lib/ObjCopy/wasm/WasmReader.cpp
===
--- llvm/lib/ObjCopy/wasm/WasmReader.cpp
+++ llvm/lib/ObjCopy/wasm/WasmReader.cpp
@@ -24,15 +24,12 @@
 const WasmSection &WS = WasmObj.getWasmSection(Sec);
 Obj->Sections.push_back(
 {static_cast(WS.Type), WS.Name, WS.Content});
-// Give known sections standard names to allow them to be selected.
+// Give known sections standard names to allow them to be selected. (Custom
+// sections already have their names filled in by the parser).
 Section &ReaderSec = Obj->Sections.back();
 if (ReaderSec.SectionType > WASM_SEC_CUSTOM &&
-ReaderSec.SectionType <= WASM_SEC_TAG)
+ReaderSec.SectionType <= WASM_SEC_LAST_KNOWN)
   ReaderSec.Name = sectionTypeToString(ReaderSec.SectionType);
-// If the section type is CUSTOM, it has a name already. If it's a new type
-// of section that we don't explicitly handle here, it will have an empty
-/

[Lldb-commits] [PATCH] D127164: [WebAssembly] Add WASM_SEC_LAST_KNOWN to BinaryFormat section types list [NFC]

2022-06-06 Thread Derek Schuff via Phabricator via lldb-commits
dschuff added inline comments.



Comment at: llvm/lib/ObjCopy/wasm/WasmReader.cpp:32-35
-// If the section type is CUSTOM, it has a name already. If it's a new type
-// of section that we don't explicitly handle here, it will have an empty
-// name and objcopy won't be able to select it by name (e.g. for removal
-// or dumping) but it will still be valid and able to be copied.

aheejin wrote:
> dschuff wrote:
> > aheejin wrote:
> > > Why was this removed? It doesn't look like it's related to the last 
> > > section thing.. It's just explaning custom sections have names already.
> > Checking against `WASM_SEC_LAST_KNOWN` ensures that there can't be a new 
> > type of section that we don't explicitly handle here (because no types of 
> > known sections are explicitly handled or mentioned); any section known to 
> > `sectionTypeToString` will work.
> I'm not sure if I understand. Is this related to `WASM_SEC_TAG` -> 
> `WASM_LAST_SEC_KNOWN` change in this PR? Or it's just an unrelated drive-by 
> fix?
> 
> > Checking against `WASM_SEC_LAST_KNOWN` ensures that there can't be a new 
> > type of section that we don't explicitly handle here (because no types of 
> > known sections are explicitly handled or mentioned);
> 
> I'm not sure what this means..
> 
> > If the section type is CUSTOM, it has a name already.
> 
> Why is this deleted too? How is the custom section related to 
> `WASM_SEC_LAST_KNOWN`?
It is indirectly related.
The purpose of this block of code is to fill in the `Name` field of the 
`WasmSection` object for known sections (as the comment on line 27 explains). 
Suppose we add a new type of known section, WASM_SEC_NEW, and we update 
`sectionTypeToString` but forget to update this file.  Before this CL, the 
behavior would be as described in the comment I'm deleting; this code would 
silently fail to give that section a name, which would mean it couldn't be 
selected by llvm-objdump. After this CL, everything would work, without needing 
any updates to this file (and if we forgot to update `sectionTypeToString` it 
would assert when encountering an unknown section type). So this comment was 
just to describe the somewhat surprising failure mode, and isn't necessary 
anymore.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127164

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


[Lldb-commits] [PATCH] D127164: [WebAssembly] Add WASM_SEC_LAST_KNOWN to BinaryFormat section types list [NFC]

2022-06-07 Thread Derek Schuff via Phabricator via lldb-commits
dschuff added inline comments.



Comment at: llvm/lib/ObjCopy/wasm/WasmReader.cpp:32-35
-// If the section type is CUSTOM, it has a name already. If it's a new type
-// of section that we don't explicitly handle here, it will have an empty
-// name and objcopy won't be able to select it by name (e.g. for removal
-// or dumping) but it will still be valid and able to be copied.

aheejin wrote:
> dschuff wrote:
> > aheejin wrote:
> > > dschuff wrote:
> > > > aheejin wrote:
> > > > > Why was this removed? It doesn't look like it's related to the last 
> > > > > section thing.. It's just explaning custom sections have names 
> > > > > already.
> > > > Checking against `WASM_SEC_LAST_KNOWN` ensures that there can't be a 
> > > > new type of section that we don't explicitly handle here (because no 
> > > > types of known sections are explicitly handled or mentioned); any 
> > > > section known to `sectionTypeToString` will work.
> > > I'm not sure if I understand. Is this related to `WASM_SEC_TAG` -> 
> > > `WASM_LAST_SEC_KNOWN` change in this PR? Or it's just an unrelated 
> > > drive-by fix?
> > > 
> > > > Checking against `WASM_SEC_LAST_KNOWN` ensures that there can't be a 
> > > > new type of section that we don't explicitly handle here (because no 
> > > > types of known sections are explicitly handled or mentioned);
> > > 
> > > I'm not sure what this means..
> > > 
> > > > If the section type is CUSTOM, it has a name already.
> > > 
> > > Why is this deleted too? How is the custom section related to 
> > > `WASM_SEC_LAST_KNOWN`?
> > It is indirectly related.
> > The purpose of this block of code is to fill in the `Name` field of the 
> > `WasmSection` object for known sections (as the comment on line 27 
> > explains). Suppose we add a new type of known section, WASM_SEC_NEW, and we 
> > update `sectionTypeToString` but forget to update this file.  Before this 
> > CL, the behavior would be as described in the comment I'm deleting; this 
> > code would silently fail to give that section a name, which would mean it 
> > couldn't be selected by llvm-objdump. After this CL, everything would work, 
> > without needing any updates to this file (and if we forgot to update 
> > `sectionTypeToString` it would assert when encountering an unknown section 
> > type). So this comment was just to describe the somewhat surprising failure 
> > mode, and isn't necessary anymore.
> I see.  My original question was why
> > If the section type is CUSTOM, it has a name already. 
> is related to this CL, but I see you moved that comment to elsewhere, so it 
> hasn't really changed..
Ah yeah that bit of explanation is still valuable. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127164

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


[Lldb-commits] [PATCH] D127164: [WebAssembly] Add WASM_SEC_LAST_KNOWN to BinaryFormat section types list [NFC]

2022-06-07 Thread Derek Schuff via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2ae385e560a6: [WebAssembly] Add WASM_SEC_LAST_KNOWN to 
BinaryFormat section types list [NFC] (authored by dschuff).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127164

Files:
  lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
  llvm/include/llvm/BinaryFormat/Wasm.h
  llvm/lib/ObjCopy/wasm/WasmReader.cpp
  llvm/lib/Object/WasmObjectFile.cpp


Index: llvm/lib/Object/WasmObjectFile.cpp
===
--- llvm/lib/Object/WasmObjectFile.cpp
+++ llvm/lib/Object/WasmObjectFile.cpp
@@ -1729,7 +1729,7 @@
   const WasmSection &S = Sections[Sec.d.a];
   if (S.Type == wasm::WASM_SEC_CUSTOM)
 return S.Name;
-  if (S.Type > wasm::WASM_SEC_TAG)
+  if (S.Type > wasm::WASM_SEC_LAST_KNOWN)
 return createStringError(object_error::invalid_section_index, "");
   return wasm::sectionTypeToString(S.Type);
 }
Index: llvm/lib/ObjCopy/wasm/WasmReader.cpp
===
--- llvm/lib/ObjCopy/wasm/WasmReader.cpp
+++ llvm/lib/ObjCopy/wasm/WasmReader.cpp
@@ -24,15 +24,12 @@
 const WasmSection &WS = WasmObj.getWasmSection(Sec);
 Obj->Sections.push_back(
 {static_cast(WS.Type), WS.Name, WS.Content});
-// Give known sections standard names to allow them to be selected.
+// Give known sections standard names to allow them to be selected. (Custom
+// sections already have their names filled in by the parser).
 Section &ReaderSec = Obj->Sections.back();
 if (ReaderSec.SectionType > WASM_SEC_CUSTOM &&
-ReaderSec.SectionType <= WASM_SEC_TAG)
+ReaderSec.SectionType <= WASM_SEC_LAST_KNOWN)
   ReaderSec.Name = sectionTypeToString(ReaderSec.SectionType);
-// If the section type is CUSTOM, it has a name already. If it's a new type
-// of section that we don't explicitly handle here, it will have an empty
-// name and objcopy won't be able to select it by name (e.g. for removal
-// or dumping) but it will still be valid and able to be copied.
   }
   return std::move(Obj);
 }
Index: llvm/include/llvm/BinaryFormat/Wasm.h
===
--- llvm/include/llvm/BinaryFormat/Wasm.h
+++ llvm/include/llvm/BinaryFormat/Wasm.h
@@ -252,7 +252,8 @@
   WASM_SEC_CODE = 10,  // Function bodies (code)
   WASM_SEC_DATA = 11,  // Data segments
   WASM_SEC_DATACOUNT = 12, // Data segment count
-  WASM_SEC_TAG = 13// Tag declarations
+  WASM_SEC_TAG = 13,   // Tag declarations
+  WASM_SEC_LAST_KNOWN = WASM_SEC_TAG,
 };
 
 // Type immediate encodings used in various contexts.
Index: lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
===
--- lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
+++ lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
@@ -192,7 +192,7 @@
 m_sect_infos.push_back(section_info{*offset_ptr + c.tell(), section_length,
 section_id, *sect_name});
 *offset_ptr += (c.tell() + section_length);
-  } else if (section_id <= llvm::wasm::WASM_SEC_TAG) {
+  } else if (section_id <= llvm::wasm::WASM_SEC_LAST_KNOWN) {
 m_sect_infos.push_back(section_info{*offset_ptr + c.tell(),
 static_cast(payload_len),
 section_id, ConstString()});


Index: llvm/lib/Object/WasmObjectFile.cpp
===
--- llvm/lib/Object/WasmObjectFile.cpp
+++ llvm/lib/Object/WasmObjectFile.cpp
@@ -1729,7 +1729,7 @@
   const WasmSection &S = Sections[Sec.d.a];
   if (S.Type == wasm::WASM_SEC_CUSTOM)
 return S.Name;
-  if (S.Type > wasm::WASM_SEC_TAG)
+  if (S.Type > wasm::WASM_SEC_LAST_KNOWN)
 return createStringError(object_error::invalid_section_index, "");
   return wasm::sectionTypeToString(S.Type);
 }
Index: llvm/lib/ObjCopy/wasm/WasmReader.cpp
===
--- llvm/lib/ObjCopy/wasm/WasmReader.cpp
+++ llvm/lib/ObjCopy/wasm/WasmReader.cpp
@@ -24,15 +24,12 @@
 const WasmSection &WS = WasmObj.getWasmSection(Sec);
 Obj->Sections.push_back(
 {static_cast(WS.Type), WS.Name, WS.Content});
-// Give known sections standard names to allow them to be selected.
+// Give known sections standard names to allow them to be selected. (Custom
+// sections already have their names filled in by the parser).
 Section &ReaderSec = Obj->Sections.back();
 if (ReaderSec.SectionType > WASM_SEC_CUSTOM &&
-ReaderSec.SectionType <= WASM_SEC_TAG)
+ReaderSec.SectionType <= WASM_SEC_LAST_KNOWN)
   ReaderSec.Name = sectionTypeToString(ReaderSec.Sect

[Lldb-commits] [PATCH] D86090: Make DWARFExpression::GetLocationExpression public

2020-08-20 Thread Derek Schuff via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4e266eaf132f: Make DWARFExpression::GetLocationExpression 
public (authored by Eric, committed by dschuff).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86090

Files:
  lldb/include/lldb/Expression/DWARFExpression.h


Index: lldb/include/lldb/Expression/DWARFExpression.h
===
--- lldb/include/lldb/Expression/DWARFExpression.h
+++ lldb/include/lldb/Expression/DWARFExpression.h
@@ -219,6 +219,10 @@
 
   bool MatchesOperand(StackFrame &frame, const Instruction::Operand &op);
 
+  llvm::Optional
+  GetLocationExpression(lldb::addr_t load_function_start,
+lldb::addr_t addr) const;
+
 private:
   /// Pretty-prints the location expression to a stream
   ///
@@ -237,10 +241,6 @@
   void DumpLocation(Stream *s, const DataExtractor &data,
 lldb::DescriptionLevel level, ABI *abi) const;
 
-  llvm::Optional
-  GetLocationExpression(lldb::addr_t load_function_start,
-lldb::addr_t addr) const;
-
   /// Module which defined this expression.
   lldb::ModuleWP m_module_wp;
 


Index: lldb/include/lldb/Expression/DWARFExpression.h
===
--- lldb/include/lldb/Expression/DWARFExpression.h
+++ lldb/include/lldb/Expression/DWARFExpression.h
@@ -219,6 +219,10 @@
 
   bool MatchesOperand(StackFrame &frame, const Instruction::Operand &op);
 
+  llvm::Optional
+  GetLocationExpression(lldb::addr_t load_function_start,
+lldb::addr_t addr) const;
+
 private:
   /// Pretty-prints the location expression to a stream
   ///
@@ -237,10 +241,6 @@
   void DumpLocation(Stream *s, const DataExtractor &data,
 lldb::DescriptionLevel level, ABI *abi) const;
 
-  llvm::Optional
-  GetLocationExpression(lldb::addr_t load_function_start,
-lldb::addr_t addr) const;
-
   /// Module which defined this expression.
   lldb::ModuleWP m_module_wp;
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D82121: Set appropriate host defines for building under emscripten

2020-06-18 Thread Derek Schuff via Phabricator via lldb-commits
dschuff created this revision.
Herald added subscribers: llvm-commits, lldb-commits, aheejin, krytarowski.
Herald added projects: LLDB, LLVM.

Emscripten has emulations for several headers found on Linux,
including spwan.h and endian.h


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82121

Files:
  lldb/include/lldb/Host/HostInfo.h
  lldb/source/Host/common/Host.cpp
  llvm/include/llvm/Support/SwapByteOrder.h


Index: llvm/include/llvm/Support/SwapByteOrder.h
===
--- llvm/include/llvm/Support/SwapByteOrder.h
+++ llvm/include/llvm/Support/SwapByteOrder.h
@@ -21,7 +21,8 @@
 #include 
 #endif
 
-#if defined(__linux__) || defined(__GNU__) || defined(__HAIKU__)
+#if defined(__linux__) || defined(__GNU__) || defined(__HAIKU__) ||
\
+defined(__EMSCRIPTEN__)
 #include 
 #elif defined(_AIX)
 #include 
Index: lldb/source/Host/common/Host.cpp
===
--- lldb/source/Host/common/Host.cpp
+++ lldb/source/Host/common/Host.cpp
@@ -28,7 +28,7 @@
 
 #if defined(__linux__) || defined(__FreeBSD__) ||  
\
 defined(__FreeBSD_kernel__) || defined(__APPLE__) ||   
\
-defined(__NetBSD__) || defined(__OpenBSD__)
+defined(__NetBSD__) || defined(__OpenBSD__) || defined(__EMSCRIPTEN__)
 #if !defined(__ANDROID__)
 #include 
 #endif
Index: lldb/include/lldb/Host/HostInfo.h
===
--- lldb/include/lldb/Host/HostInfo.h
+++ lldb/include/lldb/Host/HostInfo.h
@@ -35,7 +35,7 @@
 #if defined(_WIN32)
 #include "lldb/Host/windows/HostInfoWindows.h"
 #define HOST_INFO_TYPE HostInfoWindows
-#elif defined(__linux__)
+#elif defined(__linux__) || defined(__EMSCRIPTEN__)
 #if defined(__ANDROID__)
 #include "lldb/Host/android/HostInfoAndroid.h"
 #define HOST_INFO_TYPE HostInfoAndroid


Index: llvm/include/llvm/Support/SwapByteOrder.h
===
--- llvm/include/llvm/Support/SwapByteOrder.h
+++ llvm/include/llvm/Support/SwapByteOrder.h
@@ -21,7 +21,8 @@
 #include 
 #endif
 
-#if defined(__linux__) || defined(__GNU__) || defined(__HAIKU__)
+#if defined(__linux__) || defined(__GNU__) || defined(__HAIKU__) ||\
+defined(__EMSCRIPTEN__)
 #include 
 #elif defined(_AIX)
 #include 
Index: lldb/source/Host/common/Host.cpp
===
--- lldb/source/Host/common/Host.cpp
+++ lldb/source/Host/common/Host.cpp
@@ -28,7 +28,7 @@
 
 #if defined(__linux__) || defined(__FreeBSD__) ||  \
 defined(__FreeBSD_kernel__) || defined(__APPLE__) ||   \
-defined(__NetBSD__) || defined(__OpenBSD__)
+defined(__NetBSD__) || defined(__OpenBSD__) || defined(__EMSCRIPTEN__)
 #if !defined(__ANDROID__)
 #include 
 #endif
Index: lldb/include/lldb/Host/HostInfo.h
===
--- lldb/include/lldb/Host/HostInfo.h
+++ lldb/include/lldb/Host/HostInfo.h
@@ -35,7 +35,7 @@
 #if defined(_WIN32)
 #include "lldb/Host/windows/HostInfoWindows.h"
 #define HOST_INFO_TYPE HostInfoWindows
-#elif defined(__linux__)
+#elif defined(__linux__) || defined(__EMSCRIPTEN__)
 #if defined(__ANDROID__)
 #include "lldb/Host/android/HostInfoAndroid.h"
 #define HOST_INFO_TYPE HostInfoAndroid
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D82121: Set appropriate host defines for building under emscripten

2020-06-18 Thread Derek Schuff via Phabricator via lldb-commits
dschuff added a reviewer: JDevlieghere.
dschuff added a comment.

Just taking a guess on a reviewer...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82121



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


[Lldb-commits] [PATCH] D82121: Set appropriate host defines for building under emscripten

2020-06-18 Thread Derek Schuff via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc1709e5d90e6: Set appropriate host defines for building 
under emscripten (authored by dschuff).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82121

Files:
  lldb/include/lldb/Host/HostInfo.h
  lldb/source/Host/common/Host.cpp
  llvm/include/llvm/Support/SwapByteOrder.h


Index: llvm/include/llvm/Support/SwapByteOrder.h
===
--- llvm/include/llvm/Support/SwapByteOrder.h
+++ llvm/include/llvm/Support/SwapByteOrder.h
@@ -21,7 +21,8 @@
 #include 
 #endif
 
-#if defined(__linux__) || defined(__GNU__) || defined(__HAIKU__)
+#if defined(__linux__) || defined(__GNU__) || defined(__HAIKU__) ||
\
+defined(__EMSCRIPTEN__)
 #include 
 #elif defined(_AIX)
 #include 
Index: lldb/source/Host/common/Host.cpp
===
--- lldb/source/Host/common/Host.cpp
+++ lldb/source/Host/common/Host.cpp
@@ -28,7 +28,7 @@
 
 #if defined(__linux__) || defined(__FreeBSD__) ||  
\
 defined(__FreeBSD_kernel__) || defined(__APPLE__) ||   
\
-defined(__NetBSD__) || defined(__OpenBSD__)
+defined(__NetBSD__) || defined(__OpenBSD__) || defined(__EMSCRIPTEN__)
 #if !defined(__ANDROID__)
 #include 
 #endif
Index: lldb/include/lldb/Host/HostInfo.h
===
--- lldb/include/lldb/Host/HostInfo.h
+++ lldb/include/lldb/Host/HostInfo.h
@@ -35,7 +35,7 @@
 #if defined(_WIN32)
 #include "lldb/Host/windows/HostInfoWindows.h"
 #define HOST_INFO_TYPE HostInfoWindows
-#elif defined(__linux__)
+#elif defined(__linux__) || defined(__EMSCRIPTEN__)
 #if defined(__ANDROID__)
 #include "lldb/Host/android/HostInfoAndroid.h"
 #define HOST_INFO_TYPE HostInfoAndroid


Index: llvm/include/llvm/Support/SwapByteOrder.h
===
--- llvm/include/llvm/Support/SwapByteOrder.h
+++ llvm/include/llvm/Support/SwapByteOrder.h
@@ -21,7 +21,8 @@
 #include 
 #endif
 
-#if defined(__linux__) || defined(__GNU__) || defined(__HAIKU__)
+#if defined(__linux__) || defined(__GNU__) || defined(__HAIKU__) ||\
+defined(__EMSCRIPTEN__)
 #include 
 #elif defined(_AIX)
 #include 
Index: lldb/source/Host/common/Host.cpp
===
--- lldb/source/Host/common/Host.cpp
+++ lldb/source/Host/common/Host.cpp
@@ -28,7 +28,7 @@
 
 #if defined(__linux__) || defined(__FreeBSD__) ||  \
 defined(__FreeBSD_kernel__) || defined(__APPLE__) ||   \
-defined(__NetBSD__) || defined(__OpenBSD__)
+defined(__NetBSD__) || defined(__OpenBSD__) || defined(__EMSCRIPTEN__)
 #if !defined(__ANDROID__)
 #include 
 #endif
Index: lldb/include/lldb/Host/HostInfo.h
===
--- lldb/include/lldb/Host/HostInfo.h
+++ lldb/include/lldb/Host/HostInfo.h
@@ -35,7 +35,7 @@
 #if defined(_WIN32)
 #include "lldb/Host/windows/HostInfoWindows.h"
 #define HOST_INFO_TYPE HostInfoWindows
-#elif defined(__linux__)
+#elif defined(__linux__) || defined(__EMSCRIPTEN__)
 #if defined(__ANDROID__)
 #include "lldb/Host/android/HostInfoAndroid.h"
 #define HOST_INFO_TYPE HostInfoAndroid
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D71575: [LLDB] Add ObjectFileWasm plugin for WebAssembly debugging

2020-01-15 Thread Derek Schuff via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4bafceced6a7: [LLDB] Add ObjectFileWasm plugin for 
WebAssembly debugging (authored by paolosev, committed by dschuff).

Changed prior to commit:
  https://reviews.llvm.org/D71575?vs=238168&id=238391#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71575

Files:
  lldb/include/lldb/Utility/ArchSpec.h
  lldb/source/API/SystemInitializerFull.cpp
  lldb/source/Plugins/ObjectFile/CMakeLists.txt
  lldb/source/Plugins/ObjectFile/wasm/CMakeLists.txt
  lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
  lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h
  lldb/source/Utility/ArchSpec.cpp
  lldb/test/Shell/ObjectFile/wasm/basic.yaml
  lldb/test/Shell/ObjectFile/wasm/embedded-debug-sections.yaml
  lldb/test/Shell/ObjectFile/wasm/stripped-debug-sections.yaml
  lldb/tools/lldb-test/SystemInitializerTest.cpp

Index: lldb/tools/lldb-test/SystemInitializerTest.cpp
===
--- lldb/tools/lldb-test/SystemInitializerTest.cpp
+++ lldb/tools/lldb-test/SystemInitializerTest.cpp
@@ -56,6 +56,7 @@
 #include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
 #include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h"
 #include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h"
+#include "Plugins/ObjectFile/wasm/ObjectFileWasm.h"
 #include "Plugins/Platform/Android/PlatformAndroid.h"
 #include "Plugins/Platform/FreeBSD/PlatformFreeBSD.h"
 #include "Plugins/Platform/Linux/PlatformLinux.h"
@@ -152,6 +153,7 @@
   ObjectFileELF::Initialize();
   ObjectFileMachO::Initialize();
   ObjectFilePECOFF::Initialize();
+  wasm::ObjectFileWasm::Initialize();
 
   ScriptInterpreterNone::Initialize();
 
@@ -345,6 +347,7 @@
   ObjectFileELF::Terminate();
   ObjectFileMachO::Terminate();
   ObjectFilePECOFF::Terminate();
+  wasm::ObjectFileWasm::Terminate();
 
   // Now shutdown the common parts, in reverse order.
   SystemInitializerCommon::Terminate();
Index: lldb/test/Shell/ObjectFile/wasm/stripped-debug-sections.yaml
===
--- /dev/null
+++ lldb/test/Shell/ObjectFile/wasm/stripped-debug-sections.yaml
@@ -0,0 +1,54 @@
+# RUN: yaml2obj %s > %t
+# RUN: lldb-test object-file %t | FileCheck %s
+
+# CHECK: Plugin name: wasm
+# CHECK: Architecture: wasm32-unknown-unknown-wasm
+# CHECK: UUID: 
+# CHECK: Executable: true
+# CHECK: Stripped: true
+# CHECK: Type: executable
+# CHECK: Strata: user
+# CHECK: Base VM address: 0x0
+
+# CHECK: Name: .debug_info
+# CHECK: Type: dwarf-info
+# CHECK: VM address: 0x0
+# CHECK: VM size: 0
+# CHECK: File size: 2
+
+# CHECK: Name: .debug_abbrev
+# CHECK: Type: dwarf-abbrev
+# CHECK: VM address: 0x0
+# CHECK: VM size: 0
+# CHECK: File size: 2
+
+# CHECK: Name: .debug_line
+# CHECK: Type: dwarf-line
+# CHECK: VM address: 0x0
+# CHECK: VM size: 0
+# CHECK: File size: 2
+
+# CHECK: Name: .debug_str
+# CHECK: Type: dwarf-str
+# CHECK: VM address: 0x0
+# CHECK: VM size: 0
+# CHECK: File size: 3
+
+--- !WASM
+FileHeader:
+  Version: 0x0001
+Sections:
+
+  - Type:CUSTOM
+Name:.debug_info
+Payload: 4C00
+  - Type:CUSTOM
+Name:.debug_abbrev
+Payload: 0111
+  - Type:CUSTOM
+Name:.debug_line
+Payload: 5100
+  - Type:CUSTOM
+Name:.debug_str
+Payload: 636CFF
+...
Index: lldb/test/Shell/ObjectFile/wasm/embedded-debug-sections.yaml
===
--- /dev/null
+++ lldb/test/Shell/ObjectFile/wasm/embedded-debug-sections.yaml
@@ -0,0 +1,67 @@
+# RUN: yaml2obj %s > %t
+# RUN: lldb-test object-file %t | FileCheck %s
+
+# CHECK: Plugin name: wasm
+# CHECK: Architecture: wasm32-unknown-unknown-wasm
+# CHECK: UUID: 
+# CHECK: Executable: true
+# CHECK: Stripped: true
+# CHECK: Type: executable
+# CHECK: Strata: user
+# CHECK: Base VM address: 0xa
+
+# CHECK: Name: code
+# CHECK: Type: code
+# CHECK: VM address: 0x0
+# CHECK: VM size: 56
+# CHECK: File size: 56
+
+# CHECK: Name: .debug_info
+# CHECK: Type: dwarf-info
+# CHECK: VM address: 0x0
+# CHECK: VM size: 0
+# CHECK: File size: 2
+
+# CHECK: Name: .debug_abbrev
+# CHECK: Type: dwarf-abbrev
+# CHECK: VM address: 0x0
+# CHECK: VM size: 0
+# CHECK: File size: 2
+
+# CHECK: Name: .debug_line
+# CHECK: Type: dwarf-line
+# CHECK: VM address: 0x0
+# CHECK: VM size: 0
+# CHECK: File size: 2
+
+# CHECK: Name: .debug_str
+# CHECK: Type: dwarf-str
+# CHECK: VM address: 0x0
+# CHECK: VM size: 0
+# CHECK: File size: 3
+
+--- !WASM
+FileHeader:
+  Version: 0x0001
+Sections:
+
+  - Type:CODE
+Functions:
+  - Index:   0
+Locals:
+  - Type:I32
+Count:   6
+Body:2380808080002101411021022001

[Lldb-commits] [PATCH] D72650: [LLDB] Add SymbolVendorWasm plugin for WebAssembly debugging

2020-01-16 Thread Derek Schuff via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9b3254dbf9f6: [LLDB] Add SymbolVendorWasm plugin for 
WebAssembly debugging (authored by paolosev, committed by dschuff).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72650

Files:
  lldb/source/API/SystemInitializerFull.cpp
  lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
  lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h
  lldb/source/Plugins/SymbolVendor/CMakeLists.txt
  lldb/source/Plugins/SymbolVendor/wasm/CMakeLists.txt
  lldb/source/Plugins/SymbolVendor/wasm/SymbolVendorWasm.cpp
  lldb/source/Plugins/SymbolVendor/wasm/SymbolVendorWasm.h
  lldb/test/Shell/ObjectFile/wasm/unified-debug-sections.yaml
  lldb/tools/lldb-test/SystemInitializerTest.cpp

Index: lldb/tools/lldb-test/SystemInitializerTest.cpp
===
--- lldb/tools/lldb-test/SystemInitializerTest.cpp
+++ lldb/tools/lldb-test/SystemInitializerTest.cpp
@@ -76,6 +76,7 @@
 #include "Plugins/SymbolFile/PDB/SymbolFilePDB.h"
 #include "Plugins/SymbolFile/Symtab/SymbolFileSymtab.h"
 #include "Plugins/SymbolVendor/ELF/SymbolVendorELF.h"
+#include "Plugins/SymbolVendor/wasm/SymbolVendorWasm.h"
 #include "Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h"
 #include "Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h"
 #include "Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h"
@@ -201,6 +202,7 @@
   SymbolFileDWARF::Initialize();
   SymbolFilePDB::Initialize();
   SymbolFileSymtab::Initialize();
+  wasm::SymbolVendorWasm::Initialize();
   UnwindAssemblyInstEmulation::Initialize();
   UnwindAssembly_x86::Initialize();
   EmulateInstructionARM64::Initialize();
@@ -288,6 +290,7 @@
   SymbolFileDWARF::Terminate();
   SymbolFilePDB::Terminate();
   SymbolFileSymtab::Terminate();
+  wasm::SymbolVendorWasm::Terminate();
   UnwindAssembly_x86::Terminate();
   UnwindAssemblyInstEmulation::Terminate();
   EmulateInstructionARM64::Terminate();
Index: lldb/test/Shell/ObjectFile/wasm/unified-debug-sections.yaml
===
--- /dev/null
+++ lldb/test/Shell/ObjectFile/wasm/unified-debug-sections.yaml
@@ -0,0 +1,85 @@
+# RUN: yaml2obj -docnum=1 %s > test.wasm
+# RUN: yaml2obj -docnum=2 %s > test_sym.wasm
+# RUN: lldb-test object-file test.wasm | FileCheck %s
+
+# This test checks that SymbolVendorWasm correctly loads DWARF debug sections
+# that have been stripped out into a separated Wasm module. The original Wasm
+# module contains a "external_debug_info" custom section with the absolute or
+# relative path of the debug module.
+
+# CHECK: Plugin name: wasm
+# CHECK: Architecture: wasm32-unknown-unknown-wasm
+# CHECK: UUID: 
+# CHECK: Executable: true
+# CHECK: Stripped: true
+# CHECK: Type: executable
+# CHECK: Strata: user
+# CHECK: Base VM address: 0xa
+
+# CHECK: Name: code
+# CHECK: Type: code
+# CHECK: VM address: 0x0
+# CHECK: VM size: 56
+# CHECK: File size: 56
+
+# CHECK: Name: .debug_info
+# CHECK: Type: dwarf-info
+# CHECK: VM address: 0x0
+# CHECK: VM size: 0
+# CHECK: File size: 2
+
+# CHECK: Name: .debug_abbrev
+# CHECK: Type: dwarf-abbrev
+# CHECK: VM address: 0x0
+# CHECK: VM size: 0
+# CHECK: File size: 2
+
+# CHECK: Name: .debug_line
+# CHECK: Type: dwarf-line
+# CHECK: VM address: 0x0
+# CHECK: VM size: 0
+# CHECK: File size: 2
+
+# CHECK: Name: .debug_str
+# CHECK: Type: dwarf-str
+# CHECK: VM address: 0x0
+# CHECK: VM size: 0
+# CHECK: File size: 3
+
+--- !WASM
+FileHeader:
+  Version: 0x0001
+Sections:
+  - Type:CODE
+Functions:
+  - Index:   0
+Locals:
+  - Type:I32
+Count:   6
+Body:238080808000210141102102200120026B21032003200036020C200328020C2104200328020C2105200420056C210620060F0B
+  - Type:CUSTOM
+Name:external_debug_info
+Payload: 0D746573745F73796D2E7761736D  # test_sym.wasm
+
+...
+
+
+--- !WASM
+FileHeader:
+  Version: 0x0001
+Sections:
+
+  - Type:CUSTOM
+Name:.debug_info
+Payload: 4C00
+  - Type:CUSTOM
+Name:.debug_abbrev
+Payload: 0111
+  - Type:CUSTOM
+Name:.debug_line
+Payload: 5100
+  - Type:CUSTOM
+Name:.debug_str
+Payload: 636CFF
+
+...
Index: lldb/source/Plugins/SymbolVendor/wasm/SymbolVendorWasm.h
===
--- /dev/null
+++ lldb/source/Plugins/SymbolVendor/wasm/SymbolVendorWasm.h
@@ -0,0 +1,44 @@
+//===-- SymbolVendorWasm.h --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-Lice

[Lldb-commits] [PATCH] D72751: [LLDB] Add DynamicLoaderWasmDYLD plugin for WebAssembly debugging

2020-02-05 Thread Derek Schuff via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3ec28da6d643: [LLDB] Add DynamicLoaderWasmDYLD plugin for 
WebAssembly debugging (authored by paolosev, committed by dschuff).

Changed prior to commit:
  https://reviews.llvm.org/D72751?vs=242733&id=242754#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72751

Files:
  
lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestWasm.py
  
lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/test_sym.yaml
  
lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/test_wasm_embedded_debug_sections.yaml
  
lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/test_wasm_external_debug_sections.yaml
  lldb/source/API/SystemInitializerFull.cpp
  lldb/source/Plugins/DynamicLoader/CMakeLists.txt
  lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
  lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h
  lldb/test/Shell/ObjectFile/wasm/basic.yaml
  lldb/test/Shell/ObjectFile/wasm/embedded-debug-sections.yaml
  lldb/test/Shell/ObjectFile/wasm/stripped-debug-sections.yaml
  lldb/test/Shell/ObjectFile/wasm/unified-debug-sections.yaml
  lldb/tools/lldb-test/SystemInitializerTest.cpp

Index: lldb/tools/lldb-test/SystemInitializerTest.cpp
===
--- lldb/tools/lldb-test/SystemInitializerTest.cpp
+++ lldb/tools/lldb-test/SystemInitializerTest.cpp
@@ -38,6 +38,7 @@
 #include "Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h"
 #include "Plugins/DynamicLoader/Static/DynamicLoaderStatic.h"
 #include "Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h"
+#include "Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.h"
 #include "Plugins/Instruction/ARM/EmulateInstructionARM.h"
 #include "Plugins/Instruction/ARM64/EmulateInstructionARM64.h"
 #include "Plugins/Instruction/MIPS/EmulateInstructionMIPS.h"
@@ -244,6 +245,7 @@
   DynamicLoaderMacOSXDYLD::Initialize();
   DynamicLoaderMacOS::Initialize();
   DynamicLoaderPOSIXDYLD::Initialize();
+  wasm::DynamicLoaderWasmDYLD::Initialize(); // before DynamicLoaderStatic.
   DynamicLoaderStatic::Initialize();
   DynamicLoaderWindowsDYLD::Initialize();
 
@@ -332,6 +334,7 @@
   DynamicLoaderMacOSXDYLD::Terminate();
   DynamicLoaderMacOS::Terminate();
   DynamicLoaderPOSIXDYLD::Terminate();
+  wasm::DynamicLoaderWasmDYLD::Terminate();
   DynamicLoaderStatic::Terminate();
   DynamicLoaderWindowsDYLD::Terminate();
 
Index: lldb/test/Shell/ObjectFile/wasm/unified-debug-sections.yaml
===
--- lldb/test/Shell/ObjectFile/wasm/unified-debug-sections.yaml
+++ lldb/test/Shell/ObjectFile/wasm/unified-debug-sections.yaml
@@ -13,11 +13,11 @@
 # CHECK: Plugin name: wasm
 # CHECK: Architecture: wasm32-unknown-unknown-wasm
 # CHECK: UUID: 
-# CHECK: Executable: true
+# CHECK: Executable: false
 # CHECK: Stripped: true
-# CHECK: Type: executable
+# CHECK: Type: shared library
 # CHECK: Strata: user
-# CHECK: Base VM address: 0xa
+# CHECK: Base VM address: 0x0
 
 # CHECK: Name: code
 # CHECK: Type: code
Index: lldb/test/Shell/ObjectFile/wasm/stripped-debug-sections.yaml
===
--- lldb/test/Shell/ObjectFile/wasm/stripped-debug-sections.yaml
+++ lldb/test/Shell/ObjectFile/wasm/stripped-debug-sections.yaml
@@ -4,9 +4,9 @@
 # CHECK: Plugin name: wasm
 # CHECK: Architecture: wasm32-unknown-unknown-wasm
 # CHECK: UUID: 
-# CHECK: Executable: true
-# CHECK: Stripped: true
-# CHECK: Type: executable
+# CHECK: Executable: false
+# CHECK: Stripped: false
+# CHECK: Type: shared library
 # CHECK: Strata: user
 # CHECK: Base VM address: 0x0
 
Index: lldb/test/Shell/ObjectFile/wasm/embedded-debug-sections.yaml
===
--- lldb/test/Shell/ObjectFile/wasm/embedded-debug-sections.yaml
+++ lldb/test/Shell/ObjectFile/wasm/embedded-debug-sections.yaml
@@ -4,11 +4,11 @@
 # CHECK: Plugin name: wasm
 # CHECK: Architecture: wasm32-unknown-unknown-wasm
 # CHECK: UUID: 
-# CHECK: Executable: true
-# CHECK: Stripped: true
-# CHECK: Type: executable
+# CHECK: Executable: false
+# CHECK: Stripped: false
+# CHECK: Type: shared library
 # CHECK: Strata: user
-# CHECK: Base VM address: 0xa
+# CHECK: Base VM address: 0x0
 
 # CHECK: Name: code
 # CHECK: Type: code
Index: lldb/test/Shell/ObjectFile/wasm/basic.yaml
===
--- lldb/test/Shell/ObjectFile/wasm/basic.yaml
+++ lldb/test/Shell/ObjectFile/wasm/basic.yaml
@@ -4,11 +4,11 @@
 # CHECK: Plugin name: wasm
 # CHECK: Architecture: wasm32-unknown-unknown-wasm
 # CHECK: UUID: 
-# CHECK: Executable: true
-# CHECK: Stripped: true
-# CHECK: Type: executable
+# CHECK: Executable: false
+# CHECK: Stripped: false
+# CHECK: Type: s

[Lldb-commits] [PATCH] D72751: [LLDB] Add DynamicLoaderWasmDYLD plugin for WebAssembly debugging

2020-02-05 Thread Derek Schuff via Phabricator via lldb-commits
dschuff added a comment.

My bad, sorry about that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72751



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


[Lldb-commits] [PATCH] D72751: [LLDB] Add DynamicLoaderWasmDYLD plugin for WebAssembly debugging

2020-02-05 Thread Derek Schuff via Phabricator via lldb-commits
dschuff added a comment.

fixed in rGf5f70d1c8 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72751



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