WEB开发网
开发学院软件开发VC 对“仅通过崩溃地址找出源代码的出错行”一文的补... 阅读

对“仅通过崩溃地址找出源代码的出错行”一文的补充与改进

 2010-07-20 20:46:12 来源:WEB开发网   
核心提示:排错步骤1)定位崩溃函数,可以查询map文件获得,对“仅通过崩溃地址找出源代码的出错行”一文的补充与改进(4),我的机器编译产生的map文件的部分如下:CrashTimestamp is 42881a01 (Mon May 16 11:56:49 2005)Preferred load address is 00400

排错步骤1)定位崩溃函数。可以查询map文件获得。我的机器编译产生的map文件的部分如下:

Crash
Timestamp is 42881a01 (Mon May 16 11:56:49 2005)
Preferred load address is 00400000
Start Length Name Class
0001:00000000 0000ddf1H .text CODE
0001:0000ddf1 0001000fH .textbss CODE
0002:00000000 00001346H .rdata DATA
0002:00001346 00000000H .edata DATA
0003:00000000 00000104H .CRT$XCA DATA
0003:00000104 00000104H .CRT$XCZ DATA
0003:00000208 00000104H .CRT$XIA DATA
0003:0000030c 00000109H .CRT$XIC DATA
0003:00000418 00000104H .CRT$XIZ DATA
0003:0000051c 00000104H .CRT$XPA DATA
0003:00000620 00000104H .CRT$XPX DATA
0003:00000724 00000104H .CRT$XPZ DATA
0003:00000828 00000104H .CRT$XTA DATA
0003:0000092c 00000104H .CRT$XTZ DATA
0003:00000a30 00000b93H .data DATA
0003:000015c4 00001974H .bss DATA
0004:00000000 00000014H .idata$2 DATA
0004:00000014 00000014H .idata$3 DATA
0004:00000028 00000110H .idata$4 DATA
0004:00000138 00000110H .idata$5 DATA
0004:00000248 000004afH .idata$6 DATA
Address Publics by Value Rva+Base Lib:Object
0001:00000020 _main 00401020 f Crash.obj
0001:00000060 ?Crash1@@YAXXZ 00401060 f Crash.obj
0001:000000a0 __chkesp 004010a0 f LIBCD:chkesp.obj
0001:000000e0 _mainCRTStartup 004010e0 f LIBCD:crt0.obj
0001:00000210 __amsg_exit 00401210 f LIBCD:crt0.obj
0001:00000270 __CrtDbgBreak 00401270 f LIBCD:dbgrpt.obj
...

对于崩溃地址0x00401082而言,小于此地址中最接近的地址(Rva+Base中的地址)为00401060,其对应的函数名为?Crash1@@YAXXZ,由于所有以问号开头的函数名称都是 C++ 修饰的名称 ,"@@YAXXZ"则为区别重载函数而加的后缀,所以?Crash1@@YAXXZ就是我们的源程序中,Crash1() 这个函数。

排错步骤2)定位出错行。打开编译生成的"cod"文件,我机器上生成的文件内容如下:

TITLE  E:CrashCrash。cpp
  .386P
include listing.inc
if @Version gt 510
.model FLAT
else
_TEXT  SEGMENT PARA USE32 PUBLIC ''CODE''
_TEXT  ENDS
_DATA  SEGMENT DWORD USE32 PUBLIC ''DATA''
_DATA  ENDS
CONST  SEGMENT DWORD USE32 PUBLIC ''CONST''
CONST  ENDS
_BSS  SEGMENT DWORD USE32 PUBLIC ''BSS''
_BSS  ENDS
$$SYMBOLS  SEGMENT BYTE USE32 ''DEBSYM''
$$SYMBOLS  ENDS
$$TYPES  SEGMENT BYTE USE32 ''DEBTYP''
$$TYPES  ENDS
_TLS  SEGMENT DWORD USE32 PUBLIC ''TLS''
_TLS  ENDS
;  COMDAT _main
_TEXT  SEGMENT PARA USE32 PUBLIC ''CODE''
_TEXT  ENDS
;  COMDAT ?Crash1@@YAXXZ
_TEXT  SEGMENT PARA USE32 PUBLIC ''CODE''
_TEXT  ENDS
FLAT  GROUP _DATA, CONST, _BSS
  ASSUME  CS: FLAT, DS: FLAT, SS: FLAT
endif
PUBLIC  ?Crash1@@YAXXZ          ; Crash1
PUBLIC  _main
EXTRN  __chkesp:NEAR
;  COMDAT _main
_TEXT  SEGMENT
_main  PROC NEAR          ; COMDAT
; 9  : {
 00000  55     push   ebp
 00001  8b ec     mov   ebp, esp
 00003  83 ec 40   sub   esp, 64      ; 00000040H
 00006  53     push   ebx
 00007  56     push   esi
 00008  57     push   edi
 00009  8d 7d c0   lea   edi, DWORD PTR [ebp-64]
 0000c  b9 10 00 00 00   mov   ecx, 16      ; 00000010H
 00011  b8 cc cc cc cc   mov   eax, -858993460    ; ccccccccH
 00016  f3 ab     rep stosd
; 10  :   Crash1();
 00018  e8 00 00 00 00   call   ?Crash1@@YAXXZ    ; Crash1
; 11  :   return 0;
 0001d  33 c0     xor   eax, eax
; 12  : }
 0001f  5f     pop   edi
 00020  5e     pop   esi
 00021  5b     pop   ebx
 00022  83 c4 40   add   esp, 64      ; 00000040H
 00025  3b ec     cmp   ebp, esp
 00027  e8 00 00 00 00   call   __chkesp
 0002c  8b e5     mov   esp, ebp
 0002e  5d     pop   ebp
 0002f  c3     ret   0
_main  ENDP
_TEXT  ENDS
;  COMDAT ?Crash1@@YAXXZ
_TEXT  SEGMENT
_p$ = -4
?Crash1@@YAXXZ PROC NEAR        ; Crash1, COMDAT
; 15  : {
 00000  55     push   ebp
 00001  8b ec     mov   ebp, esp
 00003  83 ec 44   sub   esp, 68      ; 00000044H
 00006  53     push   ebx
 00007  56     push   esi
 00008  57     push   edi
 00009  8d 7d bc   lea   edi, DWORD PTR [ebp-68]
 0000c  b9 11 00 00 00   mov   ecx, 17      ; 00000011H
 00011  b8 cc cc cc cc   mov   eax, -858993460    ; ccccccccH
 00016  f3 ab     rep stosd
; 16  : char * p =(char*)100;
 00018  c7 45 fc 64 00
  00 00     mov   DWORD PTR _p$[ebp], 100  ; 00000064H
; 17  : *p=100;
 0001f  8b 45 fc   mov   eax, DWORD PTR _p$[ebp]
 00022  c6 00 64   mov   BYTE PTR [eax], 100  ; 00000064H
; 18  : }
 00025  5f     pop   edi
 00026  5e     pop   esi
 00027  5b     pop   ebx
 00028  8b e5     mov   esp, ebp
 0002a  5d     pop   ebp
 0002b  c3     ret   0
?Crash1@@YAXXZ ENDP          ; Crash1
_TEXT  ENDS
END

上一页  1 2 3 4 5  下一页

Tags:通过 崩溃 地址

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接