* TeamMemoryBlock: Now stores whether or not the block it represents is writable.

* RetrieveMemoryBlockJob: Make use of get_memory_properties() to retrieve the
  block's protection bits and mark it appropriately.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42132 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Rene Gollent 2011-06-12 20:51:27 +00:00
parent 051cb22a2a
commit 62e1d169f8
6 changed files with 29 additions and 6 deletions

View File

@ -3,7 +3,7 @@ SubDir HAIKU_TOP src apps debugger ;
CCFLAGS += -Werror ;
C++FLAGS += -Werror ;
UsePrivateHeaders debug interface kernel shared ;
UsePrivateHeaders debug interface kernel shared libroot ;
UsePrivateSystemHeaders ;
SEARCH_SOURCE += [ FDirName $(SUBDIR) arch ] ;

View File

@ -6,6 +6,7 @@
#include "Jobs.h"
#include <AutoLocker.h>
#include <memory_private.h>
#include "Architecture.h"
#include "BitBuffer.h"
@ -637,10 +638,11 @@ ResolveValueNodeValueJob::_ResolveParentNodeValue(ValueNode* parentNode)
}
RetrieveMemoryBlockJob::RetrieveMemoryBlockJob(TeamMemory* teamMemory,
TeamMemoryBlock* memoryBlock)
RetrieveMemoryBlockJob::RetrieveMemoryBlockJob(Team* team,
TeamMemory* teamMemory, TeamMemoryBlock* memoryBlock)
:
fKey(memoryBlock, JOB_TYPE_GET_MEMORY_BLOCK),
fTeam(team),
fTeamMemory(teamMemory),
fMemoryBlock(memoryBlock)
{
@ -664,12 +666,19 @@ RetrieveMemoryBlockJob::Key() const
status_t
RetrieveMemoryBlockJob::Do()
{
ssize_t result = fTeamMemory->ReadMemory(fMemoryBlock->BaseAddress(),
fMemoryBlock->Data(), fMemoryBlock->Size());
if (result < 0)
return result;
uint32 protection = 0;
uint32 locking = 0;
status_t error = get_memory_properties(fTeam->ID(),
(const void *)fMemoryBlock->BaseAddress(), &protection, &locking);
if (error != B_OK)
return error;
fMemoryBlock->SetWritable((protection & B_WRITE_AREA) != 0);
fMemoryBlock->MarkValid();
return B_OK;
}

View File

@ -184,7 +184,7 @@ private:
class RetrieveMemoryBlockJob : public Job {
public:
RetrieveMemoryBlockJob(
RetrieveMemoryBlockJob(Team* team,
TeamMemory* teamMemory,
TeamMemoryBlock* memoryBlock);
virtual ~RetrieveMemoryBlockJob();
@ -194,6 +194,7 @@ public:
private:
SimpleJobKey fKey;
Team* fTeam;
TeamMemory* fTeamMemory;
TeamMemoryBlock* fMemoryBlock;
};

View File

@ -1338,7 +1338,8 @@ TeamDebugger::_HandleInspectAddress(target_addr_t address,
// schedule the job
status_t result;
if ((result = fWorker->ScheduleJob(
new(std::nothrow) RetrieveMemoryBlockJob(memory, memoryBlock),
new(std::nothrow) RetrieveMemoryBlockJob(fTeam, memory,
memoryBlock),
this)) != B_OK) {
memoryBlock->ReleaseReference();
_NotifyUser("Inspect Address", "Failed to retrieve memory data: %s",

View File

@ -19,6 +19,7 @@ TeamMemoryBlock::TeamMemoryBlock(target_addr_t baseAddress,
TeamMemoryBlockOwner* owner)
:
fValid(false),
fWritable(false),
fBaseAddress(baseAddress),
fBlockOwner(owner)
{
@ -76,6 +77,13 @@ TeamMemoryBlock::Invalidate()
}
void
TeamMemoryBlock::SetWritable(bool writable)
{
fWritable = writable;
}
void
TeamMemoryBlock::NotifyDataRetrieved()
{

View File

@ -40,6 +40,9 @@ public:
uint8* Data() { return fData; };
size_t Size() const { return sizeof(fData); };
bool IsWritable() const { return fWritable; }
void SetWritable(bool writable);
void NotifyDataRetrieved();
protected:
@ -50,6 +53,7 @@ private:
private:
bool fValid;
bool fWritable;
target_addr_t fBaseAddress;
uint8 fData[B_PAGE_SIZE];
ListenerList fListeners;