- More style cleanups.
- Add FindSection() and IsLoaded() calls to ElfFile. - On init, cache the section start/end for the .text and .plt sections in DwarfImageDebugInfo. Use them to make the check for classifying addresses significantly cheaper. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39826 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -590,32 +590,31 @@ ThreadHandler::_HandleSingleStepStep(CpuState* cpuState)
|
||||
if (fStepStatement->ContainsAddress(cpuState->InstructionPointer())) {
|
||||
_SingleStepThread(cpuState->InstructionPointer());
|
||||
return true;
|
||||
} else {
|
||||
StackTrace* stackTrace = fThread->GetStackTrace();
|
||||
Reference<StackTrace> stackTraceReference(stackTrace);
|
||||
}
|
||||
|
||||
if (stackTrace == NULL && cpuState != NULL) {
|
||||
if (fDebuggerInterface->GetArchitecture()->CreateStackTrace(
|
||||
fThread->GetTeam(), this, cpuState, stackTrace) == B_OK) {
|
||||
stackTraceReference.SetTo(stackTrace, true);
|
||||
}
|
||||
StackTrace* stackTrace = fThread->GetStackTrace();
|
||||
Reference<StackTrace> stackTraceReference(stackTrace);
|
||||
|
||||
if (stackTrace == NULL && cpuState != NULL) {
|
||||
if (fDebuggerInterface->GetArchitecture()->CreateStackTrace(
|
||||
fThread->GetTeam(), this, cpuState, stackTrace) == B_OK) {
|
||||
stackTraceReference.SetTo(stackTrace, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (stackTrace != NULL) {
|
||||
StackFrame* frame = stackTrace->FrameAt(0);
|
||||
Image* image = frame->GetImage();
|
||||
ImageDebugInfo* info = NULL;
|
||||
if (GetImageDebugInfo(image, info) != B_OK)
|
||||
return false;
|
||||
if (stackTrace != NULL) {
|
||||
StackFrame* frame = stackTrace->FrameAt(0);
|
||||
Image* image = frame->GetImage();
|
||||
ImageDebugInfo* info = NULL;
|
||||
if (GetImageDebugInfo(image, info) != B_OK)
|
||||
return false;
|
||||
|
||||
Reference<ImageDebugInfo>(info, true);
|
||||
|
||||
if (info->GetAddressSectionType(
|
||||
Reference<ImageDebugInfo>(info, true);
|
||||
if (info->GetAddressSectionType(
|
||||
cpuState->InstructionPointer())
|
||||
== ADDRESS_SECTION_TYPE_PLT) {
|
||||
_SingleStepThread(cpuState->InstructionPointer());
|
||||
return true;
|
||||
}
|
||||
_SingleStepThread(cpuState->InstructionPointer());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -220,7 +220,11 @@ DwarfImageDebugInfo::DwarfImageDebugInfo(const ImageInfo& imageInfo,
|
||||
fTypeCache(typeCache),
|
||||
fFile(file),
|
||||
fTextSegment(NULL),
|
||||
fRelocationDelta(0)
|
||||
fRelocationDelta(0),
|
||||
fTextSectionStart(0),
|
||||
fTextSectionEnd(0),
|
||||
fPLTSectionStart(0),
|
||||
fPLTSectionEnd(0)
|
||||
{
|
||||
fFile->AcquireReference();
|
||||
fTypeCache->AcquireReference();
|
||||
@@ -247,6 +251,18 @@ DwarfImageDebugInfo::Init()
|
||||
|
||||
fRelocationDelta = fImageInfo.TextBase() - fTextSegment->LoadAddress();
|
||||
|
||||
ElfSection* section = fFile->GetElfFile()->FindSection(".text");
|
||||
if (section != NULL) {
|
||||
fTextSectionStart = section->LoadAddress() + fRelocationDelta;
|
||||
fTextSectionEnd = fTextSectionStart + section->Size();
|
||||
}
|
||||
|
||||
section = fFile->GetElfFile()->FindSection(".plt");
|
||||
if (section != NULL) {
|
||||
fPLTSectionStart = section->LoadAddress() + fRelocationDelta;
|
||||
fPLTSectionEnd = fPLTSectionStart + section->Size();
|
||||
}
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
@@ -432,22 +448,11 @@ DwarfImageDebugInfo::GetType(GlobalTypeCache* cache,
|
||||
AddressSectionType
|
||||
DwarfImageDebugInfo::GetAddressSectionType(target_addr_t address)
|
||||
{
|
||||
address -= fRelocationDelta;
|
||||
ElfFile* file = fFile->GetElfFile();
|
||||
if (address >= fTextSectionStart && address < fTextSectionEnd)
|
||||
return ADDRESS_SECTION_TYPE_FUNCTION;
|
||||
|
||||
ElfSection* section = file->GetSection(".text");
|
||||
if (section != NULL && address >= section->LoadAddress()
|
||||
&& address < section->LoadAddress() + section->Size()) {
|
||||
file->PutSection(section);
|
||||
return ADDRESS_SECTION_TYPE_FUNCTION;
|
||||
}
|
||||
|
||||
section = file->GetSection(".plt");
|
||||
if (section != NULL && address >= section->LoadAddress()
|
||||
&& address < section->LoadAddress() + section->Size()) {
|
||||
file->PutSection(section);
|
||||
return ADDRESS_SECTION_TYPE_PLT;
|
||||
}
|
||||
if (address >= fPLTSectionStart && address < fPLTSectionEnd)
|
||||
return ADDRESS_SECTION_TYPE_PLT;
|
||||
|
||||
return ADDRESS_SECTION_TYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
@@ -108,6 +108,10 @@ private:
|
||||
DwarfFile* fFile;
|
||||
ElfSegment* fTextSegment;
|
||||
target_addr_t fRelocationDelta;
|
||||
target_addr_t fTextSectionStart;
|
||||
target_addr_t fTextSectionEnd;
|
||||
target_addr_t fPLTSectionStart;
|
||||
target_addr_t fPLTSectionEnd;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -293,6 +293,19 @@ ElfFile::PutSection(ElfSection* section)
|
||||
}
|
||||
|
||||
|
||||
ElfSection*
|
||||
ElfFile::FindSection(const char* name) const
|
||||
{
|
||||
for (SectionList::ConstIterator it = fSections.GetIterator();
|
||||
ElfSection* section = it.Next();) {
|
||||
if (strcmp(section->Name(), name) == 0)
|
||||
return section;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
ElfSegment*
|
||||
ElfFile::TextSegment() const
|
||||
{
|
||||
|
||||
@@ -33,6 +33,7 @@ public:
|
||||
|
||||
status_t Load();
|
||||
void Unload();
|
||||
bool IsLoaded() const { return fLoadCount > 0; }
|
||||
|
||||
private:
|
||||
const char* fName;
|
||||
@@ -79,6 +80,7 @@ public:
|
||||
|
||||
ElfSection* GetSection(const char* name);
|
||||
void PutSection(ElfSection* section);
|
||||
ElfSection* FindSection(const char* name) const;
|
||||
|
||||
ElfSegment* TextSegment() const;
|
||||
ElfSegment* DataSegment() const;
|
||||
|
||||
Reference in New Issue
Block a user