[Lldb-commits] [PATCH] D40211: Add comments to DWARFCompileUnit length fields/methods

2017-11-19 Thread Pavel Labath via Phabricator via lldb-commits
labath added a subscriber: lldb-commits.
labath accepted this revision.
labath added a comment.
This revision is now accepted and ready to land.

If you are confident that the behavior you are documenting is correct, I think 
you can submit patches like these without approval. If you do end up sending 
something up for review, please be sure to add "lldb-commits" as a subscriber.


https://reviews.llvm.org/D40211



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


[Lldb-commits] [PATCH] D40212: refactor: Unify+simplify DWARFCompileUnit ctor+Clear() into in-class initializers

2017-11-19 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

You're using a fairly novel (to this codebase at least) simplification 
technique, so I think we should discuss that first. The way we have normally 
done these things is to just have the constructor call the Clear() function.

Personally, I am not really sure what to think about this approach. On one 
side, I kinda like it, but on the other one, it feels somewhat dodgy.


https://reviews.llvm.org/D40212



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


[Lldb-commits] [lldb] r318626 - Add comments to DWARFCompileUnit length fields/methods

2017-11-19 Thread Jan Kratochvil via lldb-commits
Author: jankratochvil
Date: Sun Nov 19 06:35:07 2017
New Revision: 318626

URL: http://llvm.org/viewvc/llvm-project?rev=318626&view=rev
Log:
Add comments to DWARFCompileUnit length fields/methods

Differential revision: https://reviews.llvm.org/D40211

Modified:
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h?rev=318626&r1=318625&r2=318626&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h Sun Nov 19 
06:35:07 2017
@@ -41,26 +41,24 @@ public:
   void Clear();
   bool Verify(lldb_private::Stream *s) const;
   void Dump(lldb_private::Stream *s) const;
+  // Offset of the initial length field.
   dw_offset_t GetOffset() const { return m_offset; }
   lldb::user_id_t GetID() const;
-  uint32_t Size() const {
-return m_is_dwarf64 ? 23
-: 11; /* Size in bytes of the compile unit header */
-  }
+  // Size in bytes of the initial length + compile unit header.
+  uint32_t Size() const { return m_is_dwarf64 ? 23 : 11; }
   bool ContainsDIEOffset(dw_offset_t die_offset) const {
 return die_offset >= GetFirstDIEOffset() &&
die_offset < GetNextCompileUnitOffset();
   }
   dw_offset_t GetFirstDIEOffset() const { return m_offset + Size(); }
   dw_offset_t GetNextCompileUnitOffset() const {
-return m_offset + m_length + (m_is_dwarf64 ? 12 : 4);
+return m_offset + (m_is_dwarf64 ? 12 : 4) + m_length;
   }
+  // Size of the CU data (without initial length and without header).
   size_t GetDebugInfoSize() const {
-return m_length + (m_is_dwarf64 ? 12 : 4) - Size(); /* Size in bytes of the
-   .debug_info data
-   associated with this
-   compile unit. */
+return (m_is_dwarf64 ? 12 : 4) + m_length - Size();
   }
