首页 > 代码库 > gdb调试高级用法

gdb调试高级用法

如何在调试内核时,同时可以调试应用程序的做法:

(cskygdb) cContinuing.^CProgram received signal SIGINT, Interrupt.default_idle () at arch/csky/kernel/process.c:8383		__asm__ __volatile__((cskygdb) hb *0x00065e34           ==》对应应用反汇编处的地址Hardware assisted breakpoint 1 at 0x65e34(cskygdb) cContinuing.Program received signal SIGTRAP, Trace/breakpoint trap.0x00065e36 in ?? ()(cskygdb) disadisable      disassemble  (cskygdb) disadisable      disassemble  (cskygdb) disassemble No function contains program counter for selected frame.(cskygdb) disassemble $pc,$pc+30    ==》确认地址是否跟反汇编处的地址一样Dump of assembler code from 0x65e36 to 0x65e54:=> 0x00065e36:	st	r15, (r0, 24)   0x00065e38:	st	r8, (r0, 28)   0x00065e3a:	mov	r8, r0   0x00065e3c:	st	r2, (r8, 8)   0x00065e3e:	st	r3, (r8, 12)   0x00065e40:	st	r4, (r8, 16)   0x00065e42:	bmaski	r7, 0   0x00065e44:	st	r7, (r8, 0)   0x00065e46:	ld	r7, (r8, 12)   0x00065e48:	bmaski	r6, 8   0x00065e4a:	andn	r7, r7, r6   0x00065e4c:	cmpnei	r7, 0   0x00065e4e:	bt	0x65e5c   0x00065e50:	ld	r2, (r8, 8)   0x00065e52:	ld	r3, (r8, 12)End of assembler dump.(cskygdb) add-symbol-file /home/yingc/nfs/dvb/out.elf 0x00080e0  ==》0x00080e0是text段的地址add symbol table from file "/home/yingc/nfs/dvb/out.elf" at	.text_addr = 0x80e0(y or n) yReading symbols from /home/yingc/nfs/dvb/out.elf...done.(cskygdb) si\0x00065e38	23	{(cskygdb) l18	19	#include "module/app_ioctl.h"20	//#include "module/app_ca_manager.h"21	22	status_t app_ioctl(uint32_t id, uint32_t cmd, void * params)23	{24	    status_t ret = GXCORE_ERROR;25	    switch (cmd & (~0xff))26	    {27	        case APP_FRONTEND_BASE:(cskygdb) n




\yingc@yingc:~/work/goxceed-dvbs-hd/test/solution/output$ csky-elf-readelf -S out.elf
There are 28 section headers, starting at offset 0xa84da0:

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            00000000 000000 000000 00      0   0  0
  [ 1] .init             PROGBITS        000080b4 0000b4 000022 00  AX  0   0  4
  [ 2] .text             PROGBITS        000080e0 0000e0 2f779a 00  AX  0   0 16
  [ 3] .fini             PROGBITS        002ff87c 2f787c 000016 00  AX  0   0  4
  [ 4] .rodata           PROGBITS        002ff8a0 2f78a0 071b60 00   A  0   0 16
  [ 5] .eh_frame         PROGBITS        00371400 369400 0013a8 00   A  0   0  4
  [ 6] .tdata            PROGBITS        003737a8 36a7a8 000004 00 WAT  0   0  4
  [ 7] .tbss             NOBITS          003737ac 36a7ac 000008 00 WAT  0   0  4
  [ 8] .ctors            PROGBITS        003737ac 36a7ac 000008 00  WA  0   0  4
  [ 9] .dtors            PROGBITS        003737b4 36a7b4 000008 00  WA  0   0  4
  [10] .jcr              PROGBITS        003737bc 36a7bc 000004 00  WA  0   0  4
  [11] .got              PROGBITS        003737c0 36a7c0 0000c4 04  WA  0   0  4
  [12] .data             PROGBITS        00373888 36a888 04a8f8 00  WA  0   0  8
  [13] .bss              NOBITS          003be180 3b5180 05a4cc 00  WA  0   0  8
  [14] .comment          PROGBITS        00000000 3b5180 000082 01  MS  0   0  1
  [15] .debug_aranges    PROGBITS        00000000 3b5202 008558 00      0   0  1
  [16] .debug_pubnames   PROGBITS        00000000 3bd75a 01cd87 00      0   0  1
  [17] .debug_info       PROGBITS        00000000 3da4e1 3b54ec 00      0   0  1
  [18] .debug_abbrev     PROGBITS        00000000 78f9cd 03ddac 00      0   0  1
  [19] .debug_line       PROGBITS        00000000 7cd779 19ac68 00      0   0  1
  [20] .debug_frame      PROGBITS        00000000 9683e4 043dc0 00      0   0  4
  [21] .debug_str        PROGBITS        00000000 9ac1a4 06262a 01  MS  0   0  1
  [22] .debug_loc        PROGBITS        00000000 a0e7ce 00e472 00      0   0  1
  [23] .debug_pubtypes   PROGBITS        00000000 a1cc40 061f78 00      0   0  1
  [24] .debug_ranges     PROGBITS        00000000 a7ebb8 0060e8 00      0   0  1
  [25] .shstrtab         STRTAB          00000000 a84ca0 0000fe 00      0   0  1
  [26] .symtab           SYMTAB          00000000 a85200 034710 10     27 7115  4
  [27] .strtab           STRTAB          00000000 ab9910 03845b 00      0   0  1
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings)
  I (info), L (link order), G (group), x (unknown)
  O (extra OS processing required) o (OS specific), p (processor specific)




259129 00065e34 <app_ioctl>:
259130
259131 #include "module/app_ioctl.h"
259132 //#include "module/app_ca_manager.h"
259133
259134 status_t app_ioctl(uint32_t id, uint32_t cmd, void * params)
259135 {
259136    65e34:?  25f0      ? subi?   r0, r0, 32
259137    65e36:?  9f60      ? st? r15, (r0, 24)
259138    65e38:?  9870      ? st? r8, (r0, 28)
259139    65e3a:?  1208      ? mov?r8, r0
259140    65e3c:?  9228      ? st? r2, (r8, 8)
259141    65e3e:?  9338      ? st? r3, (r8, 12)
259142    65e40:?  9448      ? st? r4, (r8, 16)
259143     status_t ret = GXCORE_ERROR;
259144    65e42:?  2c07      ? bmaski? r7, 0
259145    65e44:?  9708      ? st? r7, (r8, 0)
259146     switch (cmd & (~0xff))
259147    65e46:?  8738      ? ld? r7, (r8, 12)
259148    65e48:?  2c86      ? bmaski? r6, 8
259149    65e4a:?  1f67      ? andn?   r7, r7, r6
259150    65e4c:?  2a07      ? cmpnei? r7, 0
259151    65e4e:?  e006      ? bt? 0x65e5c
259152     {
259153         case APP_FRONTEND_BASE:
259154             ret = nim_ioctl(id, cmd, params);


注意:hb 的个数有限制,即使disable的话,也可能会不响应下一个

 aa

gdb调试高级用法