| 23 | * 在看 fbcommon.c 時,發現在這組出現錯誤的 mmap 前曾跑過另一組 mmap, 因此把參數印出來對照看看。 |
| 24 | * gdb debug 程序 |
| 25 | {{{ |
| 26 | file jfbterm |
| 27 | set args -e ls |
| 28 | show args |
| 29 | break fbcommon.c:500 |
| 30 | break fbcommon.c:557 |
| 31 | break fbcommon.c:566 |
| 32 | run |
| 33 | p fb_fix |
| 34 | c |
| 35 | p fb_fix |
| 36 | c |
| 37 | p fb_fix.smem_len |
| 38 | p p->soff |
| 39 | p p->slen |
| 40 | p fb_fix.mmem_len |
| 41 | p p->moff |
| 42 | p p->mlen |
| 43 | }}} |
| 44 | {{{ |
| 45 | This GDB was configured as "x86_64-linux-gnu". |
| 46 | (gdb) file jfbterm |
| 47 | Reading symbols from /root/jfbterm-0.4.7-dev/jfbterm...done. |
| 48 | (gdb) set args -e ls |
| 49 | (gdb) show args |
| 50 | Argument list to give program being debugged when it is started is "-e ls". |
| 51 | (gdb) break fbcommon.c:500 |
| 52 | Breakpoint 1 at 0x40303d: file fbcommon.c, line 500. |
| 53 | (gdb) break fbcommon.c:557 |
| 54 | Breakpoint 2 at 0x40327e: file fbcommon.c, line 557. |
| 55 | (gdb) break fbcommon.c:566 |
| 56 | Breakpoint 3 at 0x403301: file fbcommon.c, line 566. |
| 57 | (gdb) run |
| 58 | Starting program: /root/jfbterm-0.4.7-dev/jfbterm -e ls |
| 59 | Breakpoint 1, tfbm_open (p=0x6146e0) at fbcommon.c:501 |
| 60 | 501 if (fb_var.yres_virtual != fb_var.yres) { |
| 61 | (gdb) p fb_fix |
| 62 | $1 = {id = "▒▒C▒\210\177\000\000\006\000\000\000\000\000\000", smem_start = 30778096, smem_len = 3032756978, type = 32648, type_aux = 0, visual = 0, |
| 63 | xpanstep = 65535, ypanstep = 65535, ywrapstep = 65535, line_length = 1, mmio_start = 15, mmio_len = 30816528, accel = 0, reserved = {53071, 64, 0}} |
| 64 | (gdb) c |
| 65 | Continuing. |
| 66 | Breakpoint 2, tfbm_open (p=0x6146e0) at fbcommon.c:557 |
| 67 | 557 p->smem = (u_char*)mmap(NULL, p->slen, PROT_READ|PROT_WRITE, |
| 68 | (gdb) p fb_fix |
| 69 | $2 = {id = "VESA VGA\000\000\000\000\000\000\000", smem_start = 4026531840, smem_len = 1572864, type = 0, type_aux = 0, visual = 3, xpanstep = 0, |
| 70 | ypanstep = 0, ywrapstep = 0, line_length = 1024, mmio_start = 0, mmio_len = 0, accel = 0, reserved = {0, 0, 0}} |
| 71 | (gdb) c |
| 72 | Continuing. |
| 73 | |
| 74 | Breakpoint 3, tfbm_open (p=0x6146e0) at fbcommon.c:566 |
| 75 | 566 if(p->mlen == 0) |
| 76 | (gdb) p fb_fix.smem_len |
| 77 | $3 = 1572864 |
| 78 | (gdb) p p->soff |
| 79 | $4 = 0 |
| 80 | (gdb) p p->slen |
| 81 | $5 = 1572864 |
| 82 | (gdb) p fb_fix.mmem_len |
| 83 | There is no member named mmem_len. |
| 84 | (gdb) p p->moff |
| 85 | $6 = 0 |
| 86 | (gdb) p p->mlen |
| 87 | $7 = 0 |
| 88 | (gdb) |
| 89 | }}} |