[Lldb-commits] [PATCH] D51578: Contiguous .debug_info+.debug_types for D32167

2018-12-15 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 178353.
jankratochvil added a comment.

Updated against trunk due to new `getSectionType` from rL348936 
.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D51578

Files:
  include/lldb/lldb-enumerations.h
  source/Core/Section.cpp
  source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
  source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
  source/Symbol/ObjectFile.cpp

Index: source/Symbol/ObjectFile.cpp
===
--- source/Symbol/ObjectFile.cpp
+++ source/Symbol/ObjectFile.cpp
@@ -368,6 +368,7 @@
   case eSectionTypeDWARFDebugStrOffsets:
   case eSectionTypeDWARFDebugStrOffsetsDwo:
   case eSectionTypeDWARFDebugTypes:
+  case eSectionTypeDWARFDebugTypesDwo:
   case eSectionTypeDWARFAppleNames:
   case eSectionTypeDWARFAppleTypes:
   case eSectionTypeDWARFAppleNamespaces:
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
@@ -48,9 +48,10 @@
 
   const lldb_private::DWARFDataExtractor &get_debug_abbrev_data() override;
   const lldb_private::DWARFDataExtractor &get_debug_addr_data() override;
-  const lldb_private::DWARFDataExtractor &get_debug_info_data() override;
+  const lldb_private::DWARFDataExtractor &get_raw_debug_info_data() override;
   const lldb_private::DWARFDataExtractor &get_debug_str_data() override;
   const lldb_private::DWARFDataExtractor &get_debug_str_offsets_data() override;
+  const lldb_private::DWARFDataExtractor &get_raw_debug_types_data() override;
 
 protected:
   void LoadSectionData(lldb::SectionType sect_type,
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
@@ -136,8 +136,9 @@
   return m_data_debug_addr.m_data;
 }
 
-const DWARFDataExtractor &SymbolFileDWARFDwo::get_debug_info_data() {
-  return GetCachedSectionData(eSectionTypeDWARFDebugInfoDwo, m_data_debug_info);
+const DWARFDataExtractor &SymbolFileDWARFDwo::get_raw_debug_info_data() {
+  return GetCachedSectionData(eSectionTypeDWARFDebugInfoDwo,
+  m_data_raw_debug_info);
 }
 
 const DWARFDataExtractor &SymbolFileDWARFDwo::get_debug_str_data() {
@@ -149,6 +150,11 @@
   m_data_debug_str_offsets);
 }
 
+const DWARFDataExtractor &SymbolFileDWARFDwo::get_raw_debug_types_data() {
+  return GetCachedSectionData(eSectionTypeDWARFDebugTypesDwo,
+  m_data_raw_debug_types);
+}
+
 SymbolFileDWARF *SymbolFileDWARFDwo::GetBaseSymbolFile() {
   return m_base_dwarf_cu->GetSymbolFileDWARF();
 }
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -237,7 +237,8 @@
   virtual const lldb_private::DWARFDataExtractor &get_debug_addr_data();
   const lldb_private::DWARFDataExtractor &get_debug_aranges_data();
   const lldb_private::DWARFDataExtractor &get_debug_frame_data();
-  virtual const lldb_private::DWARFDataExtractor &get_debug_info_data();
+  const lldb_private::DWARFDataExtractor &get_debug_info_data();
+  virtual const lldb_private::DWARFDataExtractor &get_raw_debug_info_data();
   const lldb_private::DWARFDataExtractor &get_debug_line_data();
   const lldb_private::DWARFDataExtractor &get_debug_line_str_data();
   const lldb_private::DWARFDataExtractor &get_debug_macro_data();
@@ -247,7 +248,7 @@
   const lldb_private::DWARFDataExtractor &get_debug_rnglists_data();
   virtual const lldb_private::DWARFDataExtractor &get_debug_str_data();
   virtual const lldb_private::DWARFDataExtractor &get_debug_str_offsets_data();
-  const lldb_private::DWARFDataExtractor &get_debug_types_data();
+  virtual const lldb_private::DWARFDataExtractor &get_raw_debug_types_data();
   const lldb_private::DWARFDataExtractor &get_apple_names_data();
   const lldb_private::DWARFDataExtractor &get_apple_types_data();
   const lldb_private::DWARFDataExtractor &get_apple_namespaces_data();
@@ -3

[Lldb-commits] [PATCH] D55727: Add "dump" command as a custom "process plugin" subcommand when ProcessMinidump is used.

2018-12-15 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

+1 for tests. Other than that, the code seems fairly straight-forward, though 
it could be brought closer to llvm style (e.g., by using more StringRefs in 
favour of raw c strings).




Comment at: source/Plugins/Process/minidump/MinidumpParser.cpp:709-714
+void MinidumpParser::ForEachStreamType(Callback const &callback) const {
+  for (auto const &pair: m_directory_map) {
+if (!callback(pair.first, pair.second))
+  break;
+  }
+}

Why not just have an accessor which returns (a const reference to) the list of 
streams. Then the users can iterate over this any way they see fit (and 
range-based loops are easier to read than lambda callbacks).



Comment at: source/Plugins/Process/minidump/MinidumpParser.h:93
 
+  static const char *GetStreamTypeAsString(uint32_t stream_type);
+

Return llvm::StringRef here.



Comment at: source/Plugins/Process/minidump/MinidumpParser.h:96-99
+ const MinidumpLocationDescriptor &loc_desc)>
+  Callback;
+
+  void ForEachStreamType(Callback const &callback) const;

inconsistent spelling of const references (`const T &` vs `T const &`). I think 
the first version is more prevalent in both lldb and llvm.



Comment at: source/Plugins/Process/minidump/ProcessMinidump.cpp:561
+ProcessMinidump *process =
+(ProcessMinidump *)m_interpreter.GetExecutionContext().GetProcessPtr();
+result.SetStatus(eReturnStatusSuccessFinishResult);

static_cast


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

https://reviews.llvm.org/D55727



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


[Lldb-commits] [PATCH] D55736: build.py: inherit environment in the gcc builder

2018-12-15 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added reviewers: stella.stamenova, zturner.

This should enable the compiler to find the system linker for the link
step.


https://reviews.llvm.org/D55736

Files:
  lit/helper/build.py


Index: lit/helper/build.py
===
--- lit/helper/build.py
+++ lit/helper/build.py
@@ -153,6 +153,9 @@
 return result
 
 def print_environment(env):
+if env is None:
+print('Inherited')
+return
 for e in env:
 value = env[e]
 lines = value.split(os.pathsep)
@@ -633,7 +636,7 @@
 args.extend(['-o', obj])
 args.append(source)
 
-return ('compiling', [source], obj, {}, args)
+return ('compiling', [source], obj, None, args)
 
 def _get_link_command(self):
 args = []
@@ -649,7 +652,7 @@
 args.extend(['-o', self._exe_file_name()])
 args.extend(self._obj_file_names())
 
-return ('linking', self._obj_file_names(), self._exe_file_name(), {}, 
args)
+return ('linking', self._obj_file_names(), self._exe_file_name(), 
None, args)
 
 
 def output_files(self):


Index: lit/helper/build.py
===
--- lit/helper/build.py
+++ lit/helper/build.py
@@ -153,6 +153,9 @@
 return result
 
 def print_environment(env):
+if env is None:
+print('Inherited')
+return
 for e in env:
 value = env[e]
 lines = value.split(os.pathsep)
@@ -633,7 +636,7 @@
 args.extend(['-o', obj])
 args.append(source)
 
-return ('compiling', [source], obj, {}, args)
+return ('compiling', [source], obj, None, args)
 
 def _get_link_command(self):
 args = []
@@ -649,7 +652,7 @@
 args.extend(['-o', self._exe_file_name()])
 args.extend(self._obj_file_names())
 
-return ('linking', self._obj_file_names(), self._exe_file_name(), {}, args)
+return ('linking', self._obj_file_names(), self._exe_file_name(), None, args)
 
 
 def output_files(self):
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D55736: build.py: inherit environment in the gcc builder

2018-12-15 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Stella, could you please try whether this solves the problem you reported in 
D55430 ? I think this should do the trick, but 
I can't be sure because (for whatever reason), things seem to work for me even 
without this patch.


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

https://reviews.llvm.org/D55736



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


[Lldb-commits] [lldb] r349267 - Remove /proc/pid/maps parsing code from NativeProcessLinux

2018-12-15 Thread Pavel Labath via lldb-commits
Author: labath
Date: Sat Dec 15 05:38:16 2018
New Revision: 349267

URL: http://llvm.org/viewvc/llvm-project?rev=349267&view=rev
Log:
Remove /proc/pid/maps parsing code from NativeProcessLinux

A utility function doing this was added in r349182, so use that instead.

Modified:
lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp

Modified: lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp?rev=349267&r1=349266&r2=349267&view=diff
==
--- lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp Sat Dec 15 
05:38:16 2018
@@ -45,6 +45,7 @@
 
 #include "NativeThreadLinux.h"
 #include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
+#include "Plugins/Process/Utility/LinuxProcMaps.h"
 #include "Procfs.h"
 
 #include 
@@ -1232,90 +1233,6 @@ Status NativeProcessLinux::Kill() {
   return error;
 }
 
