summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Database/database-types.h8
-rw-r--r--Database/database.h1
-rw-r--r--Database/internals/database-segment.cpp2
-rw-r--r--Database/internals/database-segment.h32
4 files changed, 39 insertions, 4 deletions
diff --git a/Database/database-types.h b/Database/database-types.h
index 8ea61e6..796a16c 100644
--- a/Database/database-types.h
+++ b/Database/database-types.h
@@ -19,12 +19,13 @@ enum basic_tags_t {
* A non-hollow database will be as big (at least) as the input file: in-memory-RLE is probably a good idea.
*/
struct memory_tags_t {
- unsigned short basic_tags: 2;
- /** -1..30, 30 being "user hinted", 29 being "external reference" (entry point, exported symbol, ...)
+ unsigned short basic_tag: 2;
+ unsigned short crawled: 1;
+ /** -1..15, 15 being "user hinted", 14 being "external reference" (entry point, exported symbol, ...)
* and -1 means something's fishy with that tag, and that it is probably completely wrong.
* Certitude will grow down with distance from a certain piece of info when the crawler goes away jumping around.
*/
- unsigned short certitude: 6;
+ unsigned short certitude: 5;
};
/** An absolute pointer can reference a segment from its ID, and a pointer within the segment.
@@ -41,6 +42,7 @@ typedef union {
static inline Uint32 SEGID(absolute_ptr ptr) { return ptr.segment_id; }
static inline Uint32 SEGOFFSET(absolute_ptr ptr) { return ptr.ptr; }
static inline absolute_ptr ABSPTR(Uint32 id, Uint32 ptr) { absolute_ptr r; r.segment_id = id; r.ptr = ptr; return r; }
+static const absolute_ptr ABSNUL = { 0 };
/** A function description.
*/
diff --git a/Database/database.h b/Database/database.h
index 222573d..c010e66 100644
--- a/Database/database.h
+++ b/Database/database.h
@@ -14,6 +14,7 @@ class Database : public Base {
void setStart(DatabaseCell * newStart) { start = newStart; }
void setEnd(DatabaseCell * newEnd) { end = newEnd; }
Segment * getSegment(Uint32 id) {
+ // TODO: have a hash table.
DatabaseCell * cursor;
for (cursor = start; start; cursor = cursor->getNext())
diff --git a/Database/internals/database-segment.cpp b/Database/internals/database-segment.cpp
index 8ee5b4b..6ced68f 100644
--- a/Database/internals/database-segment.cpp
+++ b/Database/internals/database-segment.cpp
@@ -9,7 +9,7 @@ Segment::Segment(Uint32 size, Uint32 id, Uint64 cpu_base, Uint32 extra_size, con
assert(size);
- if (data) {
+ if (data || !size) {
plainmemory = (Byte *) data;
loaded = true;
allocated = false;
diff --git a/Database/internals/database-segment.h b/Database/internals/database-segment.h
index dc4d157..de8e850 100644
--- a/Database/internals/database-segment.h
+++ b/Database/internals/database-segment.h
@@ -56,6 +56,38 @@ class Segment : public Base {
void LoadMemory(Handle * src);
void setTag(Uint32 ptr, memory_tags_t tag);
memory_tags_t getTag(Uint32 ptr);
+ void setBasicTag(Uint32 ptr, basic_tags_t tag) {
+ memory_tags_t t = getTag(ptr);
+ t.basic_tag = tag;
+ setTag(ptr, t);
+ }
+ basic_tags_t getBasicTag(Uint32 ptr) {
+ return (basic_tags_t) getTag(ptr).basic_tag;
+ }
+ void setCrawled(Uint32 ptr, bool crawled) {
+ memory_tags_t t = getTag(ptr);
+ t.crawled = crawled ? 1 : 0;
+ setTag(ptr, t);
+ }
+ bool getCrawled(Uint32 ptr) {
+ return getTag(ptr).crawled;
+ }
+ void setCertitude(Uint32 ptr, int certitude) {
+ if (certitude < 0)
+ certitude = -1;
+ if (certitude > 15)
+ certitude = 15;
+ memory_tags_t t = getTag(ptr);
+ t.certitude = certitude + 1;
+ }
+ int getCertitude(Uint32 ptr) {
+ return getTag(ptr).certitude - 1;
+ }
+ void ResetCrawled() {
+ for (Uint32 ptr = 0; ptr < size; ptr++) {
+ tags[ptr].crawled = 0;
+ }
+ }
Uint32 getSize() { return size; }
Uint64 getFullSize() { return size + extra_size; }
Uint64 getCpuBase() { return cpu_base; }