public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/28565] New: gdb BPF support . gdb crashes after step/run/continue
@ 2021-11-08 23:43 evanovan at gmail dot com
  0 siblings, 0 replies; only message in thread
From: evanovan at gmail dot com @ 2021-11-08 23:43 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=28565

            Bug ID: 28565
           Summary: gdb BPF support . gdb crashes after step/run/continue
           Product: gdb
           Version: HEAD
            Status: UNCONFIRMED
          Severity: critical
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: evanovan at gmail dot com
  Target Milestone: ---

using "GNU gdb (GDB) 12.0.50.20211108-git" 

(gdb) show configuration
This GDB was configured as follows:
   configure --host=bpf --target=bpf
             --with-auto-load-dir=$debugdir:$datadir/auto-load
             --with-auto-load-safe-path=$debugdir:$datadir/auto-load
             --with-expat
             --with-gdb-datadir=/usr/local/share/gdb (relocatable)
             --with-jit-reader-dir=/usr/local/lib/gdb (relocatable)
             --without-libunwind-ia64
             --without-lzma
             --without-babeltrace
             --without-intel-pt
             --with-mpfr
             --without-xxhash
             --with-python=/usr
             --with-python-libdir=/usr/lib
             --without-debuginfod
             --without-guile
             --disable-source-highlight
             --with-separate-debug-dir=/usr/local/lib/debug (relocatable)

("Relocatable" means the directory can be moved with the GDB installation
tree, and GDB will still find it.)

Testing bpf debug support using simulator ( simple hellow world that call an
empty function and return back ) . I didn't see any resource or tutorial or
requirements so I ran with what I had. 



What are the requirements to debug BPF code as far as gdb / clang / llvm / gcc
versions ? and what is the coverage/support available at the moment ? 

I tried and these are the results. 

getting latest GDB : 
$ git clone git://sourceware.org/git/binutils-gdb.git
$ cd binutils-gdb
$ ./configure bpf
$ make

-----------------------------------

using gcc/g++ version (gcc version 11.1.0 (Ubuntu 11.1.0-1ubuntu1~18.04.1) )
command :  gcc -ggdb -O2  -Wall -c hello_world.c -o hello_world.o    ( debug
symbols GETS generated )

./gdb/gdb <hello_world.o>
(gdb) target sim
(gdb) sim memory-size 4Mb
(gdb) load
(gdb) run

setting breakpoints and hitting them work  
you CAN'T step 
you CAN'T print "info registers" or print variables 

continue or step    crashes gdb and core dump

----------------------------------------------

using clang / llvm ( clang version 10.0.0-4ubuntu1~18.04.2)
command : clang  -g  -O2 -target bpf -c hello_world.c        ( no debug symbols
gets generated )

no debugging with no symbols 


---------------------------------------

terminal output: 

Reading symbols from /root/hello_bpf/hello_world.o...
(gdb) target sim
Connected to the simulator.
(gdb) sim memory-size 4Mb
(gdb) load
Loading section .text, size 0x13 lma 0
Loading section .eh_frame, size 0x40 lma 0
Start address 0
Transfer rate: 664 bits in <1 sec.
(gdb) break test_bpf
Skipping prologue: start_pc=0x0
Breakpoint 1 at 0x0: file hello_world.c, line 9.
(gdb) start
Function "main" not defined.
Make breakpoint pending on future shared library load? (y or [n]) n
Starting program: /root/hello_bpf/hello_world.o 
Skipping prologue: start_pc=0x0

Breakpoint 1, long unsigned int (x=0) at hello_world.c:9
9               return y;
(gdb) info registers
r0             0x0                 0
r1             0x0                 0
r2             0x0                 0
r3             0x0                 0
r4             0x0                 0
r5             0x0                 0
r6             0x0                 0
r7             0x0                 0
r8             0x0                 0
r9             0x0                 0
r10            0x0                 0x0 <long unsigned int>
pc             0x0                 0x0 <long unsigned int>
(gdb) n


Fatal signal: Aborted
----- Backtrace -----
0x565200bc6747 gdb_internal_backtrace_1
        /root/binutils-gdb/gdb/bt-utils.c:121
0x565200bc6747 _Z22gdb_internal_backtracev
        /root/binutils-gdb/gdb/bt-utils.c:164
0x565200cbdeaa handle_fatal_signal
        /root/binutils-gdb/gdb/event-top.c:896
0x7f95b64a503f ???
0x7f95b64a4fb7 ???
0x7f95b64a6920 ???
0x565200b3f4b1 sim_engine_invalid_insn
        /root/binutils-gdb/sim/bpf/traps.c:37
0x565200f45c2e execute

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-11-08 23:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-08 23:43 [Bug gdb/28565] New: gdb BPF support . gdb crashes after step/run/continue evanovan at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).