devsaurus wrote:GDB should give you a better insight into the compiled code
Thank you
That unblocked my problem.
GDB does not find my symbol, but I can load the adresses from the error message and display the source code intermingled with the diassassembly
(gdb) disass /m 0x000000004026041c,+0x400
for example roughly yields
57 source_ip.addr = pingopt->ip;
0x4026041e <ping_received+6>: l32i.n a2, a2, 0
0x4026042b <ping_received+19>: l32i.n a2, a2, 4
0x4026042f <ping_received+23>: addi a3, a1, 16
0x40260432 <ping_received+26>: addmi a14, a3, 0x400
0x40260435 <ping_received+29>: s32i.n a2, a14, 16
58 ipaddr_ntoa_r(&source_ip, ipaddrstr, sizeof(ipaddrstr));
0x40260437 <ping_received+31>: movi a2, 0x410
0x4026043a <ping_received+34>: add.n a2, a3, a2
0x4026043c <ping_received+36>: movi.n a4, 16
So when the offendig address was `0x4026042b` I can assume line 57 as the culprit - great .
Now I can apply the good old printing debug technique:
void ping_received(void *arg, void *data) {
struct ping_msg *pingmsg = (struct ping_msg*)arg;
struct ping_option *pingopt = pingmsg->ping_opt;
struct ping_resp *pingresp = (struct ping_resp*)data;
c_printf("[wjr] what do we have in ping_recieved? | arg= %X | data= %X | pingmsg= %X | pingopt= %X | pingresp = %X | \n",
arg, data, pingmsg, pingopt, pingresp);
char ipaddrstr[16];
ip_addr_t source_ip;
c_printf("[wjr] before accessing pingopt\n");
source_ip.addr = pingopt->ip;
c_printf("[wjr] after accessing pingopt\n");
yields
> [wjr] what do we have in ping_recieved? | arg= 3FFF0598 | data= 3FFFFE50 | pingmsg= 3FFF0598 | pingopt= 4 | pingresp = 3FFFFE50 |
[wjr] before accessing pingopt
Fatal exception 28(LoadProhibitedCause):
epc1=0x4026046b, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00000008, depc=0x00000000
Bingo!
Looks like we have some data in `pingopt` instead of a pointer.
So either the tutorial was never able to run - maybe because ist was intended to be a debugging tutorial, or the interface has changed.
Anyway, my confidence is growing again