summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/include/lldb/lldb-private.h3
-rw-r--r--lldb/source/Commands/CommandObjectImage.cpp7
-rw-r--r--lldb/source/Core/Address.cpp28
-rw-r--r--lldb/source/Core/Module.cpp2
-rw-r--r--lldb/source/Core/Section.cpp22
-rw-r--r--lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp12
-rw-r--r--lldb/source/Symbol/Symtab.cpp21
-rw-r--r--lldb/source/Target/Target.cpp2
-rw-r--r--lldb/source/lldb.cpp39
9 files changed, 119 insertions, 17 deletions
diff --git a/lldb/include/lldb/lldb-private.h b/lldb/include/lldb/lldb-private.h
index fd5def81d6f..9ace5372e5c 100644
--- a/lldb/include/lldb/lldb-private.h
+++ b/lldb/include/lldb/lldb-private.h
@@ -67,6 +67,9 @@ GetVersion ();
const char *
GetVoteAsCString (lldb::Vote vote);
+const char *
+GetSectionTypeAsCString (lldb::SectionType sect_type);
+
} // namespace lldb_private
diff --git a/lldb/source/Commands/CommandObjectImage.cpp b/lldb/source/Commands/CommandObjectImage.cpp
index b2ecef23966..f8a52aece1b 100644
--- a/lldb/source/Commands/CommandObjectImage.cpp
+++ b/lldb/source/Commands/CommandObjectImage.cpp
@@ -180,7 +180,14 @@ DumpModuleSections (CommandInterpreter &interpreter, Stream &strm, Module *modul
{
SectionList *section_list = objfile->GetSectionList();
if (section_list)
+ {
+ strm.PutCString ("Sections for '");
+ strm << module->GetFileSpec();
+ strm.Printf ("' (%s):\n", module->GetArchitecture().AsCString());
+ strm.IndentMore();
section_list->Dump(&strm, interpreter.GetDebugger().GetExecutionContext().target, true);
+ strm.IndentLess();
+ }
}
}
}
diff --git a/lldb/source/Core/Address.cpp b/lldb/source/Core/Address.cpp
index c880d84b7c6..d8e1f2568a4 100644
--- a/lldb/source/Core/Address.cpp
+++ b/lldb/source/Core/Address.cpp
@@ -466,6 +466,34 @@ Address::Dump (Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, Dum
SectionType sect_type = section->GetType();
switch (sect_type)
{
+ case eSectionTypeData:
+ if (module)
+ {
+ ObjectFile *objfile = module->GetObjectFile();
+ if (objfile)
+ {
+ Symtab *symtab = objfile->GetSymtab();
+ if (symtab)
+ {
+ const addr_t file_Addr = GetFileAddress();
+ Symbol *symbol = symtab->FindSymbolContainingFileAddress (file_Addr);
+ if (symbol)
+ {
+ const char *symbol_name = symbol->GetName().AsCString();
+ if (symbol_name)
+ {
+ s->PutCString(symbol_name);
+ addr_t delta = file_Addr - symbol->GetAddressRangePtr()->GetBaseAddress().GetFileAddress();
+ if (delta)
+ s->Printf(" + %llu", delta);
+ showed_info = true;
+ }
+ }
+ }
+ }
+ }
+ break;
+
case eSectionTypeDataCString:
// Read the C string from memory and display it
showed_info = true;
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index 8194b69e359..251207425d1 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -372,7 +372,7 @@ void
Module::Dump(Stream *s)
{
Mutex::Locker locker (m_mutex);
- s->Printf("%.*p: ", (int)sizeof(void*) * 2, this);
+ //s->Printf("%.*p: ", (int)sizeof(void*) * 2, this);
s->Indent();
s->Printf("Module %s/%s%s%s%s\n",
m_file.GetDirectory().AsCString(),
diff --git a/lldb/source/Core/Section.cpp b/lldb/source/Core/Section.cpp
index f4e8800222c..3dae577c5c8 100644
--- a/lldb/source/Core/Section.cpp
+++ b/lldb/source/Core/Section.cpp
@@ -222,11 +222,11 @@ Section::Compare (const Section& a, const Section& b)
void
-Section::Dump(Stream *s, Target *target) const
+Section::Dump (Stream *s, Target *target) const
{
- s->Printf("%.*p: ", (int)sizeof(void*) * 2, this);
+// s->Printf("%.*p: ", (int)sizeof(void*) * 2, this);
s->Indent();
- s->Printf("0x%8.8x ", GetID());
+ s->Printf("0x%8.8x %-14s ", GetID(), GetSectionTypeAsCString (m_type));
bool resolved = true;
addr_t addr = LLDB_INVALID_ADDRESS;
@@ -672,16 +672,16 @@ SectionList::Dump (Stream *s, Target *target, bool show_header) const
{
if (show_header && !m_sections.empty())
{
- s->Printf("%.*p: ", (int)sizeof(void*) * 2, this);
+// s->Printf("%.*p: ", (int)sizeof(void*) * 2, this);
+// s->Indent();
+// s->PutCString( "SectionList\n");
+// s->IndentMore();
+// s->Printf("%*s", 2*(sizeof(void *) + 2), "");
s->Indent();
- s->PutCString( "SectionList\n");
- s->IndentMore();
- s->Printf("%*s", 2*(sizeof(void *) + 2), "");
+ s->Printf("SectID Type %s Address File Off. File Size Flags Section Name\n", (target && target->GetSectionLoadList().IsEmpty() == false) ? "Load" : "File");
+// s->Printf("%*s", 2*(sizeof(void *) + 2), "");
s->Indent();
- s->Printf("SectID %s Address File Off. File Size Flags Section Name\n", (target && target->GetSectionLoadList().IsEmpty() == false) ? "Load" : "File");
- s->Printf("%*s", 2*(sizeof(void *) + 2), "");
- s->Indent();
- s->PutCString("---------- --------------------------------------- ---------- ---------- ---------- ----------------------------\n");
+ s->PutCString("---------- -------------- --------------------------------------- ---------- ---------- ---------- ----------------------------\n");
}
diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index ccb9105174f..666fde4f160 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -394,10 +394,11 @@ ObjectFileMachO::ParseSections ()
static ConstString g_sect_name_dwarf_debug_ranges ("__debug_ranges");
static ConstString g_sect_name_dwarf_debug_str ("__debug_str");
static ConstString g_sect_name_eh_frame ("__eh_frame");
+ static ConstString g_sect_name_DATA ("__DATA");
+ static ConstString g_sect_name_TEXT ("__TEXT");
SectionType sect_type = eSectionTypeOther;
-
if (section_name == g_sect_name_dwarf_debug_abbrev)
sect_type = eSectionTypeDWARFDebugAbbrev;
else if (section_name == g_sect_name_dwarf_debug_aranges)
@@ -442,7 +443,14 @@ ObjectFileMachO::ParseSections ()
switch (mach_sect_type)
{
// TODO: categorize sections by other flags for regular sections
- case SectionTypeRegular: sect_type = eSectionTypeOther; break;
+ case SectionTypeRegular:
+ if (segment_sp->GetName() == g_sect_name_TEXT)
+ sect_type = eSectionTypeCode;
+ else if (segment_sp->GetName() == g_sect_name_DATA)
+ sect_type = eSectionTypeData;
+ else
+ sect_type = eSectionTypeOther;
+ break;
case SectionTypeZeroFill: sect_type = eSectionTypeZeroFill; break;
case SectionTypeCStringLiterals: sect_type = eSectionTypeDataCString; break; // section with only literal C strings
case SectionType4ByteLiterals: sect_type = eSectionTypeData4; break; // section with only 4 byte literals
diff --git a/lldb/source/Symbol/Symtab.cpp b/lldb/source/Symbol/Symtab.cpp
index 8326a445d13..6ae3e8301bc 100644
--- a/lldb/source/Symbol/Symtab.cpp
+++ b/lldb/source/Symbol/Symtab.cpp
@@ -65,7 +65,7 @@ void
Symtab::Dump(Stream *s, Target *target) const
{
const_iterator pos;
- s->Printf("%.*p: ", (int)sizeof(void*) * 2, this);
+// s->Printf("%.*p: ", (int)sizeof(void*) * 2, this);
s->Indent();
const FileSpec &file_spec = m_objfile->GetFileSpec();
const char * object_name = NULL;
@@ -705,7 +705,24 @@ Symtab::FindSymbolContainingFileAddress (addr_t file_addr, const uint32_t* index
if (info.match_symbol)
{
- if (info.match_offset < CalculateSymbolSize(info.match_symbol))
+ if (info.match_offset == 0)
+ {
+ // We found an exact match!
+ return info.match_symbol;
+ }
+
+ const size_t symbol_byte_size = CalculateSymbolSize(info.match_symbol);
+
+ if (symbol_byte_size == 0)
+ {
+ // We weren't able to find the size of the symbol so lets just go
+ // with that match we found in our search...
+ return info.match_symbol;
+ }
+
+ // We were able to figure out a symbol size so lets make sure our
+ // offset puts "file_addr" in the symbol's address range.
+ if (info.match_offset < symbol_byte_size)
return info.match_symbol;
}
return NULL;
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index f8e54aec57e..57d044987e9 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -66,7 +66,7 @@ Target::~Target()
void
Target::Dump (Stream *s)
{
- s->Printf("%.*p: ", (int)sizeof(void*) * 2, this);
+// s->Printf("%.*p: ", (int)sizeof(void*) * 2, this);
s->Indent();
s->PutCString("Target\n");
s->IndentMore();
diff --git a/lldb/source/lldb.cpp b/lldb/source/lldb.cpp
index fdc649b1f92..0f85c570b96 100644
--- a/lldb/source/lldb.cpp
+++ b/lldb/source/lldb.cpp
@@ -156,3 +156,42 @@ lldb_private::GetVoteAsCString (lldb::Vote vote)
return "invalid";
}
+
+const char *
+lldb_private::GetSectionTypeAsCString (lldb::SectionType sect_type)
+{
+ switch (sect_type)
+ {
+ case eSectionTypeInvalid: return "invalid";
+ case eSectionTypeCode: return "code";
+ case eSectionTypeContainer: return "container";
+ case eSectionTypeData: return "data";
+ case eSectionTypeDataCString: return "data-cstr";
+ case eSectionTypeDataCStringPointers: return "data-cstr-ptr";
+ case eSectionTypeDataSymbolAddress: return "data-symbol-addr";
+ case eSectionTypeData4: return "data-4-byte";
+ case eSectionTypeData8: return "data-8-byte";
+ case eSectionTypeData16: return "data-16-byte";
+ case eSectionTypeDataPointers: return "data-ptrs";
+ case eSectionTypeDebug: return "debug";
+ case eSectionTypeZeroFill: return "zero-fill";
+ case eSectionTypeDataObjCMessageRefs: return "objc-message-refs";
+ case eSectionTypeDataObjCCFStrings: return "objc-cfstrings";
+ case eSectionTypeDWARFDebugAbbrev: return "dwarf-abbrev";
+ case eSectionTypeDWARFDebugAranges: return "dwarf-aranges";
+ case eSectionTypeDWARFDebugFrame: return "dwarf-frame";
+ case eSectionTypeDWARFDebugInfo: return "dwarf-info";
+ case eSectionTypeDWARFDebugLine: return "dwarf-line";
+ case eSectionTypeDWARFDebugLoc: return "dwarf-loc";
+ case eSectionTypeDWARFDebugMacInfo: return "dwarf-macinfo";
+ case eSectionTypeDWARFDebugPubNames: return "dwarf-pubnames";
+ case eSectionTypeDWARFDebugPubTypes: return "dwarf-pubtypes";
+ case eSectionTypeDWARFDebugRanges: return "dwarf-ranges";
+ case eSectionTypeDWARFDebugStr: return "dwarf-str";
+ case eSectionTypeEHFrame: return "eh-frame";
+ case eSectionTypeOther: return "regular";
+ }
+ return "unknown";
+
+}
+
OpenPOWER on IntegriCloud