Debugger: DwarfImageDebugInfo cleanups.
- For simply looking up a type, we need neither the register map, nor the target interface, as those are only necessary for resolution of values and/or locations. - Fix memory leak. A reference to the target interface was acquired in the type context's ctor, but not correspondingly released in the dtor.
This commit is contained in:
@@ -430,27 +430,6 @@ DwarfImageDebugInfo::GetType(GlobalTypeCache* cache,
|
|||||||
const BString& name, const TypeLookupConstraints& constraints,
|
const BString& name, const TypeLookupConstraints& constraints,
|
||||||
Type*& _type)
|
Type*& _type)
|
||||||
{
|
{
|
||||||
int32 registerCount = fArchitecture->CountRegisters();
|
|
||||||
const Register* registers = fArchitecture->Registers();
|
|
||||||
|
|
||||||
// get the DWARF -> architecture register map
|
|
||||||
RegisterMap* fromDwarfMap;
|
|
||||||
status_t error = fArchitecture->GetDwarfRegisterMaps(NULL, &fromDwarfMap);
|
|
||||||
if (error != B_OK)
|
|
||||||
return error;
|
|
||||||
BReference<RegisterMap> fromDwarfMapReference(fromDwarfMap, true);
|
|
||||||
|
|
||||||
// create the target interface
|
|
||||||
BasicTargetInterface *inputInterface
|
|
||||||
= new(std::nothrow) BasicTargetInterface(registers, registerCount,
|
|
||||||
fromDwarfMap, fArchitecture, fDebuggerInterface);
|
|
||||||
|
|
||||||
if (inputInterface == NULL)
|
|
||||||
return B_NO_MEMORY;
|
|
||||||
|
|
||||||
BReference<BasicTargetInterface> inputInterfaceReference(inputInterface,
|
|
||||||
true);
|
|
||||||
|
|
||||||
// iterate through all compilation units
|
// iterate through all compilation units
|
||||||
for (int32 i = 0; CompilationUnit* unit = fFile->CompilationUnitAt(i);
|
for (int32 i = 0; CompilationUnit* unit = fFile->CompilationUnitAt(i);
|
||||||
i++) {
|
i++) {
|
||||||
@@ -489,8 +468,7 @@ DwarfImageDebugInfo::GetType(GlobalTypeCache* cache,
|
|||||||
if (typeContext == NULL) {
|
if (typeContext == NULL) {
|
||||||
typeContext = new(std::nothrow)
|
typeContext = new(std::nothrow)
|
||||||
DwarfTypeContext(fArchitecture, fImageInfo.ImageID(), fFile,
|
DwarfTypeContext(fArchitecture, fImageInfo.ImageID(), fFile,
|
||||||
unit, NULL, 0, 0, fRelocationDelta, inputInterface,
|
unit, NULL, 0, 0, fRelocationDelta, NULL, NULL);
|
||||||
fromDwarfMap);
|
|
||||||
if (typeContext == NULL)
|
if (typeContext == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
typeContextReference.SetTo(typeContext, true);
|
typeContextReference.SetTo(typeContext, true);
|
||||||
@@ -499,7 +477,7 @@ DwarfImageDebugInfo::GetType(GlobalTypeCache* cache,
|
|||||||
// create the type
|
// create the type
|
||||||
DwarfType* type;
|
DwarfType* type;
|
||||||
DwarfTypeFactory typeFactory(typeContext, fTypeLookup, cache);
|
DwarfTypeFactory typeFactory(typeContext, fTypeLookup, cache);
|
||||||
error = typeFactory.CreateType(typeEntry, type);
|
status_t error = typeFactory.CreateType(typeEntry, type);
|
||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|||||||
@@ -152,7 +152,8 @@ DwarfTypeContext::DwarfTypeContext(Architecture* architecture, image_id imageID,
|
|||||||
{
|
{
|
||||||
fArchitecture->AcquireReference();
|
fArchitecture->AcquireReference();
|
||||||
fFile->AcquireReference();
|
fFile->AcquireReference();
|
||||||
fTargetInterface->AcquireReference();
|
if (fTargetInterface != NULL)
|
||||||
|
fTargetInterface->AcquireReference();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -160,6 +161,8 @@ DwarfTypeContext::~DwarfTypeContext()
|
|||||||
{
|
{
|
||||||
fArchitecture->ReleaseReference();
|
fArchitecture->ReleaseReference();
|
||||||
fFile->ReleaseReference();
|
fFile->ReleaseReference();
|
||||||
|
if (fTargetInterface != NULL)
|
||||||
|
fTargetInterface->ReleaseReference();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user