Sining's profileSining的共享空间PhotosBlogListsMore ![]() | Help |
|
Sining的共享空间April 21 Using Printf Notes unsigned __int64 u64 = 1; u64 = u64 << 63; cout << u64 << endl; printf("%I64u", u64 ); //right printf("%I64d", u64 ); //wrong April 04 STL File Stream Limitation Scenario: You make a data file which contains variable length records, and use another file to index from records' key hash to position in data file for random access. Problem: When the data file's size is larger than 2GB, ofstream.tellp() and ifstream.seekg() works wrong. Detail (in 64-bit version): When the file's size is between 2^31 to 2^32 , ofstream.tellp() give a negative number. When the file's size is larger than 2^32, ofstream.tellp() give only lower 32(or may be 31) bits number. When the file's size is larger than 2^32, ifstream.seekg() causes the ifstream invalid. Solution: Directly use WINAPI: CreateFile, WriteFile, ReadFile. Active Debug Scenario: We have to use a binary executable tool, but it crashes on some input files. We can: 1. Remove the input file which causes the tool crash 2. Remove the input files which are processed 3. Restart the tool Problem: When crashes the tool pop up a Just-In-Time Debugger window. We have to manually close the window and find the problematic input file in its console output. Analysis: A program without debugger will forward the unhandled exception to JIT Debugger. We can make a special "debugger" which terminates the tool program when it sees a second chance exception. As to the file name in console output, we can use command line redirection to save the file name. And make a special input file remover program to remove the files with names listed in the tool program's console output. Notes for Implementation: EnumProcesses: list processes PID OpenProcess: PID->Process Handle EnumProcessModules: get process' .exe name DebugActiveProcess: as a debugger, attach to another process Exception + FirstChance: return DBG_EXCEPTION_NOT_HANDLED Exception + SecondChance: TerminateProcess March 26 What Is A Thread?What
Is A Thread?
1. When the thread encounter exception/interruption, its spirit is
separated from its flesh. Flesh
includes stack & context data |
|
||||||
|
|