- 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())) {
|
if (fStepStatement->ContainsAddress(cpuState->InstructionPointer())) {
|
||||||
_SingleStepThread(cpuState->InstructionPointer());
|
_SingleStepThread(cpuState->InstructionPointer());
|
||||||
return true;
|
return true;
|
||||||
} else {
|
}
|
||||||
StackTrace* stackTrace = fThread->GetStackTrace();
|
|
||||||
Reference<StackTrace> stackTraceReference(stackTrace);
|
|
||||||
|
|
||||||
if (stackTrace == NULL && cpuState != NULL) {
|
StackTrace* stackTrace = fThread->GetStackTrace();
|
||||||
if (fDebuggerInterface->GetArchitecture()->CreateStackTrace(
|
Reference<StackTrace> stackTraceReference(stackTrace);
|
||||||
fThread->GetTeam(), this, cpuState, stackTrace) == B_OK) {
|
|
||||||
stackTraceReference.SetTo(stackTrace, true);
|
if (stackTrace == NULL && cpuState != NULL) {
|
||||||
}
|
if (fDebuggerInterface->GetArchitecture()->CreateStackTrace(
|
||||||
|
fThread->GetTeam(), this, cpuState, stackTrace) == B_OK) {
|
||||||
|
stackTraceReference.SetTo(stackTrace, true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (stackTrace != NULL) {
|
if (stackTrace != NULL) {
|
||||||
StackFrame* frame = stackTrace->FrameAt(0);
|
StackFrame* frame = stackTrace->FrameAt(0);
|
||||||
Image* image = frame->GetImage();
|
Image* image = frame->GetImage();
|
||||||
ImageDebugInfo* info = NULL;
|
ImageDebugInfo* info = NULL;
|
||||||
if (GetImageDebugInfo(image, info) != B_OK)
|
if (GetImageDebugInfo(image, info) != B_OK)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Reference<ImageDebugInfo>(info, true);
|
Reference<ImageDebugInfo>(info, true);
|
||||||
|
if (info->GetAddressSectionType(
|
||||||
if (info->GetAddressSectionType(
|
|
||||||
cpuState->InstructionPointer())
|
cpuState->InstructionPointer())
|
||||||
== ADDRESS_SECTION_TYPE_PLT) {
|
== ADDRESS_SECTION_TYPE_PLT) {
|
||||||
_SingleStepThread(cpuState->InstructionPointer());
|
_SingleStepThread(cpuState->InstructionPointer());
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -220,7 +220,11 @@ DwarfImageDebugInfo::DwarfImageDebugInfo(const ImageInfo& imageInfo,
|
|||||||
fTypeCache(typeCache),
|
fTypeCache(typeCache),
|
||||||
fFile(file),
|
fFile(file),
|
||||||
fTextSegment(NULL),
|
fTextSegment(NULL),
|
||||||
fRelocationDelta(0)
|
fRelocationDelta(0),
|
||||||
|
fTextSectionStart(0),
|
||||||
|
fTextSectionEnd(0),
|
||||||
|
fPLTSectionStart(0),
|
||||||
|
fPLTSectionEnd(0)
|
||||||
{
|
{
|
||||||
fFile->AcquireReference();
|
fFile->AcquireReference();
|
||||||
fTypeCache->AcquireReference();
|
fTypeCache->AcquireReference();
|
||||||
@@ -247,6 +251,18 @@ DwarfImageDebugInfo::Init()
|
|||||||
|
|
||||||
fRelocationDelta = fImageInfo.TextBase() - fTextSegment->LoadAddress();
|
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;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -432,22 +448,11 @@ DwarfImageDebugInfo::GetType(GlobalTypeCache* cache,
|
|||||||
AddressSectionType
|
AddressSectionType
|
||||||
DwarfImageDebugInfo::GetAddressSectionType(target_addr_t address)
|
DwarfImageDebugInfo::GetAddressSectionType(target_addr_t address)
|
||||||
{
|
{
|
||||||
address -= fRelocationDelta;
|
if (address >= fTextSectionStart && address < fTextSectionEnd)
|
||||||
ElfFile* file = fFile->GetElfFile();
|
return ADDRESS_SECTION_TYPE_FUNCTION;
|
||||||
|
|
||||||
ElfSection* section = file->GetSection(".text");
|
if (address >= fPLTSectionStart && address < fPLTSectionEnd)
|
||||||
if (section != NULL && address >= section->LoadAddress()
|
return ADDRESS_SECTION_TYPE_PLT;
|
||||||
&& 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ADDRESS_SECTION_TYPE_UNKNOWN;
|
return ADDRESS_SECTION_TYPE_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,6 +108,10 @@ private:
|
|||||||
DwarfFile* fFile;
|
DwarfFile* fFile;
|
||||||
ElfSegment* fTextSegment;
|
ElfSegment* fTextSegment;
|
||||||
target_addr_t fRelocationDelta;
|
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*
|
ElfSegment*
|
||||||
ElfFile::TextSegment() const
|
ElfFile::TextSegment() const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ public:
|
|||||||
|
|
||||||
status_t Load();
|
status_t Load();
|
||||||
void Unload();
|
void Unload();
|
||||||
|
bool IsLoaded() const { return fLoadCount > 0; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const char* fName;
|
const char* fName;
|
||||||
@@ -79,6 +80,7 @@ public:
|
|||||||
|
|
||||||
ElfSection* GetSection(const char* name);
|
ElfSection* GetSection(const char* name);
|
||||||
void PutSection(ElfSection* section);
|
void PutSection(ElfSection* section);
|
||||||
|
ElfSection* FindSection(const char* name) const;
|
||||||
|
|
||||||
ElfSegment* TextSegment() const;
|
ElfSegment* TextSegment() const;
|
||||||
ElfSegment* DataSegment() const;
|
ElfSegment* DataSegment() const;
|
||||||
|
|||||||
Reference in New Issue
Block a user