您的位置:首页 > 编程语言

分享如何快速定位代码在哪里崩掉了(bochs+NASM汇编)

2013-04-18 21:24 791 查看
调试汇编代码是一场艰辛晦涩的旅程,幸好有bochs,幸好有各种提示信息,为这场旅行带来了一丝的光明:今天分分享如何快速定位代码在哪里崩掉了:

<bochs:27> u /10
00007cb3: (                    ): mov ebx, 0x00040000       ; bb00000400
00007cb8: (                    ): mov di, 0x0000            ; 66bf0000
00007cbc: (                    ): mov si, 0x0001            ; 66be0100
00007cc0: (                    ): call .+154                ; e89a000000
00007cc5: (                    ): mov eax, dword ptr ds:[ebx] ; 8b03
00007cc7: (                    ): mov ecx, 0x00000200       ; b900020000
00007ccc: (                    ): div eax, ecx              ; f7f1
00007cce: (                    ): mov ecx, eax              ; 89c1
00007cd0: (                    ): cmp eax, 0x00000000       ; 83f800
00007cd3: (                    ): jz .+29                   ; 741d
<bochs:28> b 0x7cc5
<bochs:29> c
00035650269e[CPU0 ] stackPrefetch(4): access [0x0000fffc] > SS.limit [0x00008000]
00035650269e[CPU0 ] fetch_raw_descriptor: GDT: index (f007) 1e00 > limit (27)
00035650269e[CPU0 ] interrupt(): gate descriptor is not valid sys seg (vector=0x08)
00035650269i[CPU0 ] CPU is in protected mode (active)
00035650269i[CPU0 ] CS.mode = 32 bit
00035650269i[CPU0 ] SS.mode = 16 bit
00035650269i[CPU0 ] EFER   = 0x00000000
00035650269i[CPU0 ] | EAX=00000020  EBX=00040000  ECX=00098000  EDX=00000000
00035650269i[CPU0 ] | ESP=00000000  EBP=00000000  ESI=000e0001  EDI=00000000
00035650269i[CPU0 ] | IOPL=0 id vip vif ac vm RF nt of df if tf sf ZF af PF cf
00035650269i[CPU0 ] | SEG sltr(index|ti|rpl)     base    limit G D
00035650269i[CPU0 ] |  CS:0010( 0002| 0|  0) 00007c00 00000200 0 1
00035650269i[CPU0 ] |  DS:0008( 0001| 0|  0) 00000000 ffffffff 1 1
00035650269i[CPU0 ] |  SS:0020( 0004| 0|  0) 000b8000 00008000 0 0
00035650269i[CPU0 ] |  ES:0000( 0005| 0|  0) 00000000 0000ffff 0 0
00035650269i[CPU0 ] |  FS:0000( 0005| 0|  0) 00000000 0000ffff 0 0
00035650269i[CPU0 ] |  GS:0000( 0005| 0|  0) 00000000 0000ffff 0 0
00035650269i[CPU0 ] | EIP=000000c0 (000000c0)  《--------ip指针是代码段内的偏移:  0x7c00 + 0x00c0 = 0x7cc0
00035650269i[CPU0 ] | CR0=0x60000011 CR2=0x00000000
00035650269i[CPU0 ] | CR3=0x00000000 CR4=0x00000000
(0).[35650269] [0x0000000000007cc0] 0010:00000000000000c0 (unk. ctxt): call .+154 (0x00007d5f)   ; e89a00  <---这里也具体的描述了崩掉的信息,跳转到0x7df5挂了
00035650269e[CPU0 ] exception(): 3rd (13) exception with no resolution, shutdown status is 00h, resetting
00035650269i[SYS  ] bx_pc_system_c::Reset(HARDWARE) called
00035650269i[CPU0 ] cpu hardware reset
00035650269i[APIC0] allocate APIC id=0 (MMIO enabled) to 0x00000000fee00000
00035650269i[CPU0 ] CPUID[0x00000000]: 00000002 756e6547 6c65746e 49656e69
00035650269i[CPU0 ] CPUID[0x00000001]: 00000633 00010800 00002008 1fcbfbff
00035650269i[CPU0 ] CPUID[0x00000002]: 00410601 00000000 00000000 00000000
00035650269i[CPU0 ] CPUID[0x80000000]: 80000008 00000000 00000000 00000000
00035650269i[CPU0 ] CPUID[0x80000001]: 00000000 00000000 00000101 2a100000
00035650269i[CPU0 ] CPUID[0x80000002]: 20202020 20202020 20202020 6e492020
00035650269i[CPU0 ] CPUID[0x80000003]: 286c6574 50202952 69746e65 52286d75
00035650269i[CPU0 ] CPUID[0x80000004]: 20342029 20555043 20202020 00202020
00035650269i[CPU0 ] CPUID[0x80000005]: 01ff01ff 01ff01ff 40020140 40020140
00035650269i[CPU0 ] CPUID[0x80000006]: 00000000 42004200 02008140 00000000
00035650269i[CPU0 ] CPUID[0x80000007]: 00000000 00000000 00000000 00000000
00035650269i[CPU0 ] CPUID[0x80000008]: 00003028 00000000 00000000 00000000
00035650269i[     ] reset of 'pci' plugin device by virtual method
00035650269i[     ] reset of 'pci2isa' plugin device by virtual method
00035650269i[     ] reset of 'cmos' plugin device by virtual method
00035650269i[     ] reset of 'dma' plugin device by virtual method
00035650269i[     ] reset of 'pic' plugin device by virtual method
00035650269i[     ] reset of 'pit' plugin device by virtual method
00035650269i[     ] reset of 'floppy' plugin device by virtual method
00035650269i[     ] reset of 'vga' plugin device by virtual method
00035650269i[     ] reset of 'acpi' plugin device by virtual method
00035650269i[     ] reset of 'ioapic' plugin device by virtual method
00035650269i[     ] reset of 'keyboard' plugin device by virtual method
00035650269i[     ] reset of 'harddrv' plugin device by virtual method
00035650269i[     ] reset of 'pci_ide' plugin device by virtual method
00035650269i[     ] reset of 'unmapped' plugin device by virtual method
00035650269i[     ] reset of 'biosdev' plugin device by virtual method
00035650269i[     ] reset of 'speaker' plugin device by virtual method
00035650269i[     ] reset of 'extfpuirq' plugin device by virtual method
00035650269i[     ] reset of 'parallel' plugin device by virtual method
00035650269i[     ] reset of 'serial' plugin device by virtual method
00035650269i[     ] reset of 'gameport' plugin device by virtual method
00035650269i[     ] reset of 'iodebug' plugin device by virtual method
Next at t=35650270
(0) [0x00000000fffffff0] f000:fff0 (unk. ctxt): jmp far f000:e05b         ; ea5be000f0
<bochs:30>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: