Tiny fixes.

develop
Petr Mrázek 2010-05-26 17:54:30 +02:00
parent ee8ac4e508
commit af1a41712e
5 changed files with 37 additions and 5 deletions

@ -609,7 +609,7 @@ void SHMProcess::read (uint32_t src_address, uint32_t size, uint8_t *target_buff
else else
{ {
// first read equals the size of the SHM window // first read equals the size of the SHM window
uint32_t to_read = SHM_BODY; uint32_t to_read = SHM_BODY - 1024;
while (size) while (size)
{ {
// read to_read bytes from src_cursor // read to_read bytes from src_cursor

@ -23,7 +23,6 @@ distribution.
*/ */
#include "Internal.h" #include "Internal.h"
#include "dfhack/DFProcess.h" #include "dfhack/DFProcess.h"
#include "dfhack/DFWindow.h"
#include "dfhack/DFMemInfo.h" #include "dfhack/DFMemInfo.h"
#include "dfhack/DFError.h" #include "dfhack/DFError.h"
#include "shms.h" #include "shms.h"

@ -23,7 +23,6 @@ distribution.
*/ */
#include "Internal.h" #include "Internal.h"
#include "dfhack/DFProcess.h" #include "dfhack/DFProcess.h"
#include "dfhack/DFWindow.h"
#include "dfhack/DFMemInfo.h" #include "dfhack/DFMemInfo.h"
#include "dfhack/DFError.h" #include "dfhack/DFError.h"
using namespace DFHack; using namespace DFHack;

@ -1,4 +1,4 @@
#ifndef DFHACK_API_H #ifndef DFHACK_API_H
#define DFHACK_API_H #define DFHACK_API_H
#include "dfhack/DFIntegers.h" #include "dfhack/DFIntegers.h"

@ -156,7 +156,40 @@ void searchLoopVector(DFHack::ContextManager & DFMgr, vector <DFHack::t_memrange
} }
} }
} }
void mkcopy(DFHack::ContextManager & DFMgr, vector <DFHack::t_memrange>& ranges, uint32_t element_size)
{
DFMgr.Refresh();
DFHack::Context * DF = DFMgr.getSingleContext();
DF->Attach();
for (int i = 0; i < ranges.size();i++)
{
// can't read? range is invalid to us
if(!ranges[i].read)
continue;
char * buffah = (char *) malloc(ranges[i].end - ranges[i].start);
if(buffah)
{
DF->ReadRaw(ranges[i].start,ranges[i].end - ranges[i].start, (uint8_t *) buffah);
cerr << "buffer for range " << i << " allocated and filled" << endl;
free(buffah);
cerr << "and freed" << endl;
}
else
cerr << "buffer for range " << i << " failed to allocate" << endl;
//loop
/*
for(uint64_t offset = ranges[i].start;offset <= ranges[i].end - sizeof(vecTriplet); offset+=4)
{
DF->ReadRaw(offset, sizeof(vecTriplet), (uint8_t *) &load);
if(load.start <= load.finish && load.finish <= load.alloc_finish)
if((load.finish - load.start) / element_size == length)
found.push_back(offset);
}
*/
}
DF->Detach();
DFMgr.purge();
}
int main (void) int main (void)
{ {
@ -325,6 +358,7 @@ int main (void)
} }
else if(mode == 3)// string else if(mode == 3)// string
{ {
mkcopy(DFMgr, selected_ranges,0);
//searchLoopString(DF, selected_ranges); //searchLoopString(DF, selected_ranges);
} }
#ifndef LINUX_BUILD #ifndef LINUX_BUILD