用記事本打開*.cgl 檔案如下
Error 00001. 0x100600 (r) (Thread 0x0D7C):
Access in invalid memory: Attempt to access 4 byte(s) at 0x00000000+772.
Call Tree:
0x0040ADA2(=S61V2.2.13-Debug.exe:0x01:009DA2)
0x0057C996(=S61V2.2.13-Debug.exe:0x01:17B996)
0x00520D7A(=S61V2.2.13-Debug.exe:0x01:11FD7A)
0x77D18734(=user32.dll:0x01:007734)
0x77D18816(=user32.dll:0x01:007816)
0x77D189CD(=user32.dll:0x01:0079CD)
------------------------------------------
比如 0x0040ADA2 和 Debug.exe:0x01:009DA2 表示什么意思?0x01:009DA2 這個地址怎么才能看出來?是否用啥工具要分析EXE嗎?
uj5u.com熱心網友回復:
用了full debug了么,有的話在view->debug window->code guard log看會方便些uj5u.com熱心網友回復:
有時不將“呼叫函式名字+各引數值,進入函式后各引數值,中間變數值,退出函式前準備回傳的值,回傳函式到呼叫處后函式名字+各引數值+回傳值”這些資訊寫日志到檔案中是無論如何也發現不了問題在哪里的,包括捕獲各種例外、寫日志到螢屏、單步或設斷點或生成core檔案、……這些方法都不行! 寫日志到檔案參考下面:#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef WIN32
#include <windows.h>
#include <io.h>
#else
#include <unistd.h>
#include <sys/time.h>
#include <pthread.h>
#define CRITICAL_SECTION pthread_mutex_t
#define _vsnprintf vsnprintf
#endif
//Log{
#define MAXLOGSIZE 20000000
#define MAXLINSIZE 16000
#include <time.h>
#include <sys/timeb.h>
#include <stdarg.h>
char logfilename1[]="MyLog1.log";
char logfilename2[]="MyLog2.log";
static char logstr[MAXLINSIZE+1];
char datestr[16];
char timestr[16];
char mss[4];
CRITICAL_SECTION cs_log;
FILE *flog;
#ifdef WIN32
void Lock(CRITICAL_SECTION *l) {
EnterCriticalSection(l);
}
void Unlock(CRITICAL_SECTION *l) {
LeaveCriticalSection(l);
}
#else
void Lock(CRITICAL_SECTION *l) {
pthread_mutex_lock(l);
}
void Unlock(CRITICAL_SECTION *l) {
pthread_mutex_unlock(l);
}
#endif
void LogV(const char *pszFmt,va_list argp) {
struct tm *now;
struct timeb tb;
if (NULL==pszFmt||0==pszFmt[0]) return;
_vsnprintf(logstr,MAXLINSIZE,pszFmt,argp);
ftime(&tb);
now=localtime(&tb.time);
sprintf(datestr,"%04d-%02d-%02d",now->tm_year+1900,now->tm_mon+1,now->tm_mday);
sprintf(timestr,"%02d:%02d:%02d",now->tm_hour ,now->tm_min ,now->tm_sec );
sprintf(mss,"%03d",tb.millitm);
printf("%s %s.%s %s",datestr,timestr,mss,logstr);
flog=fopen(logfilename1,"a");
if (NULL!=flog) {
fprintf(flog,"%s %s.%s %s",datestr,timestr,mss,logstr);
if (ftell(flog)>MAXLOGSIZE) {
fclose(flog);
if (rename(logfilename1,logfilename2)) {
remove(logfilename2);
rename(logfilename1,logfilename2);
}
} else {
fclose(flog);
}
}
}
void Log(const char *pszFmt,...) {
va_list argp;
Lock(&cs_log);
va_start(argp,pszFmt);
LogV(pszFmt,argp);
va_end(argp);
Unlock(&cs_log);
}
//Log}
int main(int argc,char * argv[]) {
int i;
#ifdef WIN32
InitializeCriticalSection(&cs_log);
#else
pthread_mutex_init(&cs_log,NULL);
#endif
for (i=0;i<10000;i++) {
Log("This is a Log %04d from FILE:%s LINE:%d\n",i, __FILE__, __LINE__);
}
#ifdef WIN32
DeleteCriticalSection(&cs_log);
#else
pthread_mutex_destroy(&cs_log);
#endif
return 0;
}
//1-78行添加到你帶main的.c或.cpp的那個檔案的最前面
//81-85行添加到你的main函式開頭
//89-93行添加到你的main函式結束前
//在要寫LOG的地方仿照第87行的寫法寫LOG到檔案MyLog1.log中
uj5u.com熱心網友回復:
比如 0x0040ADA2 和 Debug.exe:0x01:009DA2 表示什么意思?0x01:009DA2 這個地址怎么才能看出來?是否用啥工具要分析EXE嗎?uj5u.com熱心網友回復:
1)檢查你bcb6是否Debug方式而不是Release方式,如果是Debug編譯,應該可以提示到變數的。2)看來是有個記憶體指標為空指標,造成出錯。
uj5u.com熱心網友回復:
Error 00001. 0x100600 (r) (Thread 0x0D7C):Access in invalid memory: Attempt to access 4 byte(s) at 0x00000000+772.
Call Tree:
0x0040ADA2(=S61V2.2.13-Debug.exe:0x01:009DA2)
0x0057C996(=S61V2.2.13-Debug.exe:0x01:17B996)
0x00520D7A(=S61V2.2.13-Debug.exe:0x01:11FD7A)
0x77D18734(=user32.dll:0x01:007734)
0x77D18816(=user32.dll:0x01:007816)
0x77D189CD(=user32.dll:0x01:0079CD)
像這些十六進制數代表什么意思?如何和原始碼聯系起來?
uj5u.com熱心網友回復:
像這些十六進制數代表什么意思?如何和原始碼聯系起來?uj5u.com熱心網友回復:
Error 00001. 0x100600 (r) (Thread 0x0D7C):Access in invalid memory: Attempt to access 4 byte(s) at 0x00000000+772.
Call Tree:
0x0040ADA2(=S61V2.2.13-Debug.exe:0x01:009DA2)
0x0057C996(=S61V2.2.13-Debug.exe:0x01:17B996)
0x00520D7A(=S61V2.2.13-Debug.exe:0x01:11FD7A)
0x77D18734(=user32.dll:0x01:007734)
0x77D18816(=user32.dll:0x01:007816)
0x77D189CD(=user32.dll:0x01:0079CD)
像這些十六進制數代表什么意思?如何和原始碼聯系起來?
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/93047.html
標籤:基礎類
下一篇:WM_SIZE中加入MessageBox時,為什么會先執行WM_PAINT里的內容,再回來執行MessageBox,為什么會發送WM_PAINT?
