Hooked up ability to look up data symbols so they show up in disassembly
if the address comes from a data section.
Fixed an issue that could occur when looking up a symbol that has a zero
byte size where no match would be returned even if there was an exact symbol
match.
Cleaned up the section dump output and added the section type into the output.
llvm-svn: 116017
diff --git a/lldb/source/Core/Address.cpp b/lldb/source/Core/Address.cpp
index c880d84..d8e1f25 100644
--- a/lldb/source/Core/Address.cpp
+++ b/lldb/source/Core/Address.cpp
@@ -466,6 +466,34 @@
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 8194b69..2512074 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -372,7 +372,7 @@
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 f4e8800..3dae577 100644
--- a/lldb/source/Core/Section.cpp
+++ b/lldb/source/Core/Section.cpp
@@ -222,11 +222,11 @@
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 @@
{
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");
}