1: echo "add-auto-load-safe-path scripts/loader.py" > ~/.gdbinit
loader.py脚本主要是告诉gdb怎么connect guest(default port 1234)
2: 启动gdb
gdb build/release/loader.elf
编译启动guest ./scripts/build image=iperf ./scripts/run.py -nv --verbose
(gdb) connect warning: Unable to find dynamic linker breakpoint function. GDB will be unable to debug shared library initializers and track explicitly loaded dynamic code. sched::cpu::do_idle (this=this@entry=0xffff80000122b040) at core/sched.cc:404 404 handle_incoming_wakeups(); Python Exception <class 'gdb.error'> `sched::thread::status' is not defined as an aggregate type.: Error occurred in Python command: `sched::thread::status' is not defined as an aggregate type. (gdb) info threads [New Thread 2] [New Thread 3] [New Thread 4] Id Target Id Frame 4 Thread 4 (CPU#3 [halted ]) sched::cpu::do_idle (this=this@entry=0xffff80000122b040) at core/sched.cc:404 3 Thread 3 (CPU#2 [halted ]) sched::cpu::do_idle (this=this@entry=0xffff8000011f6040) at core/sched.cc:404 2 Thread 2 (CPU#1 [halted ]) sched::cpu::do_idle (this=this@entry=0xffff8000011c1040) at core/sched.cc:404 * 1 Thread 1 (CPU#0 [running]) sched::cpu::do_idle (this=this@entry=0xffff80000122b040) at core/sched.cc:404 (gdb) bt #0 sched::cpu::do_idle (this=this@entry=0xffff80000122b040) at core/sched.cc:404 #1 0x00000000003f14f8 in sched::cpu::idle (this=0xffff80000122b040) at core/sched.cc:422 #2 0x00000000003f151f in operator() (__closure=<optimized out>) at core/sched.cc:164 #3 std::_Function_handler<void(), sched::cpu::init_idle_thread()::__lambda7>::_M_invoke(const std::_Any_data &) (__functor=...) at /usr/include/c++/4.8/functional:2071 #4 0x00000000003f2d48 in main (this=0xffff8000017e3040) at core/sched.cc:1051 #5 sched::thread_main_c (t=0xffff8000017e3040) at arch/x64/arch-switch.hh:164 #6 0x0000000000393df6 in thread_main () at arch/x64/entry.S:113
上述遇到的问题应该vcpu thread (qemu) 上的问题,接下来我们可以看看vcpu halted的问题
(gdb) thread 2 [Switching to thread 2 (Thread 2)] #0 sched::cpu::do_idle (this=this@entry=0xffff8000011c1040) at core/sched.cc:404 404 handle_incoming_wakeups(); (gdb) bt #0 sched::cpu::do_idle (this=this@entry=0xffff8000011c1040) at core/sched.cc:404 #1 0x00000000003f14f8 in sched::cpu::idle (this=0xffff8000011c1040) at core/sched.cc:422 #2 0x00000000003f151f in operator() (__closure=<optimized out>) at core/sched.cc:164 #3 std::_Function_handler<void(), sched::cpu::init_idle_thread()::__lambda7>::_M_invoke(const std::_Any_data &) (__functor=...) at /usr/include/c++/4.8/functional:2071 #4 0x00000000003f2d48 in main (this=0xffff800001765040) at core/sched.cc:1051 #5 sched::thread_main_c (t=0xffff800001765040) at arch/x64/arch-switch.hh:164 #6 0x0000000000393df6 in thread_main () at arch/x64/entry.S:113
我理解的是可能该vcpu没被使用到,一直在等待激活的状态。
(gdb) osv syms /root/osv/apps/iperf/iperf 0x100000c00000 add symbol table from file "/root/osv/apps/iperf/iperf" at .text_addr = 0x100000c07370 .gnu.hash_addr = 0x100000c001f0 .dynsym_addr = 0x100000c009d8 .dynstr_addr = 0x100000c029b8 .gnu.version_addr = 0x100000c03f72 .gnu.version_r_addr = 0x100000c04220 .rela.dyn_addr = 0x100000c04300 .rela.plt_addr = 0x100000c053b0 .init_addr = 0x100000c066a0 .plt_addr = 0x100000c066c0 .fini_addr = 0x100000c1394c .rodata_addr = 0x100000c13960 .eh_frame_hdr_addr = 0x100000c1609c .eh_frame_addr = 0x100000c16528 .gcc_except_table_addr = 0x100000c1781c .init_array_addr = 0x100000e18260 .fini_array_addr = 0x100000e18268 .jcr_addr = 0x100000e18270 .data.rel.ro_addr = 0x100000e18280 .dynamic_addr = 0x100000e18b40 .got_addr = 0x100000e18d30 .got.plt_addr = 0x100000e19000 .data_addr = 0x100000e19680 .bss_addr = 0x100000e19740 .comment_addr = 0x100000c00000 .symtab_addr = 0x100000c00000 .strtab_addr = 0x100000c00000
这个功能应该是查看apps的链接库
(gdb) osv info threads 1 (0xe6b530) reclaimer cpu0 waiting condvar::wait(lockfree::mutex*, sched::timer*) at core/condvar.cc:43 vruntime 7.55319e-23 2 (0xe60a50) page-access-sca cpu0 waiting pagecache::access_scanner::run() at core/pagecache.cc:593 vruntime 19.1261 timers: 341.786667580 3 (0xe661e0) page_pool_l2 cpu0 waiting memory::page_pool::l2::fill_thread() at core/mempool.cc:1325 vruntime 1.2449e-17 4 (0xffff80000161f040) itimer-real cpu? unstarted ?? at arch/x64/entry.S:112 vruntime 0 5 (0xffff80000163d040) itimer-virt cpu? unstarted ?? at arch/x64/entry.S:112 vruntime 0 6 (0xffff8000016ad040) balancer0 cpu0 waiting ?? at arch/x64/entry.S:113 vruntime 0.0535002 timers: 341.863805280 7 (0xffff8000016c7040) rcu0 cpu0 waiting osv::rcu::cpu_quiescent_state_thread::do_work() at core/rcu.cc:181 vruntime 8.64092e-18 8 (0xffff8000016e7050) page_pool_l1_0 cpu0 waiting memory::page_pool::l1::fill_thread() at core/mempool.cc:1249 vruntime 2.70802e-10 9 (0xffff80000170c040) percpu0 cpu0 waiting workman::call_of_duty() at core/percpu-worker.cc:94 vruntime 1.49779e-20 10 (0xffff800001725740) async_worker0 cpu0 waiting async::async_worker::run() at core/async.cc:160 vruntime 4.62833e-23 11 (0xffff800001746040) idle0 cpu0 running std::_Function_handler<void(), sched::cpu::init_idle_thread()::__lambda7>::_M_invoke(const std::_Any_data &) at /usr/include/c++/4.8/functional:2071 vruntime inf 12 (0xffff800001765040) idle1 cpu1 running std::_Function_handler<void(), sched::cpu::init_idle_thread()::__lambda7>::_M_invoke(const std::_Any_data &) at /usr/include/c++/4.8/functional:2071 vruntime inf 13 (0xffff8000017a4040) idle2 cpu2 running std::_Function_handler<void(), sched::cpu::init_idle_thread()::__lambda7>::_M_invoke(const std::_Any_data &) at /usr/include/c++/4.8/functional:2071 vruntime inf 14 (0xffff8000017e3040) idle3 cpu3 running std::_Function_handler<void(), sched::cpu::init_idle_thread()::__lambda7>::_M_invoke(const std::_Any_data &) at /usr/include/c++/4.8/functional:2071 vruntime inf
可以看到osv运行的全部线程及运行状态
(gdb) osv memory Total Memory: 2147081216 Bytes Mmap Memory: 3346432 Bytes (0.16%) Free Memory: 2086907904 Bytes (97.20%)