Home > Software engineering >  VS2015 debugging pop-up dialog of invalid pointer
VS2015 debugging pop-up dialog of invalid pointer

Time:09-26

Just install VS2015 automatically generated dialog programming successful CTRL + F5 can run F5 will pop up an invalid pointer dialogue, you know why is greatly?

CodePudding user response:

Collapsed in the pop-up dialog box, press the corresponding button to enter debugging press Alt + 7 key to view the Call Stack, namely "the Call Stack" from the inside to the following out of from the inner to outer function Call history, double-click a row to the cursor to the Call of the source code or assembly instruction, don't understand when double click on the next line, until we can read ,

CodePudding user response:

reference 1st floor zhao4zhong1 response:
collapsed in the pop-up dialog box, press the corresponding button to enter debugging press Alt + 7 view the Call Stack that is "the Call Stack" from the inside to the following out of from the inner to outer function Call history, double-click a row to the cursor to the Call of the source code or assembly instruction, don't understand, until can read ,


Miss zhao, this paragraph is abridged version

CodePudding user response:

Sometimes not to "call a function name + each parameter value, after entering the function of each parameter values, intermediate variable values, exit the function return value of preparation, return to the function to call after the function value of the parameter name + + return value" this information to write logs to a file is where no matter how to also can not find the problem, including capture all kinds of abnormal, writing log to the screen and single step or set a breakpoint or generating core or DMP file,... These methods are not! Write logs to a file reference below:
 # include & lt; Stdio. H> 
# include & lt; Stdlib. H>
# include & lt; String. H>
# ifdef _MSC_VER
# pragma warning (4996) disable:
# include & lt; Windows. H>
# include & lt; IO. H>
# the else
# include & lt; Unistd. H>
# include & lt; Sys/time. H>
# include & lt; Pthread. H>
# define CRITICAL_SECTION pthread_mutex_t
# define _vsnprintf vsnprintf
# endif
//the Log {
# define MAXLOGSIZE 20000000
# define MAXLINSIZE 16000
# include & lt; Time. H>
# include & lt; Sys/timeb. H>
# include & lt; Stdarg. H>
Char logfilename1 []="MyLog1. Log";
Char logfilename2 []="MyLog2. Log";
The static char logstr [MAXLINSIZE + 1];
Char datestr [16].
Char timestr [16].
Char MSS [4].
CRITICAL_SECTION cs_log;
The FILE * flog;
# ifdef _MSC_VER
The Lock (CRITICAL_SECTION void * l) {
The EnterCriticalSection (l);
}
Void Unlock (CRITICAL_SECTION * l) {
LeaveCriticalSection (l);
}
# the else
The Lock (CRITICAL_SECTION void * 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 (& amp; TB);
Now=localtime (& amp; TB. Time);
Sprintf (datestr, "% d % % 4 d - 02-02 d", now - & gt; Tm_year + 1900, now - & gt; Tm_mon + 1, now - & gt; Tm_mday);
Sprintf (timestr, "02 02 02 % d: % d: % d", now - & gt; Tm_hour, now - & gt; Tm_min, now - & gt; Tm_sec);
Sprintf (MSS, "% 3 d", 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) & gt; MAXLOGSIZE) {
The fclose (flog);
If (rename (logfilename1 logfilename2)) {
Remove (logfilename2);
Rename (logfilename1 logfilename2);
}
} else {
The fclose (flog);
}
}
}
Void the Log (const char * pszFmt,... ) {
Va_list argp;

The Lock (& amp; Cs_log);
Va_start (argp, pszFmt);
LogV (pszFmt argp);
Va_end (argp);
Unlock (& amp; Cs_log);
}
//the Log}
Int main (int arg c, char * argv []) {
int i;
# ifdef _MSC_VER
InitializeCriticalSection (& amp; Cs_log);
# the else
Pthread_mutex_init (& amp; Cs_log, NULL);
# endif
for (i=0; i<10000; I++) {
The Log (" This is a Log % 4 d the from FILE: % s LINE: % d \ n ", I, a __FILE__ and __LINE__);
}
# ifdef _MSC_VER
DeleteCriticalSection (& amp; Cs_log);
# the else
Pthread_mutex_destroy (& amp; Cs_log);
# endif
return 0;
}
//1. With the main - 79 line to add to your c or. The front of the CPP file that
//the main function of 81-86 line to add to your opening
//90-94 before the end of the line to add to your main function
//where to write the LOG modeled on line 88 write to write the LOG to file MyLog1.
in the LOG

CodePudding user response:

reference 1st floor zhao4zhong1 response:
collapsed in the pop-up dialog box, press the corresponding button to enter debugging press Alt + 7 view the Call Stack that is "the Call Stack" from the inside to the following out of from the inner to outer function Call history, double-click a row to the cursor to the Call of the source code or assembly instruction, don't understand, until can read ,


F5 and Ctrl + F5 to run the current path is different, if use path related code needs to pay attention to

CodePudding user response:

Zgl7903
reference 4 floor response:
Quote: refer to 1st floor zhao4zhong1 response:

Collapsed in the pop-up dialog box, press the corresponding button to enter debugging press Alt + 7 key to view the Call Stack, namely "the Call Stack" from the inside to the following out of from the inner to outer function Call history, double-click a row to the cursor to the Call of the source code or assembly instruction, don't understand, until can read ,


F5 and Ctrl + F5 to run the current path is different, if use path related code needs to pay attention to


Project, properties, configuration properties, debugging, the working directory,

CodePudding user response:

The landlord to solve ah, help

CodePudding user response:

I have already solved, the building Lord m I if you don't have to solve

CodePudding user response:

nullnullnullnullnullnullnullnullnullnullnullnull
  • Related