-static Status
-ParseMemoryRegionInfoFromProcMapsLine(llvm::StringRef &maps_line,
-  MemoryRegionInfo &memory_region_info) {
-  memory_region_info.Clear();
-
-  StringExtractor line_extractor(maps_line);
-
-  // Format: {address_start_hex}-{address_end_hex} perms offset  dev   inode
-  // pathname perms: rwxp   (letter is present if set, '-' if not, final
-  // character is p=private, s=shared).
-
-  // Parse out the starting address
-  lldb::addr_t start_address = line_extractor.GetHexMaxU64(false, 0);
-
-  // Parse out hyphen separating start and end address from range.
-  if (!line_extractor.GetBytesLeft() || (line_extractor.GetChar() != '-'))
-return Status(
-"malformed /proc/{pid}/maps entry, missing dash between address 
range");
-
-  // Parse out the ending address
-  lldb::addr_t end_address = line_extractor.GetHexMaxU64(false, start_address);
-
-  // Parse out the space after the address.
-  if (!line_extractor.GetBytesLeft() || (line_extractor.GetChar() != ' '))
-return Status(
-"malformed /proc/{pid}/maps entry, missing space after range");
-
-  // Save the range.
-  memory_region_info.GetRange().SetRangeBase(start_address);
-  memory_region_info.GetRange().SetRangeEnd(end_address);
-
-  // Any memory region in /proc/{pid}/maps is by definition mapped into the
-  // process.
-  memory_region_info.SetMapped(MemoryRegionInfo::OptionalBool::eYes);
-
-  // Parse out each permission entry.
-  if (line_extractor.GetBytesLeft() < 4)
-return Status("malformed /proc/{pid}/maps entry, missing some portion of "
-  "permissions");
-
-  // Handle read permission.
-  const char read_perm_char = line_extractor.GetChar();
-  if (read_perm_char == 'r')
-memory_region_info.SetReadable(MemoryRegionInfo::OptionalBool::eYes);
-  else if (read_perm_char == '-')
-memory_region_info.SetReadable(MemoryRegionInfo::OptionalBool::eNo);
-  else
-return Status("unexpected /proc/{pid}/maps read permission char");
-
-  // Handle write permission.
-  const char write_perm_char = line_extractor.GetChar();
-  if (write_perm_char == 'w')
-memory_region_info.SetWritable(MemoryRegionInfo::OptionalBool::eYes);
-  else if (write_perm_char == '-')
-memory_region_info.SetWritable(MemoryRegionInfo::OptionalBool::eNo);
-  else
-return Status("unexpected /proc/{pid}/maps write permission char");
-
-  // Handle execute permission.
-  const char exec_perm_char = line_extractor.GetChar();
-  if (exec_perm_char == 'x')
-memory_region_info.SetExecutable(MemoryRegionInfo::OptionalBool::eYes);
-  else if (exec_perm_char == '-')
-memory_region_info.SetExecutable(MemoryRegionInfo::OptionalBool::eNo);
-  else
-return Status("unexpected /proc/{pid}/maps exec permission char");
-
-  line_extractor.GetChar();  // Read the private bit
-  line_extractor.SkipSpaces();   // Skip the separator
-  line_extractor.GetHexMaxU64(false, 0); // Read the offset
-  line_extractor.GetHexMaxU64(false, 0); // Read the major device number
-  line_extractor.GetChar();  // Read the device id separator
-  line_extractor.GetHexMaxU64(false, 0); // Read the major device number
-  line_extractor.SkipSpaces();   // Skip the separator
-  line_extractor.GetU64(0, 10);  // Read the inode number
-
-  line_extractor.SkipSpaces();
-  const char *name = line_extractor.Peek();
-  if (name)
-memory_region_info.SetName(name);
-
-  return Status();
-}
-
 Status NativeProcessLinux::GetMemoryRegionInfo(lldb::addr_t load_addr,
MemoryRegionInfo &range_info) {
   // FIXME review that the final memory region returned extends to the end of
@@ -1401,23 +1318,23 @@ Status NativeProcessLinux::PopulateMemor
 m_supports_mem_region = LazyBool::eLazyBoolNo;
 return BufferOrError.getError();
   }
-  StringRef Rest = B

[Lldb-commits] [PATCH] D55706: ELF: more section creation cleanup

2018-12-15 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Kamil, Joerg: most of this is fairly lldb-specific and boring. I just added you 
for the .symtab thingy, just in case you know of anyone using SHT_SYMTAB 
sections which are not called .symtab (or conversely, using the name .symtab 
for non-symbol-table-related things).


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

https://reviews.llvm.org/D55706



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


[Lldb-commits] [lldb] r349268 - ELF: more section creation cleanup

2018-12-15 Thread Pavel Labath via lldb-commits
Author: labath
Date: Sat Dec 15 05:45:38 2018
New Revision: 349268

URL: http://llvm.org/viewvc/llvm-project?rev=349268&view=rev
Log:
ELF: more section creation cleanup

Summary:
This patch attempts to move as much code as possible out of the
CreateSections function to make room for future improvements there. Some
of this may be slightly over-engineered (VMAddressProvider), but I
wanted to keep the logic of this function very simple, because once I
start taking segment headers into acount (as discussed in D55356), the
function is going to grow significantly.

While in there, I also added tests for various bits of functionality.

This should be NFC, except that I changed the order of hac^H^Heuristicks
for determining section type slightly. Previously, name-based deduction
(.symtab -> symtab) would take precedence over type-based (SHT_SYMTAB ->
symtab) one. In fact we would assert if we ran into a .text section with
type SHT_SYMTAB. Though unlikely to matter in practice, this order
seemed wrong to me, so I have inverted it.

Reviewers: clayborg, krytarowski, espindola

Subscribers: emaste, arichardson, lldb-commits

Differential Revision: https://reviews.llvm.org/D55706

Added:
lldb/trunk/lit/Modules/ELF/section-addresses.yaml
lldb/trunk/lit/Modules/ELF/section-permissions.yaml
lldb/trunk/lit/Modules/ELF/section-types-edgecases.yaml
Modified:
lldb/trunk/lit/Modules/ELF/compressed-sections.yaml
lldb/trunk/lit/Modules/ELF/section-types.yaml
lldb/trunk/lit/Modules/MachO/subsections.yaml
lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
lldb/trunk/tools/lldb-test/lldb-test.cpp

Modified: lldb/trunk/lit/Modules/ELF/compressed-sections.yaml
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/ELF/compressed-sections.yaml?rev=349268&r1=349267&r2=349268&view=diff
==
--- lldb/trunk/lit/Modules/ELF/compressed-sections.yaml (original)
+++ lldb/trunk/lit/Modules/ELF/compressed-sections.yaml Sat Dec 15 05:45:38 2018
@@ -19,15 +19,13 @@ Sections:
 
 # CHECK: Name: .hello_elf
 # CHECK-NEXT: Type: regular
-# CHECK-NEXT: Thread specific: no
-# CHECK-NEXT: VM size: 0
+# CHECK: VM size: 0
 # CHECK-NEXT: File size: 28
 # CHECK-NEXT: Data:
 # CHECK-NEXT: 20304050 60708090
 
 # CHECK: Name: .bogus
 # CHECK-NEXT: Type: regular
-# CHECK-NEXT: Thread specific: no
-# CHECK-NEXT: VM size: 0
+# CHECK: VM size: 0
 # CHECK-NEXT: File size: 8
 # CHECK-NEXT: Data: ()

Added: lldb/trunk/lit/Modules/ELF/section-addresses.yaml
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/ELF/section-addresses.yaml?rev=349268&view=auto
==
--- lldb/trunk/lit/Modules/ELF/section-addresses.yaml (added)
+++ lldb/trunk/lit/Modules/ELF/section-addresses.yaml Sat Dec 15 05:45:38 2018
@@ -0,0 +1,58 @@
+# RUN: yaml2obj %s > %t
+# RUN: lldb-test object-file %t | FileCheck %s
+
+# CHECK-LABEL: Name: .one
+# CHECK: VM address: 0x0
+
+# CHECK-LABEL: Name: .nonalloc
+# CHECK: VM address: 0x0
+
+# CHECK-LABEL: Name: .two
+# CHECK: VM address: 0x8
+
+# CHECK-LABEL: Name: .three
+# CHECK: VM address: 0xc
+
+# CHECK-LABEL: Name: .four
+# CHECK: VM address: 0xc
+
+# CHECK-LABEL: Name: .five
+# CHECK: VM address: 0x1000
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_REL
+  Machine: EM_X86_64
+  Entry:   0x07A0
+Sections:
+  - Name:.one
+Type:SHT_PROGBITS
+Flags:   [ SHF_ALLOC ]
+AddressAlign:0x0004
+Content: DEADBEEFBAADF00D
+  - Name:.nonalloc
+Type:SHT_PROGBITS
+AddressAlign:0x0004
+Content: DEADBEEFBAADF00D
+  - Name:.two
+Type:SHT_PROGBITS
+Flags:   [ SHF_ALLOC ]
+AddressAlign:0x0004
+Content: DE
+  - Name:.three
+Type:SHT_PROGBITS
+Flags:   [ SHF_ALLOC ]
+AddressAlign:0x0004
+  - Name:.four
+Type:SHT_PROGBITS
+Flags:   [ SHF_ALLOC ]
+AddressAlign:0x0004
+Content: DEADBEEFBAADF00D
+  - Name:.five
+Type:SHT_PROGBITS
+Flags:   [ SHF_ALLOC ]
+AddressAlign:0x1000
+Content: DEADBEEFBAADF00D
+...

Added: lldb/trunk/lit/Modules/ELF/section-permissions.yaml
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/ELF/section-permissions.yaml?rev=349268&view=auto
==
--- lldb/trunk/lit/Modules/ELF/section-permissions.yaml (added)
+++ lldb/trunk/lit/Modules/ELF/section-permissions.yaml Sat Dec 15 05:45:38 2018
@@ -0,0 +1,34 @@
+# RUN

[Lldb-commits] [PATCH] D55706: ELF: more section creation cleanup

2018-12-15 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB349268: ELF: more section creation cleanup (authored by 
labath, committed by ).
Herald added a subscriber: abidh.

Changed prior to commit:
  https://reviews.llvm.org/D55706?vs=178231&id=178360#toc

Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D55706

Files:
  lit/Modules/ELF/compressed-sections.yaml
  lit/Modules/ELF/section-addresses.yaml
  lit/Modules/ELF/section-permissions.yaml
  lit/Modules/ELF/section-types-edgecases.yaml
  lit/Modules/ELF/section-types.yaml
  lit/Modules/MachO/subsections.yaml
  source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  source/Plugins/ObjectFile/ELF/ObjectFileELF.h
  tools/lldb-test/lldb-test.cpp

Index: source/Plugins/ObjectFile/ELF/ObjectFileELF.h
===
--- source/Plugins/ObjectFile/ELF/ObjectFileELF.h
+++ source/Plugins/ObjectFile/ELF/ObjectFileELF.h
@@ -246,6 +246,8 @@
   /// Returns the number of headers parsed.
   size_t ParseSectionHeaders();
 
+  lldb::SectionType GetSectionType(const ELFSectionHeaderInfo &H) const;
+
   static void ParseARMAttributes(lldb_private::DataExtractor &data,
  uint64_t length,
  lldb_private::ArchSpec &arch_spec);
Index: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -1735,7 +1735,7 @@
   return 0;
 }
 
