Sujet : Inspecting memory on the field
De : pozzugno (at) *nospam* gmail.com (pozz)
Groupes : comp.arch.embeddedDate : 03. Feb 2025, 00:12:49
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vnou73$tcss$1@dont-email.me>
User-Agent : Mozilla Thunderbird
I instrumented one of my system with a low-level memory read functionality. I'm able to read the content of a memory block in a running system by remote.
I also have the source code and build files of the firmware running in the system.
Now suppose you have a complex static data structure at address X. Its size is 1000 bytes. The struct could be defined as:
--- mystruct.c ---
#include "object1.h"
#include "object2.h"
static struct {
int x;
int y;
struct {
enum { OBJ1, OBJ2 } type;
union {
object1 obj1; // object1 is another struct
object2 obj2; // object2 is another struct
};
} array[10];
...
} mystruct;
---
By using low-level memory read function, I can read the current values of all the bytes in mystruct. How to print a nice report of mystruct values, such as:
mystruct = {
x = 10,
y = 3,
array = [
{ OBJ1, obj={...}, obj2={...} },
{ OBJ1, obj={...}, obj2={...} },
{ OBJ1, obj={...}, obj2={...} },
{ OBJ1, obj={...}, obj2={...} },
]
}
I know I can write a script that works on a specific mystruct, maybe calculating the offset address of each field. I'm searching for a tool that can calculate the correct offset address and print a nice report as before.