Debug Kit: Don't find the runtime_loader debug area if no debug context.

We can't clone it or do anything in that case.

Also clean up coding style, and drop B_CLONEABLE_AREA from
the debug area, as it's not needed anymore.
This commit is contained in:
Augustin Cavalier 2025-01-14 17:28:47 -05:00
parent 7331a67227
commit 853ddd218e
3 changed files with 17 additions and 19 deletions

View File

@ -65,6 +65,18 @@ RemoteMemoryAccessor::~RemoteMemoryAccessor()
}
status_t
RemoteMemoryAccessor::InitCheck() const
{
// If we don't have a debug context, then there's nothing we can do.
// SymbolLookup's image file functionality will still be available, though.
if (fDebugContext == NULL || fDebugContext->nub_port < 0)
return B_NO_INIT;
return B_OK;
}
const void *
RemoteMemoryAccessor::PrepareAddress(const void *remoteAddress,
int32 size)
@ -97,7 +109,6 @@ RemoteMemoryAccessor::PrepareAddressNoThrow(const void *remoteAddress,
}
Area*
RemoteMemoryAccessor::AreaForLocalAddress(const void* address) const
{
@ -143,9 +154,7 @@ RemoteMemoryAccessor::_GetAreaNoThrow(const void *address, int32 size, Area *&_a
}
}
// If we don't have a debug context, then there's nothing we can do.
// SymbolLookup's image file functionality will still be available, though.
if (fDebugContext == NULL || fDebugContext->nub_port < 0)
if (InitCheck() != B_OK)
return B_NO_INIT;
// we need to clone a new area
@ -221,7 +230,6 @@ private:
// #pragma mark -
// constructor
SymbolLookup::SymbolLookup(debug_context* debugContext, image_id image)
:
RemoteMemoryAccessor(debugContext),
@ -232,7 +240,6 @@ SymbolLookup::SymbolLookup(debug_context* debugContext, image_id image)
}
// destructor
SymbolLookup::~SymbolLookup()
{
while (Image* image = fImages.RemoveHead())
@ -240,7 +247,6 @@ SymbolLookup::~SymbolLookup()
}
// Init
status_t
SymbolLookup::Init()
{
@ -248,7 +254,7 @@ SymbolLookup::Init()
status_t error = 0;
if (fDebugContext->team != B_SYSTEM_TEAM) {
if (RemoteMemoryAccessor::InitCheck() == B_OK) {
TRACE(("SymbolLookup::Init(): searching debug area...\n"));
// find the runtime loader debug area
@ -305,7 +311,6 @@ SymbolLookup::Init()
}
// LookupSymbolAddress
status_t
SymbolLookup::LookupSymbolAddress(addr_t address, addr_t *_baseAddress,
const char **_symbolName, size_t *_symbolNameLen, const char **_imageName,
@ -350,7 +355,6 @@ SymbolLookup::LookupSymbolAddress(addr_t address, addr_t *_baseAddress,
}
// InitSymbolIterator
status_t
SymbolLookup::InitSymbolIterator(image_id imageID,
SymbolIterator& iterator) const
@ -374,7 +378,6 @@ SymbolLookup::InitSymbolIterator(image_id imageID,
}
// InitSymbolIterator
status_t
SymbolLookup::InitSymbolIteratorByAddress(addr_t address,
SymbolIterator& iterator) const
@ -396,7 +399,6 @@ SymbolLookup::InitSymbolIteratorByAddress(addr_t address,
}
// NextSymbol
status_t
SymbolLookup::NextSymbol(SymbolIterator& iterator, const char** _symbolName,
size_t* _symbolNameLen, addr_t* _symbolAddress, size_t* _symbolSize,
@ -407,7 +409,6 @@ SymbolLookup::NextSymbol(SymbolIterator& iterator, const char** _symbolName,
}
// GetSymbol
status_t
SymbolLookup::GetSymbol(image_id imageID, const char* name, int32 symbolType,
void** _symbolLocation, size_t* _symbolSize, int32* _symbolType) const
@ -421,7 +422,6 @@ SymbolLookup::GetSymbol(image_id imageID, const char* name, int32 symbolType,
}
// _FindLoadedImageAtAddress
const image_t *
SymbolLookup::_FindLoadedImageAtAddress(addr_t address)
{
@ -446,7 +446,6 @@ SymbolLookup::_FindLoadedImageAtAddress(addr_t address)
}
// _FindLoadedImageByID
const image_t*
SymbolLookup::_FindLoadedImageByID(image_id id)
{
@ -469,7 +468,6 @@ SymbolLookup::_FindLoadedImageByID(image_id id)
}
// _FindImageAtAddress
Image*
SymbolLookup::_FindImageAtAddress(addr_t address) const
{
@ -484,7 +482,6 @@ SymbolLookup::_FindImageAtAddress(addr_t address) const
}
// _FindImageByID
Image*
SymbolLookup::_FindImageByID(image_id id) const
{
@ -498,7 +495,6 @@ SymbolLookup::_FindImageByID(image_id id) const
}
// _SymbolNameLen
size_t
SymbolLookup::_SymbolNameLen(const char* address) const
{

View File

@ -95,6 +95,8 @@ public:
RemoteMemoryAccessor(debug_context* debugContext);
~RemoteMemoryAccessor();
status_t InitCheck() const;
const void *PrepareAddress(const void *remoteAddress, int32 size);
const void *PrepareAddressNoThrow(const void *remoteAddress,
int32 size);

View File

@ -1210,7 +1210,7 @@ rldelf_init(void)
runtime_loader_debug_area *area;
area_id areaID = _kern_create_area(RUNTIME_LOADER_DEBUG_AREA_NAME,
(void **)&area, B_RANDOMIZED_ANY_ADDRESS, size, B_NO_LOCK,
B_READ_AREA | B_WRITE_AREA | B_CLONEABLE_AREA);
B_READ_AREA | B_WRITE_AREA);
if (areaID < B_OK) {
FATAL("Failed to create debug area.\n");
_kern_loading_app_failed(areaID);