[Lldb-commits] [lldb] r116017 - in /lldb/trunk: include/lldb/lldb-private.h source/Commands/CommandObjectImage.cpp source/Core/Address.cpp source/Core/Module.cpp source/Core/Section.cpp source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp source/Symbol/Symtab.cpp source/Target/Target.cpp source/lldb.cpp
Greg Clayton
gclayton at apple.com
Thu Oct 7 17:21:05 PDT 2010
Author: gclayton
Date: Thu Oct 7 19:21:05 2010
New Revision: 116017
URL: http://llvm.org/viewvc/llvm-project?rev=116017&view=rev
Log:
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.
Modified:
lldb/trunk/include/lldb/lldb-private.h
lldb/trunk/source/Commands/CommandObjectImage.cpp
lldb/trunk/source/Core/Address.cpp
lldb/trunk/source/Core/Module.cpp
lldb/trunk/source/Core/Section.cpp
lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/trunk/source/Symbol/Symtab.cpp
lldb/trunk/source/Target/Target.cpp
lldb/trunk/source/lldb.cpp
Modified: lldb/trunk/include/lldb/lldb-private.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-private.h?rev=116017&r1=116016&r2=116017&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-private.h (original)
+++ lldb/trunk/include/lldb/lldb-private.h Thu Oct 7 19:21:05 2010
@@ -67,6 +67,9 @@
const char *
GetVoteAsCString (lldb::Vote vote);
+const char *
+GetSectionTypeAsCString (lldb::SectionType sect_type);
+
} // namespace lldb_private
Modified: lldb/trunk/source/Commands/CommandObjectImage.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectImage.cpp?rev=116017&r1=116016&r2=116017&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectImage.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectImage.cpp Thu Oct 7 19:21:05 2010
@@ -180,7 +180,14 @@
{
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();
+ }
}
}
}
Modified: lldb/trunk/source/Core/Address.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Address.cpp?rev=116017&r1=116016&r2=116017&view=diff
==============================================================================
--- lldb/trunk/source/Core/Address.cpp (original)
+++ lldb/trunk/source/Core/Address.cpp Thu Oct 7 19:21:05 2010
@@ -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;
Modified: lldb/trunk/source/Core/Module.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Module.cpp?rev=116017&r1=116016&r2=116017&view=diff
==============================================================================
--- lldb/trunk/source/Core/Module.cpp (original)
+++ lldb/trunk/source/Core/Module.cpp Thu Oct 7 19:21:05 2010
@@ -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(),
Modified: lldb/trunk/source/Core/Section.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Section.cpp?rev=116017&r1=116016&r2=116017&view=diff
==============================================================================
--- lldb/trunk/source/Core/Section.cpp (original)
+++ lldb/trunk/source/Core/Section.cpp Thu Oct 7 19:21:05 2010
@@ -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");
}
Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=116017&r1=116016&r2=116017&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Thu Oct 7 19:21:05 2010
@@ -394,10 +394,11 @@
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 @@
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
Modified: lldb/trunk/source/Symbol/Symtab.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Symtab.cpp?rev=116017&r1=116016&r2=116017&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/Symtab.cpp (original)
+++ lldb/trunk/source/Symbol/Symtab.cpp Thu Oct 7 19:21:05 2010
@@ -65,7 +65,7 @@
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 @@
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;
Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=116017&r1=116016&r2=116017&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Thu Oct 7 19:21:05 2010
@@ -66,7 +66,7 @@
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();
Modified: lldb/trunk/source/lldb.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/lldb.cpp?rev=116017&r1=116016&r2=116017&view=diff
==============================================================================
--- lldb/trunk/source/lldb.cpp (original)
+++ lldb/trunk/source/lldb.cpp Thu Oct 7 19:21:05 2010
@@ -156,3 +156,42 @@
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";
+
+}
+
More information about the lldb-commits
mailing list