-static SectionType getSectionType(llvm::StringRef Name) {
+static SectionType GetSectionTypeFromName(llvm::StringRef Name) {
   return llvm::StringSwitch(Name)
   .Case(".ARM.exidx", eSectionTypeARMexidx)
   .Case(".ARM.extab", eSectionTypeARMextab)
@@ -1774,16 +1774,85 @@
   .Default(eSectionTypeOther);
 }
 
+SectionType ObjectFileELF::GetSectionType(const ELFSectionHeaderInfo &H) const {
+  switch (H.sh_type) {
+  case SHT_PROGBITS:
+if (H.sh_flags & SHF_EXECINSTR)
+  return eSectionTypeCode;
+break;
+  case SHT_SYMTAB:
+return eSectionTypeELFSymbolTable;
+  case SHT_DYNSYM:
+return eSectionTypeELFDynamicSymbols;
+  case SHT_RELA:
+  case SHT_REL:
+return eSectionTypeELFRelocationEntries;
+  case SHT_DYNAMIC:
+return eSectionTypeELFDynamicLinkInfo;
+  }
+  SectionType Type = GetSectionTypeFromName(H.section_name.GetStringRef());
+  if (Type == eSectionTypeOther) {
+// the kalimba toolchain assumes that ELF section names are free-form.
+// It does support linkscripts which (can) give rise to various
+// arbitrarily named sections being "Code" or "Data".
+Type = kalimbaSectionType(m_header, H);
+  }
+  return Type;
+}
+
+static uint32_t GetTargetByteSize(SectionType Type, const ArchSpec &arch) {
+  switch (Type) {
+  case eSectionTypeData:
+  case eSectionTypeZeroFill:
+return arch.GetDataByteSize();
+  case eSectionTypeCode:
+return arch.GetCodeByteSize();
+  default:
+return 1;
+  }
+}
+
+static Permissions GetPermissions(const ELFSectionHeader &H) {
+  Permissions Perm = Permissions(0);
+  if (H.sh_flags & SHF_ALLOC)
+Perm |= ePermissionsReadable;
+  if (H.sh_flags & SHF_WRITE)
+Perm |= ePermissionsWritable;
+  if (H.sh_flags & SHF_EXECINSTR)
+Perm |= ePermissionsExecutable;
+  return Perm;
+}
+
+namespace {
+// (Unlinked) ELF object files usually have 0 for every section address, meaning
+// we need to compute synthetic addresses in order for "file addresses" from
+// different sections to not overlap. This class handles that logic.
+class VMAddressProvider {
+  bool m_synthesizing;
+  addr_t m_next;
+
+public:
+  VMAddressProvider(ObjectFile::Type Type)
+  : m_synthesizing(Type == ObjectFile::Type::eTypeObjectFile), m_next(0) {}
+
+  std::pair GetAddressAndSize(const ELFSectionHeader &H) {
+addr_t address = H.sh_addr;
+addr_t size = H.sh_flags & SHF_ALLOC ? H.sh_size : 0;
+if (m_synthesizing && (H.sh_flags & SHF_ALLOC)) {
+  m_next = llvm::alignTo(m_next, std::max(H.sh_addralign, 1));
+  address = m_next;
+  m_next += size;
+}
+return {address, size};
+  }
+};
+}
+
 void ObjectFileELF::CreateSections(SectionList &unified_section_list) {
   if (!m_sections_ap.get() && ParseSectionHeaders()) {
 m_sections_ap.reset(new SectionList());
 
-// Object files frequently have 0 for every section address, meaning we
-// need to compute synthetic addresses in order for "file addresses" from
-// different sections to not overlap
-bool synthaddrs = (CalculateType() == ObjectFile::Type::eTypeObjectFile);
-uint64_t nextaddr = 0;
-
+VMAddressProvider address_provider(CalculateType());
 for (SectionHeaderCollIter I = m_section_headers.begin();
  I != m_section_headers.end(); ++I) {
   const ELFSectionHeaderInfo &header = *I;
@@ -179

[Lldb-commits] [PATCH] D55597: lldb-test: Improve newline handling

2018-12-15 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB349269: lldb-test: Improve newline handling (authored by 
labath, committed by ).
Herald added a subscriber: abidh.

Changed prior to commit:
  https://reviews.llvm.org/D55597?vs=177841&id=178362#toc

Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D55597

Files:
  lit/Modules/MachO/subsections.yaml
  tools/lldb-test/FormatUtil.cpp
  tools/lldb-test/FormatUtil.h

Index: tools/lldb-test/FormatUtil.h
===
--- tools/lldb-test/FormatUtil.h
+++ tools/lldb-test/FormatUtil.h
@@ -26,27 +26,36 @@
   int CurrentIndent;
 
 public:
+  class Line {
+LinePrinter *P;
+
+  public:
+Line(LinePrinter &P) : P(&P) { P.OS.indent(P.CurrentIndent); }
+~Line();
+
+Line(Line &&RHS) : P(RHS.P) { RHS.P = nullptr; }
+void operator=(Line &&) = delete;
+
+operator llvm::raw_ostream &() { return P->OS; }
+  };
+
   LinePrinter(int Indent, llvm::raw_ostream &Stream);
 
   void Indent(uint32_t Amount = 0);
   void Unindent(uint32_t Amount = 0);
   void NewLine();
 
-  void printLine(const llvm::Twine &T);
-  void print(const llvm::Twine &T);
+  void printLine(const llvm::Twine &T) { line() << T; }
   template  void formatLine(const char *Fmt, Ts &&... Items) {
 printLine(llvm::formatv(Fmt, std::forward(Items)...));
   }
-  template  void format(const char *Fmt, Ts &&... Items) {
-print(llvm::formatv(Fmt, std::forward(Items)...));
-  }
 
   void formatBinary(llvm::StringRef Label, llvm::ArrayRef Data,
 uint32_t StartOffset);
   void formatBinary(llvm::StringRef Label, llvm::ArrayRef Data,
 uint64_t BaseAddr, uint32_t StartOffset);
 
-  llvm::raw_ostream &getStream() { return OS; }
+  Line line() { return Line(*this); }
   int getIndentLevel() const { return CurrentIndent; }
 };
 
@@ -64,12 +73,6 @@
   uint32_t Amount = 0;
 };
 
-template 
-inline llvm::raw_ostream &operator<<(LinePrinter &Printer, const T &Item) {
-  Printer.getStream() << Item;
-  return Printer.getStream();
-}
-
 } // namespace lldb_private
 
 #endif
Index: tools/lldb-test/FormatUtil.cpp
===
--- tools/lldb-test/FormatUtil.cpp
+++ tools/lldb-test/FormatUtil.cpp
@@ -14,6 +14,11 @@
 using namespace lldb_private;
 using namespace llvm;
 
+LinePrinter::Line::~Line() {
+  if (P)
+P->NewLine();
+}
+
 LinePrinter::LinePrinter(int Indent, llvm::raw_ostream &Stream)
 : OS(Stream), IndentSpaces(Indent), CurrentIndent(0) {}
 
@@ -31,39 +36,31 @@
 
 void LinePrinter::NewLine() {
   OS << "\n";
-  OS.indent(CurrentIndent);
-}
-
-void LinePrinter::print(const Twine &T) { OS << T; }
-
-void LinePrinter::printLine(const Twine &T) {
-  NewLine();
-  OS << T;
 }
 
 void LinePrinter::formatBinary(StringRef Label, ArrayRef Data,
uint32_t StartOffset) {
-  NewLine();
-  OS << Label << " (";
-  if (!Data.empty()) {
-OS << "\n";
-OS << format_bytes_with_ascii(Data, StartOffset, 32, 4,
-  CurrentIndent + IndentSpaces, true);
-NewLine();
+  if (Data.empty()) {
+line() << Label << " ()";
+return;
   }
-  OS << ")";
+  line() << Label << " (";
+  OS << format_bytes_with_ascii(Data, StartOffset, 32, 4,
+CurrentIndent + IndentSpaces, true);
+  NewLine();
+  line() << ")";
 }
 
 void LinePrinter::formatBinary(StringRef Label, ArrayRef Data,
uint64_t Base, uint32_t StartOffset) {
-  NewLine();
-  OS << Label << " (";
-  if (!Data.empty()) {
-OS << "\n";
-Base += StartOffset;
-OS << format_bytes_with_ascii(Data, Base, 32, 4,
-  CurrentIndent + IndentSpaces, true);
-NewLine();
+  if (Data.empty()) {
+line() << Label << " ()";
+return;
   }
-  OS << ")";
+  line() << Label << " (";
+  Base += StartOffset;
+  OS << format_bytes_with_ascii(Data, Base, 32, 4, CurrentIndent + IndentSpaces,
+true);
+  NewLine();
+  line() << ")";
 }
Index: lit/Modules/MachO/subsections.yaml
===
--- lit/Modules/MachO/subsections.yaml
+++ lit/Modules/MachO/subsections.yaml
@@ -11,8 +11,8 @@
 #CHECK-NEXT:  VM size: 4294967296
 #CHECK-NEXT:  File size: 0
 #CHECK-NEXT:  There are no subsections
-#
-#CHECK:   Index: 1
+#CHECK-EMPTY:
+#CHECK-NEXT:  Index: 1
 #CHECK-NEXT:  Name: __TEXT
 #CHECK-NEXT:  Type: container
 #CHECK-NEXT:  Permissions: r-x
@@ -29,8 +29,8 @@
 #CHECK-NEXT:VM address: 0x10f30
 #CHECK-NEXT:VM size: 22
 #CHECK-NEXT:File size: 22
-#
-#CHECK: Index: 1
+#CHECK-EMPTY:
+#CHECK-NEXT:Index: 1
 #CHECK-NEXT:Name: __unwind_info
 #CHECK-NEXT:Type: compact-unwind
 #CHECK-NEXT:Permissions: r-x
@@ -38,8 +38,8 @@
 #CHECK-NEXT: 

[Lldb-commits] [lldb] r349269 - lldb-test: Improve newline handling

2018-12-15 Thread Pavel Labath via lldb-commits
Author: labath
Date: Sat Dec 15 05:49:25 2018
New Revision: 349269

URL: http://llvm.org/viewvc/llvm-project?rev=349269&view=rev
Log:
lldb-test: Improve newline handling

Summary:
Previously lldb-test's LinePrinter would output the indentation spaces
even on completely empty lines. This is not nice, as trailing spaces get
flagged as errors in some tools/editors, and it prevents FileCheck's
CHECK-EMPTY from working.

Equally annoying was the fact that the LinePrinter did not terminate
it's output with a newline (instead it would leave the unterminated hanging
indent from the last NewLine() command), which meant that the shell prompt
following the lldb-test command came out wrong.

This fixes both issues by changing how newlines are handled. NewLine(),
which was ending the previous line ('\n') *and* begging the next line by
printing the indent, is now "demoted" to just printing literal "\n".
Instead, lines are now delimited via a helper Line object, which makes
sure the line is indented and terminated in an RAII fashion. The typical
usage would be:
Printer.line() << "This text will be indented and terminated";
If one needs to do more work than it will fit into a single statement,
one can also assign the result of the line() function to a local
variable. The line will then be terminated when that object goes out of
scope.

Reviewers: zturner

Subscribers: lldb-commits

Differential Revision: https://reviews.llvm.org/D55597

Modified:
lldb/trunk/lit/Modules/MachO/subsections.yaml
lldb/trunk/tools/lldb-test/FormatUtil.cpp
lldb/trunk/tools/lldb-test/FormatUtil.h

Modified: lldb/trunk/lit/Modules/MachO/subsections.yaml
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/MachO/subsections.yaml?rev=349269&r1=349268&r2=349269&view=diff
==
--- lldb/trunk/lit/Modules/MachO/subsections.yaml (original)
+++ lldb/trunk/lit/Modules/MachO/subsections.yaml Sat Dec 15 05:49:25 2018
@@ -11,8 +11,8 @@
 #CHECK-NEXT:  VM size: 4294967296
 #CHECK-NEXT:  File size: 0
 #CHECK-NEXT:  There are no subsections
-#
-#CHECK:   Index: 1
+#CHECK-EMPTY:
+#CHECK-NEXT:  Index: 1
 #CHECK-NEXT:  Name: __TEXT
 #CHECK-NEXT:  Type: container
 #CHECK-NEXT:  Permissions: r-x
@@ -29,8 +29,8 @@
 #CHECK-NEXT:VM address: 0x10f30
 #CHECK-NEXT:VM size: 22
 #CHECK-NEXT:File size: 22
-#
-#CHECK: Index: 1
+#CHECK-EMPTY:
+#CHECK-NEXT:Index: 1
 #CHECK-NEXT:Name: __unwind_info
 #CHECK-NEXT:Type: compact-unwind
 #CHECK-NEXT:Permissions: r-x
@@ -38,8 +38,8 @@
 #CHECK-NEXT:VM address: 0x10f48
 #CHECK-NEXT:VM size: 76
 #CHECK-NEXT:File size: 76
-#
-#CHECK: Index: 2
+#CHECK-EMPTY:
+#CHECK-NEXT:Index: 2
 #CHECK-NEXT:Name: __eh_frame
 #CHECK-NEXT:Type: eh-frame
 #CHECK-NEXT:Permissions: r-x

Modified: lldb/trunk/tools/lldb-test/FormatUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-test/FormatUtil.cpp?rev=349269&r1=349268&r2=349269&view=diff
==
--- lldb/trunk/tools/lldb-test/FormatUtil.cpp (original)
+++ lldb/trunk/tools/lldb-test/FormatUtil.cpp Sat Dec 15 05:49:25 2018
@@ -14,6 +14,11 @@
 using namespace lldb_private;
 using namespace llvm;
 
+LinePrinter::Line::~Line() {
+  if (P)
+P->NewLine();
+}
+
 LinePrinter::LinePrinter(int Indent, llvm::raw_ostream &Stream)
 : OS(Stream), IndentSpaces(Indent), CurrentIndent(0) {}
 
@@ -31,39 +36,31 @@ void LinePrinter::Unindent(uint32_t Amou
 
 void LinePrinter::NewLine() {
   OS << "\n";
-  OS.indent(CurrentIndent);
-}
-
-void LinePrinter::print(const Twine &T) { OS << T; }
-
-void LinePrinter::printLine(const Twine &T) {
-  NewLine();
-  OS << T;
 }
 
 void LinePrinter::formatBinary(StringRef Label, ArrayRef Data,
uint32_t StartOffset) {
-  NewLine();
-  OS << Label << " (";
-  if (!Data.empty()) {
-OS << "\n";
-OS << format_bytes_with_ascii(Data, StartOffset, 32, 4,
-  CurrentIndent + IndentSpaces, true);
-NewLine();
+  if (Data.empty()) {
+line() << Label << " ()";
+return;
   }
-  OS << ")";
+  line() << Label << " (";
+  OS << format_bytes_with_ascii(Data, StartOffset, 32, 4,
+CurrentIndent + IndentSpaces, true);
+  NewLine();
+  line() << ")";
 }
 
 void LinePrinter::formatBinary(StringRef Label, ArrayRef Data,
uint64_t Base, uint32_t StartOffset) {
-  NewLine();
-  OS << Label << " (";
-  if (!Data.empty()) {
-OS << "\n";
-Base += StartOffset;
-OS << format_bytes_with_ascii(Data, Base, 32, 4,
-  CurrentIndent + IndentSpaces, true);
-NewLine();
+  if (Data.empty()) {
+line() << Label << " ()";
+return;
   }
-  OS << ")";
+  line() << Label << " (";
+  Base += StartOffset;
+  OS << format_bytes_with_ascii(Data, Base, 32, 4, CurrentIn

[Lldb-commits] [lldb] r349282 - Update the vFile:open: description to note that the flags

2018-12-15 Thread Jason Molenda via lldb-commits
Author: jmolenda
Date: Sat Dec 15 10:40:38 2018
New Revision: 349282

URL: http://llvm.org/viewvc/llvm-project?rev=349282&view=rev
Log:
Update the vFile:open: description to note that the flags
in the packet are lldb enum values, not the open(2) oflags -- 
forgot about that wrinkle.  Also added a comment to File.h 
noting that the existing values cannot be modified or we'll
have a compatibilty break with any alternative platform
implementations, or older versions of lldb-server.

Modified:
lldb/trunk/docs/lldb-platform-packets.txt
lldb/trunk/include/lldb/Host/File.h

Modified: lldb/trunk/docs/lldb-platform-packets.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/docs/lldb-platform-packets.txt?rev=349282&r1=349281&r2=349282&view=diff
==
--- lldb/trunk/docs/lldb-platform-packets.txt (original)
+++ lldb/trunk/docs/lldb-platform-packets.txt Sat Dec 15 10:40:38 2018
@@ -303,7 +303,9 @@ for the lldb testsuite to be run on a re
 //
 //  request packet has the fields:
 // 1. ASCII hex encoded filename
-// 2. oflags to be passed to open(2), base 16
+// 2. flags passed to the open call, base 16.
+//Note that these are not the oflags that open(2) takes, but
+//are the constant values in enum OpenOptions from lldb's File.h
 // 3. mode bits, base 16
 //  
 //  response is F followed by the opened file descriptor in base 10.

Modified: lldb/trunk/include/lldb/Host/File.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/File.h?rev=349282&r1=349281&r2=349282&view=diff
==
--- lldb/trunk/include/lldb/Host/File.h (original)
+++ lldb/trunk/include/lldb/Host/File.h Sat Dec 15 10:40:38 2018
@@ -33,6 +33,8 @@ public:
   static int kInvalidDescriptor;
   static FILE *kInvalidStream;
 
+  // NB this enum is used in the lldb platform gdb-remote packet
+  // vFile:open: and existing values cannot be modified.
   enum OpenOptions {
 eOpenOptionRead = (1u << 0),  // Open file for reading
 eOpenOptionWrite = (1u << 1), // Open file for writing


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


[Lldb-commits] [PATCH] D55608: Make crashlog.py work or binaries with spaces in their names

2018-12-15 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl updated this revision to Diff 178375.
aprantl added a comment.

Fixed the reported problems with the regexes and added testcases with example 
lines. I used the funny test setup to avoid burdening the installed crashlog.py 
script with unit test code that would need to be parsed every time.


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

https://reviews.llvm.org/D55608

Files:
  examples/python/crashlog.py
  lit/Python/crashlog.test

Index: lit/Python/crashlog.test
===
--- /dev/null
+++ lit/Python/crashlog.test
@@ -0,0 +1,80 @@
+# -*- python -*-
+# RUN: cd %S/../../examples/python && %lldb -S %s | FileCheck %s
+# CHECK-LABEL: {{S}}KIP BEYOND CHECKS
+script
+import crashlog
+cl = crashlog.CrashLog
+images = [
+"0x10b60b000 - 0x10f707fff com.apple.LLDB.framework (1.1000.11.38.2 - 1000.11.38.2) <96E36F5C-1A83-39A1-8713-5FDD9701C3F1> /Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/LLDB",
+# CHECK: 0x10b60b000
+# CHECK: 0x10f707fff
+# CHECK: com.apple.LLDB.framework
+# CHECK: 96E36F5C-1A83-39A1-8713-5FDD9701C3F1
+# CHECK: /Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/LLDB
+
+"0x104591000 - 0x1055cfff7 +llvm-dwarfdump (0)  /Users/USER 1/Documents/*/llvm-dwarfdump",
+# CHECK: 0x104591000
+# CHECK: 0x1055cfff7
+# CHECK: llvm-dwarfdump
+# CHECK: (0)
+# CHECK: B104CFA1-046A-36A6-8EB4-07DDD7CC2DF3
+# CHECK: /Users/USER 1/Documents/*/llvm-dwarfdump
+
+"0x7fff63f2 - 0x7fff63f77ff7  libc++.1.dylib (400.9.4)  /usr/lib/libc++.1.dylib",
+# CHECK: 0x7fff63f2
+# CHECK: 0x7fff63f77ff7
+# CHECK: libc++.1.dylib
+# CHECK: (400.9.4)
+# CHECK: D4AB366F-48A9-3C7D-91BD-41198F69DD57
+# CHECK: /usr/lib/libc++.1.dylib
+
+"0x111 - 0x2 +MyApp Pro arm64  <01234> /tmp/MyApp Pro.app/MyApp Pro"
+# CHECK: 0x111
+# CHECK: 0x2
+# CHECK: MyApp Pro arm64
+# CHECK: None
+# CHECK: 01234
+# CHECK: /tmp/MyApp Pro.app/MyApp Pro
+]
+# CHECK-LABEL: FRAMES
+frames = [
+"0 libsystem_kernel.dylib	0x7fff684b78a6 read + 10",
+# CHECK: 0
+# CHECK: libsystem_kernel.dylib
+# CHECK: 0x7fff684b78a6
+# CHECK: read + 10
+"1   com.apple.LLDB.framework  	0x00010f7954af lldb_private::HostNativeThreadBase::ThreadCreateTrampoline(void*) + 105",
+# CHECK: 1
+# CHECK: com.apple.LLDB.framework
+# CHECK: 0x00010f7954af
+# CHECK: lldb_private{{.*}} + 105
+"2   MyApp Pro arm64	0x00019b0db3a8 foo + 72",
+# CHECK: 2
+# CHECK: MyApp Pro arm64
+# CHECK: 0x00019b0db3a8
+# CHECK: foo + 72
+"3   He 0x1	0x00019b0db3a8 foo + 72"
+# CHECK: 3
+# CHECK: He 0x1
+# CHECK: 0x00019b0db3a8
+# CHECK: foo + 72
+]
+
+
+# Avoid matching the text inside the input.
+print("SKIP BEYOND CHECKS")
+for image in images:
+print("--")
+match = cl.image_regex_uuid.search(image)
+for group in match.groups():
+print(group)
+
+print("FRAMES")
+for frame in frames:
+print("--")
+match = cl.frame_regex.search(frame)
+for group in match.groups():
+print(group)
+
+exit()
+quit
Index: examples/python/crashlog.py
===
--- examples/python/crashlog.py
+++ examples/python/crashlog.py
@@ -94,9 +94,9 @@
 thread_regex = re.compile('^Thread ([0-9]+)([^:]*):(.*)')
 app_backtrace_regex = re.compile(
 '^Application Specific Backtrace ([0-9]+)([^:]*):(.*)')
-frame_regex = re.compile('^([0-9]+)\s+([^ ]+)\s+(0x[0-9a-fA-F]+) +(.*)')
+frame_regex = re.compile('^([0-9]+)\s+(.+?)\s+(0x[0-9a-fA-F]{7}[0-9a-fA-F]+) +(.*)')
 image_regex_uuid = re.compile(
-'(0x[0-9a-fA-F]+)[- ]+(0x[0-9a-fA-F]+) +[+]?([^ ]+) +([^<]+)<([-0-9a-fA-F]+)> (.*)')
+'(0x[0-9a-fA-F]+)[- ]+(0x[0-9a-fA-F]+) +[+]?(.+) +(\(.+\))? ?<([-0-9a-fA-F]+)> (.*)')
 image_regex_no_uuid = re.compile(
 '(0x[0-9a-fA-F]+)[- ]+(0x[0-9a-fA-F]+) +[+]?([^ ]+) +([^/]+)/(.*)')
 empty_line_regex = re.compile('^$')
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits