mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-09 11:25:55 +00:00
DWARF: wire up .debug_str dumping.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139799 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "DWARFContext.h"
|
#include "DWARFContext.h"
|
||||||
|
#include "llvm/Support/Format.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
@@ -27,8 +28,18 @@ void DWARFContext::dump(raw_ostream &OS) {
|
|||||||
set.dump(OS);
|
set.dump(OS);
|
||||||
|
|
||||||
OS << "\n.debug_lines contents:\n";
|
OS << "\n.debug_lines contents:\n";
|
||||||
DataExtractor lineData(getLineSection(), isLittleEndian(), 8);
|
// FIXME: must be done per CU.
|
||||||
|
DataExtractor lineData(getLineSection(), isLittleEndian(), /*FIXME*/8);
|
||||||
DWARFDebugLine::dump(lineData, OS);
|
DWARFDebugLine::dump(lineData, OS);
|
||||||
|
|
||||||
|
OS << "\n.debug_str contents:\n";
|
||||||
|
DataExtractor strData(getStringSection(), isLittleEndian(), 0);
|
||||||
|
offset = 0;
|
||||||
|
uint32_t lastOffset = 0;
|
||||||
|
while (const char *s = strData.getCStr(&offset)) {
|
||||||
|
OS << format("0x%8.8x: \"%s\"\n", lastOffset, s);
|
||||||
|
lastOffset = offset;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const DWARFDebugAbbrev *DWARFContext::getDebugAbbrev() {
|
const DWARFDebugAbbrev *DWARFContext::getDebugAbbrev() {
|
||||||
|
@@ -89,7 +89,7 @@ void DWARFDebugInfoEntryMinimal::dumpAttribute(raw_ostream &OS,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
OS << "\t(";
|
OS << "\t(";
|
||||||
formValue.dump(OS, 0, cu);
|
formValue.dump(OS, cu);
|
||||||
OS << ")\n";
|
OS << ")\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include "DWARFFormValue.h"
|
#include "DWARFFormValue.h"
|
||||||
#include "DWARFCompileUnit.h"
|
#include "DWARFCompileUnit.h"
|
||||||
|
#include "DWARFContext.h"
|
||||||
#include "llvm/Support/Dwarf.h"
|
#include "llvm/Support/Dwarf.h"
|
||||||
#include "llvm/Support/Format.h"
|
#include "llvm/Support/Format.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
@@ -256,8 +257,8 @@ DWARFFormValue::skipValue(uint16_t form, DataExtractor debug_info_data,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DWARFFormValue::dump(raw_ostream &OS, const DataExtractor *debug_str_data,
|
DWARFFormValue::dump(raw_ostream &OS, const DWARFCompileUnit *cu) const {
|
||||||
const DWARFCompileUnit *cu) const {
|
DataExtractor debug_str_data(cu->getContext().getStringSection(), true, 0);
|
||||||
uint64_t uvalue = getUnsigned();
|
uint64_t uvalue = getUnsigned();
|
||||||
bool cu_relative_offset = false;
|
bool cu_relative_offset = false;
|
||||||
|
|
||||||
@@ -302,19 +303,16 @@ DWARFFormValue::dump(raw_ostream &OS, const DataExtractor *debug_str_data,
|
|||||||
|
|
||||||
case DW_FORM_sdata: OS << getSigned(); break;
|
case DW_FORM_sdata: OS << getSigned(); break;
|
||||||
case DW_FORM_udata: OS << getUnsigned(); break;
|
case DW_FORM_udata: OS << getUnsigned(); break;
|
||||||
case DW_FORM_strp:
|
case DW_FORM_strp: {
|
||||||
if (debug_str_data) {
|
OS << format(" .debug_str[0x%8.8x] = ", (uint32_t)uvalue);
|
||||||
OS << format(" .debug_str[0x%8.8x] = ", (uint32_t)uvalue);
|
const char* dbg_str = getAsCString(&debug_str_data);
|
||||||
const char* dbg_str = getAsCString(debug_str_data);
|
if (dbg_str) {
|
||||||
if (dbg_str) {
|
OS << '"';
|
||||||
OS << '"';
|
OS.write_escaped(dbg_str);
|
||||||
OS.write_escaped(dbg_str);
|
OS << '"';
|
||||||
OS << '"';
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
OS << format("0x%08x", uvalue);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case DW_FORM_ref_addr:
|
case DW_FORM_ref_addr:
|
||||||
OS << format("0x%016x", uvalue);
|
OS << format("0x%016x", uvalue);
|
||||||
break;
|
break;
|
||||||
|
@@ -48,8 +48,7 @@ public:
|
|||||||
DWARFFormValue(uint16_t form = 0) : Form(form) {}
|
DWARFFormValue(uint16_t form = 0) : Form(form) {}
|
||||||
uint16_t getForm() const { return Form; }
|
uint16_t getForm() const { return Form; }
|
||||||
const ValueType& value() const { return Value; }
|
const ValueType& value() const { return Value; }
|
||||||
void dump(raw_ostream &OS, const DataExtractor *debug_str_data,
|
void dump(raw_ostream &OS, const DWARFCompileUnit* cu) const;
|
||||||
const DWARFCompileUnit* cu) const;
|
|
||||||
bool extractValue(DataExtractor data, uint32_t *offset_ptr,
|
bool extractValue(DataExtractor data, uint32_t *offset_ptr,
|
||||||
const DWARFCompileUnit *cu);
|
const DWARFCompileUnit *cu);
|
||||||
bool isInlinedCStr() const {
|
bool isInlinedCStr() const {
|
||||||
|
@@ -53,6 +53,7 @@ static void DumpInput(const StringRef &Filename) {
|
|||||||
StringRef DebugAbbrevSection;
|
StringRef DebugAbbrevSection;
|
||||||
StringRef DebugLineSection;
|
StringRef DebugLineSection;
|
||||||
StringRef DebugArangesSection;
|
StringRef DebugArangesSection;
|
||||||
|
StringRef DebugStringSection;
|
||||||
|
|
||||||
error_code ec;
|
error_code ec;
|
||||||
for (ObjectFile::section_iterator i = Obj->begin_sections(),
|
for (ObjectFile::section_iterator i = Obj->begin_sections(),
|
||||||
@@ -74,13 +75,16 @@ static void DumpInput(const StringRef &Filename) {
|
|||||||
DebugLineSection = data;
|
DebugLineSection = data;
|
||||||
else if (name == "debug_aranges")
|
else if (name == "debug_aranges")
|
||||||
DebugArangesSection = data;
|
DebugArangesSection = data;
|
||||||
|
else if (name == "debug_str")
|
||||||
|
DebugStringSection = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
OwningPtr<DIContext> dictx(DIContext::getDWARFContext(/*FIXME*/true,
|
OwningPtr<DIContext> dictx(DIContext::getDWARFContext(/*FIXME*/true,
|
||||||
DebugInfoSection,
|
DebugInfoSection,
|
||||||
DebugAbbrevSection,
|
DebugAbbrevSection,
|
||||||
DebugArangesSection,
|
DebugArangesSection,
|
||||||
DebugLineSection));
|
DebugLineSection,
|
||||||
|
DebugStringSection));
|
||||||
dictx->dump(outs());
|
dictx->dump(outs());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user