@@ -30,7 +30,7 @@ class WinsockInitialization : boost::noncopyable
30
30
public:
31
31
explicit WinsockInitialization (int major = 2 , int minor = 2 )
32
32
{
33
- WSADATA wsaData = { 0 };
33
+ WSADATA wsaData = {0 };
34
34
int rc = WSAStartup (MAKEWORD (major, minor), &wsaData);
35
35
if (rc != 0 )
36
36
ThrowWin32Error (rc, " WSAStartup" );
@@ -59,7 +59,7 @@ void DbgMsgSrc(double freq)
59
59
for (;;)
60
60
{
61
61
Sleep (10 );
62
- while (count < (GetTickCount () - t0)* msgPerTick)
62
+ while (count < (GetTickCount () - t0) * msgPerTick)
63
63
{
64
64
if (count % 10 == 0 )
65
65
cdbg << " Een, twee, drie, vier, vijf, zes, zeven, acht, negen, tien, elf, twaalf, dertien, veertien, vijftien, zestien, zeventien, achttien, negentien, twintig, eenentwintig, tweeentwintig, drieentwintig, vierentwintig, vijfentwintig, zesentwintig, zevenentwintig, achtentwintig, negenentwintig, dertig.\n " ;
@@ -135,16 +135,16 @@ void DbgMsgClearTest()
135
135
char buffer[200 ];
136
136
137
137
int line = 1 ;
138
- for (int i= 0 ; i< 400 ; ++i)
138
+ for (int i = 0 ; i < 400 ; ++i)
139
139
{
140
140
sprintf_s (buffer, " Message %d" , line);
141
141
OutputDebugStringA (buffer);
142
142
++line;
143
143
}
144
-
144
+
145
145
OutputDebugStringA (" ----> DBGVIEWCLEAR\n " );
146
146
147
- for (int i= 0 ; i< 10 ; ++i)
147
+ for (int i = 0 ; i < 10 ; ++i)
148
148
{
149
149
sprintf_s (buffer, " Message %d" , line);
150
150
OutputDebugStringA (buffer);
@@ -170,8 +170,8 @@ void testLongString()
170
170
ss << " X" ;
171
171
172
172
ss << " \n " ;
173
- test = ss.str ();
174
-
173
+ test = ss.str ();
174
+
175
175
OutputDebugStringA (test.c_str ());
176
176
}
177
177
@@ -212,7 +212,7 @@ void Output(const std::string& filename)
212
212
213
213
void EndlessTest ()
214
214
{
215
- int length = 40 ; // 260
215
+ int length = 40 ; // 260
216
216
std::ostringstream ss;
217
217
ss << " 123456:jan-7890_ABC__DEF-te m_test" ;
218
218
ss << length;
@@ -263,7 +263,7 @@ void SeparateProcessTest()
263
263
264
264
void CoutCerrTest ()
265
265
{
266
- for (int i= 1 ; i <= 5 ; ++i)
266
+ for (int i = 1 ; i <= 5 ; ++i)
267
267
{
268
268
std::cout << " ========= cycle " << i << " /5 ========\n " ;
269
269
std::cout << " Message on cout 1\n " ;
@@ -310,31 +310,30 @@ void CoutCerrTest2()
310
310
311
311
void PrintUsage ()
312
312
{
313
- std::cout <<
314
- " Usage: DbgMsgSrc <opt>\n "
315
- " \n "
316
- " -1 read 'titan_crash_debugview_43mb.log' and output it through OutputDebugStringA\n "
317
- " -2 <filename> read <filename> and output it through OutputDebugStringA\n "
318
- " -3 run endless test\n "
319
- " -s run -n repeatedly (10x / second) in separate processes)\n "
320
- " -w Send OutputDebugStringA 'WithoutNewLine'\n "
321
- " -n Send OutputDebugStringA 'WithNewLine\\ n'\n "
322
- " -e Send empty OutputDebugStringA message (does not trigger DBwinMutex!)\n "
323
- // about -4:
324
- // we cannot guarantee what happens if 1x OutputDebugStringA is send
325
- // the process might already be gone be time we handle the message
326
- // however, if 2 messages are send, the process is guarenteed to be alive
327
- // at least after receiving the first message but before setting the m_dbWinBufferReady flag..
328
- // (because before setting the flag the traced process is still waiting for the flag)
329
- // this means sending 2 messages and dieing ASAP afterwards is the worst-case we can still handle reliablely.
330
- " -4 Send 2x OutputDebugStringA 'WithNewLine\\ n' (process handle cache test)\n "
331
- " -5 Send OutputDebugStringA '1\\ n2\\ n3\\ n'\n "
332
- " -6 Send OutputDebugStringA '1 ' '2 ' '3\\ n' in separate messages\n "
333
- " -7 DbgMsgTest, sends 5 different test lines, using different newlines styles\n "
334
- " -8 <frequency> DbgMsgSrc, Send OutputDebugStringA test lines with the specified frequency\n "
335
- " -9 DBGVIEWCLEAR test\n "
336
- " -A cout/cerr test\n "
337
- " -u <address> <port> Send UDP messsages to address:port\n " ;
313
+ std::cout << " Usage: DbgMsgSrc <opt>\n "
314
+ " \n "
315
+ " -1 read 'titan_crash_debugview_43mb.log' and output it through OutputDebugStringA\n "
316
+ " -2 <filename> read <filename> and output it through OutputDebugStringA\n "
317
+ " -3 run endless test\n "
318
+ " -s run -n repeatedly (10x / second) in separate processes)\n "
319
+ " -w Send OutputDebugStringA 'WithoutNewLine'\n "
320
+ " -n Send OutputDebugStringA 'WithNewLine\\ n'\n "
321
+ " -e Send empty OutputDebugStringA message (does not trigger DBwinMutex!)\n "
322
+ // about -4:
323
+ // we cannot guarantee what happens if 1x OutputDebugStringA is send
324
+ // the process might already be gone be time we handle the message
325
+ // however, if 2 messages are send, the process is guarenteed to be alive
326
+ // at least after receiving the first message but before setting the m_dbWinBufferReady flag..
327
+ // (because before setting the flag the traced process is still waiting for the flag)
328
+ // this means sending 2 messages and dieing ASAP afterwards is the worst-case we can still handle reliablely.
329
+ " -4 Send 2x OutputDebugStringA 'WithNewLine\\ n' (process handle cache test)\n "
330
+ " -5 Send OutputDebugStringA '1\\ n2\\ n3\\ n'\n "
331
+ " -6 Send OutputDebugStringA '1 ' '2 ' '3\\ n' in separate messages\n "
332
+ " -7 DbgMsgTest, sends 5 different test lines, using different newlines styles\n "
333
+ " -8 <frequency> DbgMsgSrc, Send OutputDebugStringA test lines with the specified frequency\n "
334
+ " -9 DBGVIEWCLEAR test\n "
335
+ " -A cout/cerr test\n "
336
+ " -u <address> <port> Send UDP messsages to address:port\n " ;
338
337
}
339
338
340
339
int Main (int argc, char * argv[])
@@ -346,122 +345,129 @@ int Main(int argc, char* argv[])
346
345
// HANDLE handle3 = ::OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, GetCurrentProcessId());
347
346
// printf(" %p, %p, %p\n", handle1, handle2, handle3);
348
347
349
- int i = 0 ;
350
- std::string arg (argv[i]);
351
- if (arg == " -1" )
352
- {
353
- Output (" titan_crash_debugview_43mb.log" );
354
- return 0 ;
355
- }
356
- else if (arg == " -2" )
348
+ for (int i = 1 ; i < argc; ++i)
357
349
{
358
- if (i + 1 < argc)
350
+ std::string arg (argv[i]);
351
+ if (arg == " -1" )
359
352
{
360
- Output (argv[i + 1 ]);
353
+ Output (" titan_crash_debugview_43mb.log" );
354
+ return 0 ;
361
355
}
362
- else
356
+ else if (arg == " -2 " )
363
357
{
364
- PrintUsage ();
365
- return -1 ;
358
+ if (i + 1 < argc)
359
+ {
360
+ Output (argv[i + 1 ]);
361
+ }
362
+ else
363
+ {
364
+ PrintUsage ();
365
+ return -1 ;
366
+ }
367
+ return 0 ;
366
368
}
367
- return 0 ;
368
- }
369
- else if (arg == " -3" )
370
- {
371
- EndlessTest ();
372
- return 0 ;
373
- }
374
- else if (arg == " -s" ) // run separate process test
375
- {
376
- SeparateProcessTest ();
377
- return 0 ;
378
- }
379
- else if (arg == " -w" )
380
- {
381
- std::cout << " Send OutputDebugStringA 'WithoutNewLine ' (15 bytes)\n " ;
382
- OutputDebugStringA (" WithoutNewLine " );
383
- return 0 ;
384
- }
385
- else if (arg == " -n" )
386
- {
387
- std::cout << " Send OutputDebugStringA 'With-a-NewLine \\ n' (16 bytes)\n " ;
388
- OutputDebugStringA (" With-a-NewLine \n " );
389
- return 0 ;
390
- }
391
- else if (arg == " -e" )
392
- {
393
- std::cout << " Send empty OutputDebugStringA message (0 bytes)\n " ;
394
- OutputDebugStringA (" " ); // empty message
395
- return 0 ;
396
- }
397
- else if (arg == " -4" )
398
- {
399
- std::cout << " Send 2x OutputDebugStringA 'WithNewLine\\ n (24 bytes)'\n " ;
400
- OutputDebugStringA (" WithNewLine\n " );
401
- OutputDebugStringA (" WithNewLine\n " );
402
- return 0 ;
403
- }
404
- else if (arg == " -5" )
405
- {
406
- std::cout << " Send OutputDebugStringA '1\\ n2\\ n3\\ n' (6 bytes)\n " ;
407
- OutputDebugStringA (" 1\n 2\n 3\n " );
408
- return 0 ;
409
- }
410
- else if (arg == " -6" )
411
- {
412
- std::cout << " Send OutputDebugStringA '1 ' '2 ' '3\\ n' in separate messages (6 bytes)\n " ;
413
- OutputDebugStringA (" 1 " );
414
- OutputDebugStringA (" 2 " );
415
- OutputDebugStringA (" 3\n " );
416
- return 0 ;
417
- }
418
- else if (arg == " -7" )
419
- {
420
- DbgMsgTest ();
421
- return 7 ;
422
- }
423
- else if (arg == " -8" )
424
- {
425
- if (i + 1 < argc)
369
+ else if (arg == " -3" )
426
370
{
427
- DbgMsgSrc (std::stoi (argv[i + 1 ]));
371
+ EndlessTest ();
372
+ return 0 ;
428
373
}
429
- else
374
+ else if (arg == " -s" ) // run separate process test
375
+ {
376
+ SeparateProcessTest ();
377
+ return 0 ;
378
+ }
379
+ else if (arg == " -w" )
380
+ {
381
+ std::cout << " Send OutputDebugStringA 'WithoutNewLine ' (15 bytes)\n " ;
382
+ OutputDebugStringA (" WithoutNewLine " );
383
+ return 0 ;
384
+ }
385
+ else if (arg == " -n" )
386
+ {
387
+ std::cout << " Send OutputDebugStringA 'With-a-NewLine \\ n' (16 bytes)\n " ;
388
+ OutputDebugStringA (" With-a-NewLine \n " );
389
+ return 0 ;
390
+ }
391
+ else if (arg == " -e" )
392
+ {
393
+ std::cout << " Send empty OutputDebugStringA message (0 bytes)\n " ;
394
+ OutputDebugStringA (" " ); // empty message
395
+ return 0 ;
396
+ }
397
+ else if (arg == " -4" )
398
+ {
399
+ std::cout << " Send 2x OutputDebugStringA 'WithNewLine\\ n (24 bytes)'\n " ;
400
+ OutputDebugStringA (" WithNewLine\n " );
401
+ OutputDebugStringA (" WithNewLine\n " );
402
+ return 0 ;
403
+ }
404
+ else if (arg == " -5" )
405
+ {
406
+ std::cout << " Send OutputDebugStringA '1\\ n2\\ n3\\ n' (6 bytes)\n " ;
407
+ OutputDebugStringA (" 1\n 2\n 3\n " );
408
+ return 0 ;
409
+ }
410
+ else if (arg == " -6" )
411
+ {
412
+ std::cout << " Send OutputDebugStringA '1 ' '2 ' '3\\ n' in separate messages (6 bytes)\n " ;
413
+ OutputDebugStringA (" 1 " );
414
+ OutputDebugStringA (" 2 " );
415
+ OutputDebugStringA (" 3\n " );
416
+ return 0 ;
417
+ }
418
+ else if (arg == " -7" )
419
+ {
420
+ DbgMsgTest ();
421
+ return 7 ;
422
+ }
423
+ else if (arg == " -8" )
424
+ {
425
+ if (i + 1 < argc)
426
+ {
427
+ DbgMsgSrc (std::stoi (argv[i + 1 ]));
428
+ }
429
+ else
430
+ {
431
+ PrintUsage ();
432
+ return -1 ;
433
+ }
434
+ return 0 ;
435
+ }
436
+ else if (arg == " -9" )
437
+ {
438
+ DbgMsgClearTest ();
439
+ return 0 ;
440
+ }
441
+ else if (arg == " -A" )
442
+ {
443
+ CoutCerrTest ();
444
+ return 0 ;
445
+ }
446
+ else if (arg == " -u" )
430
447
{
448
+ if (i + 2 < argc)
449
+ {
450
+ UdpTest (argv[i + 1 ], std::stoi (argv[i + 2 ]));
451
+ return 0 ;
452
+ }
431
453
PrintUsage ();
432
454
return -1 ;
433
455
}
434
- return 0 ;
435
- }
436
- else if (arg == " -9" )
437
- {
438
- DbgMsgClearTest ();
439
- return 0 ;
440
- }
441
- else if (arg == " -A" )
442
- {
443
- CoutCerrTest ();
444
- return 0 ;
445
- }
446
- else if (arg == " -u" )
447
- {
448
- if (i + 2 < argc)
456
+ else if (arg == " -B" )
449
457
{
450
- UdpTest (argv[i + 1 ], std::stoi (argv[i + 2 ]));
458
+ CoutCerrTest2 ();
459
+ return 0 ;
460
+ }
461
+ else if (arg == " -C" )
462
+ {
463
+ SocketTest ();
464
+ return 0 ;
465
+ }
466
+ else
467
+ {
468
+ Output (arg);
451
469
return 0 ;
452
470
}
453
- PrintUsage ();
454
- return -1 ;
455
- }
456
- else if (arg == " -B" )
457
- {
458
- CoutCerrTest2 ();
459
- return 0 ;
460
- }
461
- else if (arg == " -C" )
462
- {
463
- SocketTest ();
464
- return 0 ;
465
471
}
466
472
PrintUsage ();
467
473
return EXIT_SUCCESS;
@@ -470,8 +476,7 @@ int Main(int argc, char* argv[])
470
476
} // namespace DbgMsgSrc
471
477
} // namespace fusion
472
478
473
- int main (int argc, char * argv[])
474
- try
479
+ int main (int argc, char * argv[]) try
475
480
{
476
481
return fusion::DbgMsgSrc::Main (argc, argv);
477
482
}
0 commit comments