On Wed, Mar 2, 2022 at 10:50 AM Andrew Burgess wrote: > > William Tambe via Gdb-patches writes: > > > Regarding this issue, support for gdbserver has been implemented here: > > https://github.com/fontamsoc/binutils-gdb/blob/b2eeeae0/gdbserver/linux-pu32-low.cc > > > > Support for gdb has been implemented here: > > https://github.com/fontamsoc/binutils-gdb/blob/b2eeeae0/gdb/pu32-tdep.c > > > > gdb is able to successfully connect to gdbserver and start a program > > on the target; however, gdb is unable to fetch registers and instead > > shows as follow: > > > > (gdb) info registers > > r0 > > r1 > > r2 > > r3 > > r4 > > r5 > > r6 > > r7 > > r8 > > r9 > > r10 > > r11 > > r12 > > r13 > > r14 > > r15 > > pc > > > > Find attached full `gdbserver --debug --remote-debug` logs as well as > > gdb logs. > > You should consider using 'set debug remote 1' on the GDB side to > capture the remote packets from that perspective. I'm particularlly > interested in the reply to the 'g' packet, but the complete logs would > be useful. This information doesn't seem to be visible in the gdbserver > output (or I'm missing it). Please, find attached similar gdb and gdbserver logs; with `set debug remote 1` used on the GDB side. > > Thanks, > Andrew > > > > > Any idea what might have been missed while implementing gdbserver support ? > > Would you suggest ways to debug the issue ? > > tambewilliam@kubuntu20200502:~$ sudo /opt/pu32-toolchain/bin/pu32-elf-gdb -x buildroot-build/staging/usr/share/buildroot/gdbinit -ex 'target extended-remote /dev/ttyUSB2' -ex 'set cwd /' && -ex 'monitor set debug 1' -ex 'monitor set remote-debug 1' > > GNU gdb (GDB) 11.0.50.20210718-git > > Copyright (C) 2021 Free Software Foundation, Inc. > > License GPLv3+: GNU GPL version 3 or later > > This is free software: you are free to change and redistribute it. > > There is NO WARRANTY, to the extent permitted by law. > > Type "show copying" and "show warranty" for details. > > This GDB was configured as "--host=x86_64-pc-linux-gnu --target=pu32-elf". > > Type "show configuration" for configuration details. > > For bug reporting instructions, please see: > > . > > Find the GDB manual and other documentation resources online at: > > . > > > > For help, type "help". > > Type "apropos word" to search for commands related to "word". > > warning: File "/home/tambewilliam/.gdbinit" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load". > > To enable execution of this file add > > add-auto-load-safe-path /home/tambewilliam/.gdbinit > > line to your configuration file "/root/.config/gdb/gdbinit". > > To completely disable this security protection add > > set auto-load safe-path / > > line to your configuration file "/root/.config/gdb/gdbinit". > > For more information about this security protection see the > > "Auto-loading safe path" section in the GDB manual. E.g., run from the shell: > > info "(gdb)Auto-loading safe path" > > buildroot-build/staging/usr/share/buildroot/gdbinit: No such file or directory. > > Remote debugging using /dev/ttyUSB2 > > (gdb) set remote exec-file /bin/ls > > (gdb) r -l / > > Starting program: -l / > > Reading /usr/bin/busybox from remote target... > > warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead. > > Reading /usr/bin/busybox from remote target... > > Reading symbols from target:/usr/bin/busybox... > > (No debugging symbols found in target:/usr/bin/busybox) > > warning: Target-supplied registers are not supported by the current architecture > > PC register is not available > > (gdb) info registers > > r0 > > r1 > > r2 > > r3 > > r4 > > r5 > > r6 > > r7 > > r8 > > r9 > > r10 > > r11 > > r12 > > r13 > > r14 > > r15 > > pc > > (gdb) > > # gdbserver --debug --remote-debug --multi /dev/ttyS1 & > > [2] 94 > > root@buildroot:~ > > # sigchld_handler > > sigchld_handler > > sigchld_handler > > sigchld_handler > > sigchld_handler > > Remote debugging using /dev/ttyS1 > > > > root@buildroot:~ > > # > > root@buildroot:~ > > # > > root@buildroot:~ > > # > > root@buildroot:~ > > # handling possible serial event > > [getpkt: discarding char '+'] > > getpkt ("qSupported:multiprocess+;swbreak+;hwbreak+;qRelocInsn+;fork-events+;vfork-events+;exec-events+;vContSupported+;QThreadEvents+;no-resumed+;memory-tagging+"); [sending ack] > > [sent ack] > > putpkt ("$PacketSize=47ff;QPassSignals+;QProgramSignals+;QStartupWithShell+;QEnvironmentHexEncoded+;QEnvironmentReset+;QEnvironmentUnset+;QSetWorkingDir+;qXfer:libraries-svr4:read+;augmented-libraries-svr4-read+;qXfer:auxv:read+;qXfer:siginfo:read+;qXfer:siginfo:write+;qXfer:features:read+;qXfer:osdata:read+;multiprocess+;fork-events+;vfork-events+;exec-events+;QNonStop+;QDisableRandomization+;qXfer:threads:read+;ConditionalBreakpoints+;BreakpointCommands+;QAgent+;Qbtrace:bts+;Qbtrace-conf:bts:size+;Qbtrace:pt+;Qbtrace-conf:pt:size+;Qbtrace:off+;qXfer:btrace:read+;qXfer:btrace-conf:read+;swbreak+;hwbreak+;qXfer:exec-file:read+;vContSupported+;QThreadEvents+;no-resumed+#21"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("vMustReplyEmpty"); [sending ack] > > [sent ack] > > putpkt ("$#00"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("!"); [sending ack] > > [sent ack] > > putpkt ("$OK#9a"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("QProgramSignals:0;1;3;4;6;7;8;9;a;b;c;d;e;f;10;11;12;13;14;15;16;17;18;19;1a;1b;1c;1d;1e;1f;20;21;22;23;24;25;26;27;28;29;2a;2b;2c;2d;2e;2f;30;31;32;33;34;35;36;37;38;39;3a;3b;3c;3d;3e;3f;40;41;42;43;44;45;46;47;48;49;4a;4b;4c;4d;4e;4f;50;51;52;53;54;55;56;57;58;59;5a;5b;5c;5d;5e;5f;60;61;62;63;64;65;66;67;68;69;6a;6b;6c;6d;6e;6f;70;71;72;73;74;75;76;77;78;79;7a;7b;7c;7d;7e;7f;80;81;82;83;84;85;86;87;88;89;8a;8b;8c;8d;8e;8f;90;91;92;93;94;95;96;97;"); [sending ack] > > [sent ack] > > putpkt ("$OK#9a"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("Hgp0.0"); [sending ack] > > [sent ack] > > putpkt ("$E01#a6"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("qXfer:features:read:target.xml:0,1000"); [sending ack] > > [sent ack] > > putpkt ("$E01#a6"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("QNonStop:0"); [sending ack] > > [sent ack] > > linux_async (0), previous=0 > > [all-stop mode enabled] > > putpkt ("$OK#9a"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("qTStatus"); [sending ack] > > [sent ack] > > putpkt ("$#00"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("?"); [sending ack] > > [sent ack] > >>>>> entering void linux_process_target::stop_all_lwps(int, lwp_info*) > > stop_all_lwps (stop, except=none) > > wait_for_sigstop: pulling events > > LWFE: waitpid(-1, ...) returned -1, > > LLW: exit (no unwaited-for LWP) > > stop_all_lwps done, setting stopping_threads back to !stopping > > <<<< exiting void linux_process_target::stop_all_lwps(int, lwp_info*) > > putpkt ("$W00#b7"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("QDisableRandomization:1"); [sending ack] > > [sent ack] > > [address space randomization disabled] > > putpkt ("$OK#9a"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("QStartupWithShell:1"); [sending ack] > > [sent ack] > > [Inferior will be started with shell]putpkt ("$OK#9a"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("QEnvironmentReset"); [sending ack] > > [sent ack] > > putpkt ("$OK#9a"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("QSetWorkingDir:2f"); [sending ack] > > [sent ack] > > [Set the inferior's current directory to /] > > putpkt ("$OK#9a"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("vRun;2f62696e2f6c73;2d6c;2f"); [sending ack] > > [sent ack] > > args: -l / > >>>>> entering ptid_t linux_process_target::wait_1(ptid_t, target_waitstatus*, target_wait_flags) > > wait_1: [Process 97] > > LWFE: waitpid(-1, ...) returned 0, ERRNO-OK > > leader_pid=97, leader_lp!=NULL=1, num_lwps=1, zombie=0 > > sigsuspend'ing > > sigchld_handler > > LWFE: waitpid(-1, ...) returned 97, ERRNO-OK > > LLW: waitpid 97 received SIGTRAP - Trace/breakpoint trap (stopped) > > LWFE: waitpid(-1, ...) returned 0, ERRNO-OK > > Hit a non-gdbserver trap event. > >>>>> entering void linux_process_target::stop_all_lwps(int, lwp_info*) > > stop_all_lwps (stop, except=none) > > wait_for_sigstop: pulling events > > LWFE: waitpid(-1, ...) returned 0, ERRNO-OK > > leader_pid=97, leader_lp!=NULL=1, num_lwps=1, zombie=0 > > LLW: exit (no unwaited-for LWP) > > stop_all_lwps done, setting stopping_threads back to !stopping > > <<<< exiting void linux_process_target::stop_all_lwps(int, lwp_info*) > > Checking whether LWP 97 needs to move out of the jump pad...no > > wait_1 ret = LWP 97.97, 1, 5 > > <<<< exiting ptid_t linux_process_target::wait_1(ptid_t, target_waitstatus*, target_wait_flags) > >>>>> entering virtual void linux_process_target::resume(thread_resume*, size_t) > > linux_resume: > > already continuing LWP 97 at GDB's request > > Resuming, no pending status or step over needed > > linux_resume done > > <<<< exiting virtual void linux_process_target::resume(thread_resume*, size_t) > >>>>> entering ptid_t linux_process_target::wait_1(ptid_t, target_waitstatus*, target_wait_flags) > > wait_1: [Process 97] > > LWFE: waitpid(-1, ...) returned 0, ERRNO-OK > > RSRL: resuming stopped-resumed LWP LWP 97.97 at 0: step=0 > > Resuming lwp 97 (continue, signal 0, stop not expected) > > leader_pid=97, leader_lp!=NULL=1, num_lwps=1, zombie=0 > > sigsuspend'ing > > sigchld_handler > > LWFE: waitpid(-1, ...) returned 97, ERRNO-OK > > LLW: waitpid 97 received SIGTRAP - Trace/breakpoint trap (stopped) > > LWFE: waitpid(-1, ...) returned 0, ERRNO-OK > > Hit a non-gdbserver trap event. > >>>>> entering void linux_process_target::stop_all_lwps(int, lwp_info*) > > stop_all_lwps (stop, except=none) > > wait_for_sigstop: pulling events > > LWFE: waitpid(-1, ...) returned 0, ERRNO-OK > > leader_pid=97, leader_lp!=NULL=1, num_lwps=1, zombie=0 > > LLW: exit (no unwaited-for LWP) > > stop_all_lwps done, setting stopping_threads back to !stopping > > <<<< exiting void linux_process_target::stop_all_lwps(int, lwp_info*) > > Checking whether LWP 97 needs to move out of the jump pad...no > > wait_1 ret = LWP 97.97, 1, 5 > > <<<< exiting ptid_t linux_process_target::wait_1(ptid_t, target_waitstatus*, target_wait_flags) > > Process /bin/ls created; pid = 97 > > Writing resume reply for LWP 97.97:1 > > putpkt ("$T0500:0*"00;0e:0*"00;0f:0*"00;10:0*"00;thread:p61.61;core:0;#90"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("qAttached:61"); [sending ack] > > [sent ack] > > putpkt ("$0#30"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("qXfer:exec-file:read:61:0,1000"); [sending ack] > > [sent ack] > > putpkt ("$l/usr/bin/busybox#98"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("vFile:setfs:0"); [sending ack] > > [sent ack] > > putpkt ("$F0#76"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("vFile:open:6a7573742070726f62696e67,0,1c0"); [sending ack] > > [sent ack] > > putpkt ("$F-1,2#02"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("vFile:setfs:61"); [sending ack] > > [sent ack] > > putpkt ("$F0#76"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("vFile:open:2f7573722f62696e2f62757379626f78,0,0"); [sending ack] > > [sent ack] > > putpkt ("$F4#7a"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("vFile:pread:4,47ff,0"); [sending ack] > > [sent ack] > > putpkt ("$F4734;ELF"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("vFile:pread:4,47ff,1ce288"); [sending ack] > > [sent ack] > > putpkt ("$F370;"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("vFile:fstat:4"); [sending ack] > > [sent ack] > > putpkt ("$F40;"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("vFile:pread:4,47ff,34"); [sending ack] > > [sent ack] > > putpkt ("$F4733;"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("vFile:pread:4,47ff,1ce1a1"); [sending ack] > > [sent ack] > > putpkt ("$F457;"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("vFile:pread:4,47ff,b4"); [sending ack] > > [sent ack] > > putpkt ("$F4733;"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("vFile:fstat:4"); [sending ack] > > [sent ack] > > putpkt ("$F40;"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("vFile:open:2f7573722f62696e2f62757379626f78,0,0"); [sending ack] > > [sent ack] > > putpkt ("$F5#7b"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("vFile:pread:5,47ff,0"); [sending ack] > > [sent ack] > > putpkt ("$F4734;ELF"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("vFile:pread:5,47ff,1ce288"); [sending ack] > > [sent ack] > > putpkt ("$F370;"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("vFile:fstat:5"); [sending ack] > > [sent ack] > > putpkt ("$F40;"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("vFile:pread:5,47ff,34"); [sending ack] > > [sent ack] > > putpkt ("$F4733;"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("vFile:pread:5,47ff,1ce1a1"); [sending ack] > > [sent ack] > > putpkt ("$F457;"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("vFile:pread:5,47ff,b4"); [sending ack] > > [sent ack] > > putpkt ("$F4733;"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("vFile:fstat:5"); [sending ack] > > [sent ack] > > putpkt ("$F40;"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("qSymbol::"); [sending ack] > > [sent ack] > > Trying host libthread_db library: libthread_db.so.1. > > dlopen failed: libthread_db.so.1: cannot open shared object file: No such file or directory. > > thread_db_load_search returning 0 > > putpkt ("$OK#9a"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("qSymbol::"); [sending ack] > > [sent ack] > > Trying host libthread_db library: libthread_db.so.1. > > dlopen failed: libthread_db.so.1: cannot open shared object file: No such file or directory. > > thread_db_load_search returning 0 > > putpkt ("$OK#9a"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("qXfer:exec-file:read:61:0,1000"); [sending ack] > > [sent ack] > > putpkt ("$l/usr/bin/busybox#98"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("qOffsets"); [sending ack] > > [sent ack] > > putpkt ("$#00"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("Hgp61.61"); [sending ack] > > [sent ack] > > putpkt ("$OK#9a"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("qXfer:features:read:target.xml:0,1000"); [sending ack] > > [sent ack] > > putpkt ("$l > > > > > > pu32 > > GNU/Linux > > > > * > > * > > * > > * > > * > > * > > * > > * > > * > > * > > * > > * > > * > > * > > * > > * > > * > > > > > > #ef"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("vFile:pread:4,47ff,b4"); [sending ack] > > [sent ack] > > putpkt ("$F4733;"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("g"); [sending ack] > > [sent ack] > > putpkt ("$x*}x*C#04"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("qXfer:libraries-svr4:read::0,1000"); [sending ack] > > [sent ack] > > putpkt ("$E01#a6"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("qXfer:auxv:read::0,1000"); [sending ack] > > [sent ack] > > putpkt ("$l"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("m50000034,20"); [sending ack] > > [sent ack] > > putpkt ("$010*050*"050f9cb1c00f9cb1c00050*"0010*!#ce"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("m50000054,20"); [sending ack] > > [sent ack] > > putpkt ("$010*"fccb1c00fcdb1c50fcdb1c50a5150* 1c370*!60*"0010*!#1c"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("m50000074,20"); [sending ack] > > [sent ack] > > putpkt ("$040*"b40*"b40* 50b40* 5020*"020*"0040*"040*"#58"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("m50000094,20"); [sending ack] > > [sent ack] > > putpkt ("$070*"fccb1c00fcdb1c50fcdb1c50180*"540*"040*"040*"#ff"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("m50000034,20"); [sending ack] > > [sent ack] > > putpkt ("$010*050*"050f9cb1c00f9cb1c00050*"0010*!#ce"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("m50000054,20"); [sending ack] > > [sent ack] > > putpkt ("$010*"fccb1c00fcdb1c50fcdb1c50a5150* 1c370*!60*"0010*!#1c"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("m50000074,20"); [sending ack] > > [sent ack] > > putpkt ("$040*"b40*"b40* 50b40* 5020*"020*"0040*"040*"#58"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("m50000094,20"); [sending ack] > > [sent ack] > > putpkt ("$070*"fccb1c00fcdb1c50fcdb1c50180*"540*"040*"040*"#ff"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("m50000034,20"); [sending ack] > > [sent ack] > > putpkt ("$010*050*"050f9cb1c00f9cb1c00050*"0010*!#ce"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("m50000054,20"); [sending ack] > > [sent ack] > > putpkt ("$010*"fccb1c00fcdb1c50fcdb1c50a5150* 1c370*!60*"0010*!#1c"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("m50000074,20"); [sending ack] > > [sent ack] > > putpkt ("$040*"b40*"b40* 50b40* 5020*"020*"0040*"040*"#58"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("m50000094,20"); [sending ack] > > [sent ack] > > putpkt ("$070*"fccb1c00fcdb1c50fcdb1c50180*"540*"040*"040*"#ff"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("m50000034,20"); [sending ack] > > [sent ack] > > putpkt ("$010*050*"050f9cb1c00f9cb1c00050*"0010*!#ce"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("m50000054,20"); [sending ack] > > [sent ack] > > putpkt ("$010*"fccb1c00fcdb1c50fcdb1c50a5150* 1c370*!60*"0010*!#1c"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("m50000074,20"); [sending ack] > > [sent ack] > > putpkt ("$040*"b40*"b40* 50b40* 5020*"020*"0040*"040*"#58"); [looking for ack] > > [received '+' (0x2b)] > > handling possible serial event > > getpkt ("m50000094,20"); [sending ack] > > [sent ack] > > putpkt ("$070*"fccb1c00fcdb1c50fcdb1c50180*"540*"040*"040*"#ff"); [looking for ack] > > [received '+' (0x2b)] > > > > root@buildroot:~ >