+  // Size of the CU data incl. header but without initial length.
   uint32_t GetLength() const { return m_length; }
   uint16_t GetVersion() const { return m_version; }
   const DWARFAbbreviationDeclarationSet *GetAbbreviations() const {
@@ -175,6 +173,7 @@ protected:
 // DW_TAG_subprogram
 // DIEs
   dw_addr_t m_base_addr;
+  // Offset of the initial length field.
   dw_offset_t m_offset;
   dw_offset_t m_length;
   uint16_t m_version;


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


[Lldb-commits] [PATCH] D40211: Add comments to DWARFCompileUnit length fields/methods

2017-11-19 Thread Jan Kratochvil via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL318626: Add comments to DWARFCompileUnit length 
fields/methods (authored by jankratochvil).

Changed prior to commit:
  https://reviews.llvm.org/D40211?vs=123472&id=123498#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D40211

Files:
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h


Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
@@ -41,26 +41,24 @@
   void Clear();
   bool Verify(lldb_private::Stream *s) const;
   void Dump(lldb_private::Stream *s) const;
+  // Offset of the initial length field.
   dw_offset_t GetOffset() const { return m_offset; }
   lldb::user_id_t GetID() const;
-  uint32_t Size() const {
-return m_is_dwarf64 ? 23
-: 11; /* Size in bytes of the compile unit header */
-  }
+  // Size in bytes of the initial length + compile unit header.
+  uint32_t Size() const { return m_is_dwarf64 ? 23 : 11; }
   bool ContainsDIEOffset(dw_offset_t die_offset) const {
 return die_offset >= GetFirstDIEOffset() &&
die_offset < GetNextCompileUnitOffset();
   }
   dw_offset_t GetFirstDIEOffset() const { return m_offset + Size(); }
   dw_offset_t GetNextCompileUnitOffset() const {
-return m_offset + m_length + (m_is_dwarf64 ? 12 : 4);
+return m_offset + (m_is_dwarf64 ? 12 : 4) + m_length;
   }
+  // Size of the CU data (without initial length and without header).
   size_t GetDebugInfoSize() const {
-return m_length + (m_is_dwarf64 ? 12 : 4) - Size(); /* Size in bytes of the
-   .debug_info data
-   associated with this
-   compile unit. */
+return (m_is_dwarf64 ? 12 : 4) + m_length - Size();
   }
+  // Size of the CU data incl. header but without initial length.
   uint32_t GetLength() const { return m_length; }
   uint16_t GetVersion() const { return m_version; }
   const DWARFAbbreviationDeclarationSet *GetAbbreviations() const {
@@ -175,6 +173,7 @@
 // DW_TAG_subprogram
 // DIEs
   dw_addr_t m_base_addr;
+  // Offset of the initial length field.
   dw_offset_t m_offset;
   dw_offset_t m_length;
   uint16_t m_version;


Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
@@ -41,26 +41,24 @@
   void Clear();
   bool Verify(lldb_private::Stream *s) const;
   void Dump(lldb_private::Stream *s) const;
+  // Offset of the initial length field.
   dw_offset_t GetOffset() const { return m_offset; }
   lldb::user_id_t GetID() const;
-  uint32_t Size() const {
-return m_is_dwarf64 ? 23
-: 11; /* Size in bytes of the compile unit header */
-  }
+  // Size in bytes of the initial length + compile unit header.
+  uint32_t Size() const { return m_is_dwarf64 ? 23 : 11; }
   bool ContainsDIEOffset(dw_offset_t die_offset) const {
 return die_offset >= GetFirstDIEOffset() &&
die_offset < GetNextCompileUnitOffset();
   }
   dw_offset_t GetFirstDIEOffset() const { return m_offset + Size(); }
   dw_offset_t GetNextCompileUnitOffset() const {
-return m_offset + m_length + (m_is_dwarf64 ? 12 : 4);
+return m_offset + (m_is_dwarf64 ? 12 : 4) + m_length;
   }
+  // Size of the CU data (without initial length and without header).
   size_t GetDebugInfoSize() const {
-return m_length + (m_is_dwarf64 ? 12 : 4) - Size(); /* Size in bytes of the
-   .debug_info data
-   associated with this
-   compile unit. */
+return (m_is_dwarf64 ? 12 : 4) + m_length - Size();
   }
+  // Size of the CU data incl. header but without initial length.
   uint32_t GetLength() const { return m_length; }
   uint16_t GetVersion() const { return m_version; }
   const DWARFAbbreviationDeclarationSet *GetAbbreviations() const {
@@ -175,6 +173,7 @@
 // DW_TAG_subprogram
 // DIEs
   dw_addr_t m_base_addr;
+  // Offset of the initial length field.
   dw_offset_t m_offset;
   dw_offset_t m_length;
   uint16_t m_version;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/m

[Lldb-commits] [PATCH] D40212: refactor: Unify+simplify DWARFCompileUnit ctor+Clear() into in-class initializers

2017-11-19 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

Good change in the header file. I am not sure I like the destruct this object 
in place and replace with new version... If this is commonly done and 
acceptable form of C++ I would be ok with it, but I agree with Pavel, it seems 
a little bit off the books.


https://reviews.llvm.org/D40212



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


[Lldb-commits] [PATCH] D40214: performance: Prevent needless DWARFCompileUnit::Clear() on freshly ctor-ed object

2017-11-19 Thread Greg Clayton via Phabricator via lldb-commits
clayborg requested changes to this revision.
clayborg added a comment.
This revision now requires changes to proceed.

See inline comments.




Comment at: source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp:74
lldb::offset_t *offset_ptr) {
-  Clear();
-
+  assert(m_offset == DW_INVALID_OFFSET);
   m_offset = *offset_ptr;

Make this static as mentioned in above comment. Assertions are ok to detect 
things in debug build, but please use lldbassert and make sure it returns an 
empty shared pointer if things fail (code must function properly when assert is 
not compiled in the program.



Comment at: source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h:34-36
+  // Object must be clear - either constructed now or after calling Clear().
   bool Extract(const lldb_private::DWARFDataExtractor &debug_info,
lldb::offset_t *offset_ptr);

If you want to enforce this, then make this function static and have it return 
a shared pointer to a DWARFCompileUnit and make the constructor private. 
Commenting isn't enough on its own



Comment at: source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp:294-297
   if (!cu.unique())
 cu.reset(new DWARFCompileUnit(dwarf2Data));
+  else
+cu->Clear();

I don't see this code in top of tree? My DWARFDebugInfo.cpp ends at line 259


https://reviews.llvm.org/D40214



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


[Lldb-commits] [PATCH] D40216: #if 0 for DWARFDebugInfo::Find() as it is unused

2017-11-19 Thread Greg Clayton via Phabricator via lldb-commits
clayborg requested changes to this revision.
clayborg added a comment.
This revision now requires changes to proceed.

Feel free to remove any unused code. No need for review on dead code removal. 
So just remove the code, don't add #if 0


https://reviews.llvm.org/D40216



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


[Lldb-commits] [PATCH] D40212: refactor: Unify+simplify DWARFCompileUnit ctor+Clear() into in-class initializers

2017-11-19 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

In https://reviews.llvm.org/D40212#929716, @clayborg wrote:

> Good change in the header file.


If you mean the in-class initializers they obviously cannot be used without the 
in-place construction+destruction as they would stay duplicate to the Clear() 
method.

OK if you are also uncomfortable with it I will keep Clear() as is and just 
call Clear() from the ctor to unify it at least a bit.


https://reviews.llvm.org/D40212



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


[Lldb-commits] [PATCH] D40212: refactor: Unify+simplify DWARFCompileUnit ctor+Clear() into in-class initializers

2017-11-19 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

In https://reviews.llvm.org/D40212#929740, @jankratochvil wrote:

> In https://reviews.llvm.org/D40212#929716, @clayborg wrote:
>
> > Good change in the header file.
>
>
> If you mean the in-class initializers they obviously cannot be used without 
> the in-place construction+destruction as they would stay duplicate to the 
> Clear() method.
>
> OK if you are also uncomfortable with it I will keep Clear() as is and just 
> call Clear() from the ctor to unify it at least a bit.


Or we can get rid of Clear(), make the constructor private and make 
DWARFCompileInit::Extract be static and return a shared pointer as suggested in 
your other patch. I doubt many compile units fail to construct so we can just 
avoid the Clear() call all together and keep the initialization in the header 
file. Let me know


https://reviews.llvm.org/D40212



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


[Lldb-commits] [PATCH] D40214: performance: Prevent needless DWARFCompileUnit::Clear() on freshly ctor-ed object

2017-11-19 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

Thanks for the review but then it would become a performance regression, not 
the performance improvement I was trying to make.
Withdrawing this patch.




Comment at: source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp:74
lldb::offset_t *offset_ptr) {
-  Clear();
-
+  assert(m_offset == DW_INVALID_OFFSET);
   m_offset = *offset_ptr;

clayborg wrote:
> Make this static as mentioned in above comment. Assertions are ok to detect 
> things in debug build, but please use lldbassert and make sure it returns an 
> empty shared pointer if things fail (code must function properly when assert 
> is not compiled in the program.
In such case each Extract() call will always make a new allocation of 
DWARFCompileUnit instance which is much more performance expensive that the 
double in-place reinitialization this patch was trying to avoid.




Comment at: source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp:294-297
   if (!cu.unique())
 cu.reset(new DWARFCompileUnit(dwarf2Data));
+  else
+cu->Clear();

clayborg wrote:
> I don't see this code in top of tree? My DWARFDebugInfo.cpp ends at line 259
I see it in:
[[ 
https://github.com/llvm-mirror/lldb/blob/master/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp#L295
 ]]
and also in:
[[ 
https://llvm.org/svn/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
 ]]



https://reviews.llvm.org/D40214



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


[Lldb-commits] [lldb] r318631 - Remove 2 unused methods DWARFDebugInfo::Find and their FindCallbackString

2017-11-19 Thread Jan Kratochvil via lldb-commits
Author: jankratochvil
Date: Sun Nov 19 11:04:24 2017
New Revision: 318631

URL: http://llvm.org/viewvc/llvm-project?rev=318631&view=rev
Log:
Remove 2 unused methods DWARFDebugInfo::Find and their FindCallbackString

Differential revision: https://reviews.llvm.org/D40216

Modified:
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp?rev=318631&r1=318630&r2=318631&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp Sun Nov 19 
11:04:24 2017
@@ -507,80 +507,3 @@ void DWARFDebugInfo::Dump(Stream *s, con
   die.Dump(s, recurse_depth);
   }
 }
-
-//--
-// FindCallbackString
-//
-// A callback function for the static DWARFDebugInfo::Parse() function
-// that gets called each time a compile unit header or debug information
-// entry is successfully parsed.
-//
-// This function will find the die_offset of any items whose DW_AT_name
-// matches the given string
-//--
-typedef struct FindCallbackStringInfoTag {
-  const char *name;
-  bool ignore_case;
-  RegularExpression *regex;
-  vector &die_offsets;
-} FindCallbackStringInfo;
-
-static dw_offset_t
-FindCallbackString(SymbolFileDWARF *dwarf2Data, DWARFCompileUnit *cu,
-   DWARFDebugInfoEntry *die, const dw_offset_t next_offset,
-   const uint32_t curr_depth, void *userData) {
-  FindCallbackStringInfo *info = (FindCallbackStringInfo *)userData;
-
-  if (!die)
-return next_offset;
-
-  const char *die_name = die->GetName(dwarf2Data, cu);
-  if (!die_name)
-return next_offset;
-
-  if (info->regex) {
-if (info->regex->Execute(llvm::StringRef(die_name)))
-  info->die_offsets.push_back(die->GetOffset());
-  } else {
-if ((info->ignore_case ? strcasecmp(die_name, info->name)
-   : strcmp(die_name, info->name)) == 0)
-  info->die_offsets.push_back(die->GetOffset());
-  }
-
-  // Just return the current offset to parse the next CU or DIE entry
-  return next_offset;
-}
-
-//--
-// Find
-//
-// Finds all DIE that have a specific DW_AT_name attribute by manually
-// searching through the debug information (not using the
-// .debug_pubnames section). The string must match the entire name
-// and case sensitive searches are an option.
-//--
-bool DWARFDebugInfo::Find(const char *name, bool ignore_case,
-  vector &die_offsets) const {
-  die_offsets.clear();
-  if (name && name[0]) {
-FindCallbackStringInfo info = {name, ignore_case, NULL, die_offsets};
-DWARFDebugInfo::Parse(m_dwarf2Data, FindCallbackString, &info);
-  }
-  return !die_offsets.empty();
-}
-
-//--
-// Find
-//
-// Finds all DIE that have a specific DW_AT_name attribute by manually
-// searching through the debug information (not using the
-// .debug_pubnames section). The string must match the supplied regular
-// expression.
-//--
-bool DWARFDebugInfo::Find(RegularExpression &re,
-  vector &die_offsets) const {
-  die_offsets.clear();
-  FindCallbackStringInfo info = {NULL, false, &re, die_offsets};
-  DWARFDebugInfo::Parse(m_dwarf2Data, FindCallbackString, &info);
-  return !die_offsets.empty();
-}

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h?rev=318631&r1=318630&r2=318631&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h Sun Nov 19 
11:04:24 2017
@@ -50,10 +50,6 @@ public:
   static void Verify(lldb_private::Stream *s, SymbolFileDWARF *dwarf2Data);
   static void Dump(lldb_private::Stream *s, SymbolFileDWARF *dwarf2Data,
const uint32_t die_offset, const uint32_t recurse_depth);
-  bool Find(const char *name, bool ignore_case,
-std::vector &die_offsets) const;
-  bool Find(lldb_private::RegularExpression &re,
-std::vector &die_offsets) const;
 
   enum {
 eDumpFlag_Verbose = (1 << 0),  // Verbose dumping


___
lldb-commits mailing list
lldb-commits@li

[Lldb-commits] [PATCH] D40216: #if 0 for DWARFDebugInfo::Find() as it is unused

2017-11-19 Thread Jan Kratochvil via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL318631: Remove 2 unused methods DWARFDebugInfo::Find and 
their FindCallbackString (authored by jankratochvil).

Changed prior to commit:
  https://reviews.llvm.org/D40216?vs=123479&id=123505#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D40216

Files:
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h


Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
@@ -50,10 +50,6 @@
   static void Verify(lldb_private::Stream *s, SymbolFileDWARF *dwarf2Data);
   static void Dump(lldb_private::Stream *s, SymbolFileDWARF *dwarf2Data,
const uint32_t die_offset, const uint32_t recurse_depth);
-  bool Find(const char *name, bool ignore_case,
-std::vector &die_offsets) const;
-  bool Find(lldb_private::RegularExpression &re,
-std::vector &die_offsets) const;
 
   enum {
 eDumpFlag_Verbose = (1 << 0),  // Verbose dumping
Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
@@ -507,80 +507,3 @@
   die.Dump(s, recurse_depth);
   }
 }
-
-//--
-// FindCallbackString
-//
-// A callback function for the static DWARFDebugInfo::Parse() function
-// that gets called each time a compile unit header or debug information
-// entry is successfully parsed.
-//
-// This function will find the die_offset of any items whose DW_AT_name
-// matches the given string
-//--
-typedef struct FindCallbackStringInfoTag {
-  const char *name;
-  bool ignore_case;
-  RegularExpression *regex;
-  vector &die_offsets;
-} FindCallbackStringInfo;
-
-static dw_offset_t
-FindCallbackString(SymbolFileDWARF *dwarf2Data, DWARFCompileUnit *cu,
-   DWARFDebugInfoEntry *die, const dw_offset_t next_offset,
-   const uint32_t curr_depth, void *userData) {
-  FindCallbackStringInfo *info = (FindCallbackStringInfo *)userData;
-
-  if (!die)
-return next_offset;
-
-  const char *die_name = die->GetName(dwarf2Data, cu);
-  if (!die_name)
-return next_offset;
-
-  if (info->regex) {
-if (info->regex->Execute(llvm::StringRef(die_name)))
-  info->die_offsets.push_back(die->GetOffset());
-  } else {
-if ((info->ignore_case ? strcasecmp(die_name, info->name)
-   : strcmp(die_name, info->name)) == 0)
-  info->die_offsets.push_back(die->GetOffset());
-  }
-
-  // Just return the current offset to parse the next CU or DIE entry
-  return next_offset;
-}
-
-//--
-// Find
-//
-// Finds all DIE that have a specific DW_AT_name attribute by manually
-// searching through the debug information (not using the
-// .debug_pubnames section). The string must match the entire name
-// and case sensitive searches are an option.
-//--
-bool DWARFDebugInfo::Find(const char *name, bool ignore_case,
-  vector &die_offsets) const {
-  die_offsets.clear();
-  if (name && name[0]) {
-FindCallbackStringInfo info = {name, ignore_case, NULL, die_offsets};
-DWARFDebugInfo::Parse(m_dwarf2Data, FindCallbackString, &info);
-  }
-  return !die_offsets.empty();
-}
-
-//--
-// Find
-//
-// Finds all DIE that have a specific DW_AT_name attribute by manually
-// searching through the debug information (not using the
-// .debug_pubnames section). The string must match the supplied regular
-// expression.
-//--
-bool DWARFDebugInfo::Find(RegularExpression &re,
-  vector &die_offsets) const {
-  die_offsets.clear();
-  FindCallbackStringInfo info = {NULL, false, &re, die_offsets};
-  DWARFDebugInfo::Parse(m_dwarf2Data, FindCallbackString, &info);
-  return !die_offsets.empty();
-}


Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
@@ -50,10 +50,6 @@
   static void Verify(lldb_private::Stream *s, SymbolFileDWARF *dwarf2Data);
   static void Dump(lldb_private::Stream *s, SymbolFileDWARF *dwarf2Data,
const ui

Re: [Lldb-commits] [PATCH] D40211: Add comments to DWARFCompileUnit length fields/methods

2017-11-19 Thread Zachary Turner via lldb-commits
On Sun, Nov 19, 2017 at 6:35 AM Jan Kratochvil via Phabricator via
lldb-commits  wrote:

> This revision was automatically updated to reflect the committed changes.
> Closed by commit rL318626: Add comments to DWARFCompileUnit length
> fields/methods (authored by jankratochvil).
>
> Changed prior to commit:
>   https://reviews.llvm.org/D40211?vs=123472&id=123498#toc
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D40211
>
> Files:
>   lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
>
>
> Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
> ===
> --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
> +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
> @@ -41,26 +41,24 @@
>void Clear();
>bool Verify(lldb_private::Stream *s) const;
>void Dump(lldb_private::Stream *s) const;
> +  // Offset of the initial length field.
>dw_offset_t GetOffset() const { return m_offset; }
>lldb::user_id_t GetID() const;
> -  uint32_t Size() const {
> -return m_is_dwarf64 ? 23
> -: 11; /* Size in bytes of the compile unit header
> */
> -  }
> +  // Size in bytes of the initial length + compile unit header.
> +  uint32_t Size() const { return m_is_dwarf64 ? 23 : 11; }
>

This is pretty gross.  Don't we have a structure somewhere that represents
a compile unit header?  That we can just call sizeof on?  Same goes for the
rest of the patch
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] Use the DWARF linkage name when importing C++ methods

2017-11-19 Thread Nelson Elhage via lldb-commits
When importing C++ methods into clang AST nodes from the DWARF symbol
table, preserve the DW_AT_linkage_name and use it as the linker ("asm")
name for the symbol.

Concretely, this enables `expression` to call into names that use the GNU
`abi_tag` extension, and enables lldb to call into code using std::string
or std::list from recent versions of libstdc++. See
https://bugs.llvm.org/show_bug.cgi?id=35310 . It also seems broadly more
robust than relying on the DWARF->clang->codegen pipeline to roundtrip
properly, but I'm not immediately aware of any other cases in which it
makes a difference.

- Nelson
Index: include/lldb/Symbol/ClangASTContext.h
===
--- include/lldb/Symbol/ClangASTContext.h	(revision 318614)
+++ include/lldb/Symbol/ClangASTContext.h	(working copy)
@@ -821,6 +821,7 @@
 
   clang::CXXMethodDecl *
   AddMethodToCXXRecordType(lldb::opaque_compiler_type_t type, const char *name,
+   const char *mangled_name,
const CompilerType &method_type,
lldb::AccessType access, bool is_virtual,
bool is_static, bool is_inline, bool is_explicit,
Index: source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
===
--- source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp	(revision 318614)
+++ source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp	(working copy)
@@ -2165,7 +2165,7 @@
 CXXMethodDecl *method_decl =
 ClangASTContext::GetASTContext(m_ast_context)
 ->AddMethodToCXXRecordType(
-copied_clang_type.GetOpaqueQualType(), "$__lldb_expr",
+copied_clang_type.GetOpaqueQualType(), "$__lldb_expr", NULL,
 method_type, lldb::eAccessPublic, is_virtual, is_static,
 is_inline, is_explicit, is_attr_used, is_artificial);
 
Index: source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp	(revision 318614)
+++ source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp	(working copy)
@@ -220,6 +220,7 @@
   bool is_forward_declaration = false;
   DWARFAttributes attributes;
   const char *type_name_cstr = NULL;
+  const char *mangled_name_cstr = NULL;
   ConstString type_name_const_str;
   Type::ResolveState resolve_state = Type::eResolveStateUnresolved;
   uint64_t byte_size = 0;
@@ -1135,9 +1136,8 @@
 
   case DW_AT_linkage_name:
   case DW_AT_MIPS_linkage_name:
-break; // mangled =
-   // form_value.AsCString(&dwarf->get_debug_str_data());
-   // break;
+mangled_name_cstr = form_value.AsCString();
+break;
   case DW_AT_type:
 type_die_form = form_value;
 break;
@@ -1498,9 +1498,10 @@
   clang::CXXMethodDecl *cxx_method_decl =
   m_ast.AddMethodToCXXRecordType(
   class_opaque_type.GetOpaqueQualType(),
-  type_name_cstr, clang_type, accessibility,
-  is_virtual, is_static, is_inline, is_explicit,
-  is_attr_used, is_artificial);
+  type_name_cstr, mangled_name_cstr, clang_type,
+  accessibility, is_virtual, is_static,
+  is_inline, is_explicit, is_attr_used,
+  is_artificial);
 
   type_handled = cxx_method_decl != NULL;
 
Index: source/Symbol/ClangASTContext.cpp
===
--- source/Symbol/ClangASTContext.cpp	(revision 318614)
+++ source/Symbol/ClangASTContext.cpp	(working copy)
@@ -7960,7 +7960,7 @@
 }
 
 clang::CXXMethodDecl *ClangASTContext::AddMethodToCXXRecordType(
-lldb::opaque_compiler_type_t type, const char *name,
+lldb::opaque_compiler_type_t type, const char *name, const char *mangled_name,
 const CompilerType &method_clang_type, lldb::AccessType access,
 bool is_virtual, bool is_static, bool is_inline, bool is_explicit,
 bool is_attr_used, bool is_artificial) {
@@ -8080,6 +8080,11 @@
   if (is_attr_used)
 cxx_method_decl->addAttr(clang::UsedAttr::CreateImplicit(*getASTContext()));
 
+  if (mangled_name != NULL) {
+cxx_method_decl->addAttr(
+clang::AsmLabelAttr::CreateImplicit(*getASTContext(), mangled_name));
+  }
+
   // Populate the method decl with parameter decls
 
   llvm::SmallVector params;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo