home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / gdb-4.9 / gdb / testsuite / gdb.t07 / gdbme.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-05-12  |  1.6 KB  |  53 lines

  1. /*
  2.  *    Since using watchpoints can be very slow, we have to take some pains to
  3.  *    ensure that we don't run too long with them enabled or we run the risk
  4.  *    of having the test timeout.  To help avoid this, we insert some marker
  5.  *    functions in the execution stream so we can set breakpoints at known
  6.  *    locations, without worrying about invalidating line numbers by changing
  7.  *    this file.  We use null bodied functions are markers since gdb does
  8.  *    not support breakpoints at labeled text points at this time.
  9.  *
  10.  *    One place we need is a marker for when we start executing our tests
  11.  *    instructions rather than any process startup code, so we insert one
  12.  *    right after entering main().  Another is right before we finish, before
  13.  *    we start executing any process termination code.
  14.  *
  15.  *    Another problem we have to guard against, at least for the test
  16.  *    suite, is that we need to ensure that the line that causes the
  17.  *    watchpoint to be hit is still the current line when gdb notices
  18.  *    the hit.  Depending upon the specific code generated by the compiler,
  19.  *    the instruction after the one that triggers the hit may be part of
  20.  *    the same line or part of the next line.  Thus we ensure that there
  21.  *    are always some instructions to execute on the same line after the
  22.  *    code that should trigger the hit.
  23.  */
  24.  
  25. int count = -1;
  26. int ival1 = -1;
  27. int ival2 = -1;
  28. int ival3 = -1;
  29. int ival4 = -1;
  30.  
  31. void marker1 ()
  32. {
  33. }
  34.  
  35. void marker2 ()
  36. {
  37. }
  38.  
  39. int main ()
  40. {
  41.   marker1 ();
  42.   for (count = 0; count < 4; count++) {
  43.     ival1 = count;
  44.     ival2 = count;
  45.     ival3 = count; ival4 = count;
  46.   }
  47.   ival1 = count;
  48.   ival2 = count;
  49.   ival3 = count; ival4 = count;
  50.   marker2 ();
  51.   return 0;
  52. }
  53.