Inspecting memory on the field
From
pozz@pozzugno@gmail.com to
comp.arch.embedded on Mon Feb 3 00:12:49 2025
From Newsgroup: comp.arch.embedded
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.
--- Synchronet 3.20c-Linux NewsLink 1.2