Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
2.1 KiB

  1. //*** dbutil.cpp -- debug helpers
  2. // DESCRIPTION
  3. // this file has the shared-source 'master' implementation. it is
  4. // #included in each DLL that uses it.
  5. // clients do something like:
  6. // #include "priv.h" // for types, ASSERT, DM_*, DF_*, etc.
  7. // #include "../lib/dbutil.cpp"
  8. #ifdef DEBUG // {
  9. #if ( _X86_)
  10. // warning: these macros assume we have an ebp-linked chain. for debug we do.
  11. #define BP_GETOLDBP(pbp) (*((int *)(pbp) + 0))
  12. #define BP_GETRET(pbp) (*((int *)(pbp) + 1))
  13. //*** DBGetStackBack -- walk stack frame
  14. // #if 0 w/ sanity checks #endif
  15. // ENTRY/EXIT
  16. // pfp INOUT ptr to frame ptr (IN:starting, OUT:ending)
  17. // pstkback OUT:fp/ret pairs, IN:optional size/addr pairs for sanity check
  18. // nstkback ARRAYSIZE(pstckback)
  19. // #if 0
  20. // ncheck # of IN pstkback size/addr sanity-check pairs
  21. // #endif
  22. // n (return) # of frames successfully walked
  23. // DESCRIPTION
  24. // fills in OUT pstckback w/ backtrace info for nstckback frames.
  25. // #if 0
  26. // if ncheck > 0, makes sure that initial backtrace entries are in the
  27. // range of the function specified by the IN size/addr pairs in pstkback.
  28. // #endif
  29. // NOTES
  30. // not sure if we return the right pfp' value (untested)
  31. int DBGetStackBack(int *pfp, struct DBstkback *pstkback, int nstkback /*,int nchk*/)
  32. {
  33. int fp = *pfp;
  34. int ret;
  35. int i = 0;
  36. __try {
  37. for (; i < nstkback; i++, pstkback++) {
  38. ret = BP_GETRET(fp);
  39. #if 0
  40. if (i < ncheck && pstkback->ret != 0) {
  41. ASSERT(pstkback->fp == 0 || pstkback->fp == -1 || pstkback->fp <= 512);
  42. if (!(pstkback->ret <= ret && ret <= pstkback->ret + pstkback->fp)) {
  43. // constraint violated
  44. break;
  45. }
  46. }
  47. #endif
  48. fp = BP_GETOLDBP(fp);
  49. pstkback->ret = ret;
  50. pstkback->fp = fp;
  51. }
  52. }
  53. __except(EXCEPTION_EXECUTE_HANDLER) {
  54. TraceMsg(TF_ALWAYS, "atm: GPF");
  55. // just use last 'ret' we had
  56. }
  57. *pfp = fp;
  58. return i;
  59. }
  60. #endif
  61. #endif // }