panda
panda copied to clipboard
Pandalog problem during rebuilding
Hi guys, I'm trying to implement pandalog in my plugin, but I have some issues.... If in my .proto file, I set an "optional" field, it remains empty, instead if I set it as "required", I got this error:
what(): CHECK failed: IsInitialized(): Can't serialize message of type "panda.LogEntry" because it is missing required fields: test1
To be sure that I was not doing mistakes in my implementation, I tryied to modify "asidstory" plug-in. I added one field: "test1" as required and in the code of the plug-in I wrote this:
ple.test1 = strdup ("TEST");
I rebuilt all and I got the same error of my plug-in... I think it should be an error during building ? Or what else?
Then the .proto file of asidstory now is:
message AsidInfo {
required uint64 asid = 1;
required string name = 2;
required uint32 pid = 3;
required uint64 start_instr = 4;
required uint64 end_instr = 5;
required uint64 count = 6;
}
optional AsidInfo asid_info = 40;
required string test1 = 41;
optional uint64 asid = 3;
And the code that write in pandalog is:
if (pandalog) {
for (auto &kvp : process_datas) {
auto &np = kvp.first;
auto &pd = kvp.second;
Panda__AsidInfo *ai = (Panda__AsidInfo *) malloc(sizeof(Panda__AsidInfo));
*ai = PANDA__ASID_INFO__INIT;
ai->asid = np.asid;
ai->name = strdup(np.name.c_str());
ai->pid = np.pid;
ai->start_instr = pd.first;
ai->end_instr = pd.last;
ai->count = pd.count;
Panda__LogEntry ple = PANDA__LOG_ENTRY__INIT;
ple.asid_info = ai;
ple.test1 = strdup ("TEST");
pandalog_write_entry(&ple);
free(ai);
}
}
Your error mentions of myfield
which can't be found elsewhere. In your proto file you define required string test = 41;
and in your C code, you assign ple.test1 = strdup ("TEST");
.
Do all of these happen in the same snapshot of your codebase?
I'm sorry, that was a typo trying to report the problem. I edited the post. I'm pretty sure that the implementation of pandalog is correct (I followed the basic steps and modified coherently the code)
(the original code contains many curses .....)
I believe you can't add a top-level required field to PANDA's protocol. The open_write
function used to open the log for writing, also writes an entry to the log.
https://github.com/panda-re/panda/blob/67f98f0849f0cb9aab0d202031c83e5f5933da28/panda/src/plog-cc.cpp#L130
This means that any required field you may have added will not have been initialized when this write happens.
Still not sure why you don't get anything in your PANDA log after making the field optional. Are you sure that your logging block runs? Are you looking at the right PANDA log file after replaying?
I believe you can't add a top-level required field to PANDA's protocol. The
open_write
function used to open the log for writing, also writes an entry to the log.https://github.com/panda-re/panda/blob/67f98f0849f0cb9aab0d202031c83e5f5933da28/panda/src/plog-cc.cpp#L130
This means that any required field you may have added will not have been initialized when this write happens.
Still not sure why you don't get anything in your PANDA log after making the field optional. Are you sure that your logging block runs? Are you looking at the right PANDA log file after replaying?
Unfortunatly I'm sure that I don't see the log entry if I set it as optional....I Used both the ./plot_reader wrote in C++ and the one in python from /panda/scripts directory, but nothing....
Stale issue message
I'm experimenting the same issue... please can you help us?