Source code of Windows XP (NT5)
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.

110 lines
3.3 KiB

  1. //TracePDB - Extracts trace information from the PDB
  2. // This small tool is used to extract the same trace information that binplace does, but can be used 'after the fact'
  3. // that is if you have the full symbols PDB but no trace information, TracePDB can generate the trace
  4. // tmf and tmc files for you.
  5. #ifdef __cplusplus
  6. extern "C"{
  7. #endif
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <nt.h>
  11. #include <ntrtl.h>
  12. #include <nturtl.h>
  13. #include <windows.h>
  14. #include <shellapi.h>
  15. #include <tchar.h>
  16. #include "wppfmt.h"
  17. int _cdecl main(int argc, char** argv)
  18. {
  19. DWORD status;
  20. TCHAR lppath[MAX_PATH] ;
  21. TCHAR pdbname[MAX_PATH] ;
  22. INT len, targv=0 ;
  23. BOOL Verbose = FALSE ;
  24. BOOL bPDBName = FALSE ;
  25. LPSTR szRSDSDllToLoad = NULL;
  26. TCHAR helptext[] = "Usage: TracePDB -f <pdbname> [-p <path>] [-v]\n"
  27. " Options:\n"
  28. // " -r recurse into subdirectories\n"
  29. " -f specifies the PDBName from which to extract tmf's\n"
  30. " -p specifies the path to create the tmf's,\n"
  31. " by default the current directory.\n"
  32. " -v verbose, displays actions taken \n" ;
  33. if (GetCurrentDirectory(MAX_PATH,lppath) == 0 ) {
  34. printf("TracePDB: no current directory\n") ;
  35. exit(-1);
  36. }
  37. while (--argc > 0) {
  38. ++targv;
  39. if (argv[targv][0] == '-' || argv[targv][0] == '/') { // argument found
  40. if (argv[targv][1] == 'h' || argv[targv][1] == 'H'
  41. || argv[targv][1] == '?')
  42. {
  43. printf(helptext);
  44. return 1;
  45. } else if (argv[targv][1] == 'f') {
  46. if (--argc >0 ) {
  47. ++targv ;
  48. if ((strlen(argv[targv])+1) > MAX_PATH) {
  49. printf("TracePDB: PDBname toolarge\n");
  50. exit(-1);
  51. }
  52. strncpy(pdbname,argv[targv],strlen(argv[targv])+1);
  53. bPDBName = TRUE ;
  54. }
  55. } else if (argv[targv][1] == 'p') {
  56. if (--argc >0 ) {
  57. ++ targv ;
  58. if ((strlen(argv[targv])+1) > MAX_PATH) {
  59. printf("TracePDB: Path larger than MAX_PATH\n");
  60. exit(-1);
  61. }
  62. strncpy(lppath,argv[targv],strlen(argv[targv])+1);
  63. }
  64. } else if (argv[targv][1] == 'v') {
  65. Verbose = TRUE ;
  66. } else {
  67. printf(helptext);
  68. }
  69. }
  70. }
  71. if (!bPDBName) {
  72. printf("TracePDB: No PDB specified?\n\n%s",helptext);
  73. return (1);
  74. }
  75. if ((szRSDSDllToLoad = (LPSTR) malloc(MAX_PATH+1)) == NULL) {
  76. printf("TracePDB: malloc failed\n");
  77. return FALSE ;
  78. }
  79. strcpy( szRSDSDllToLoad, "mspdb70.dll");
  80. status = BinplaceWppFmt(pdbname,
  81. lppath,
  82. szRSDSDllToLoad,
  83. TRUE // always verbose
  84. ) ;
  85. if (status != ERROR_SUCCESS) {
  86. printf("TracePDB: failed with error %d\n", status);
  87. }
  88. return 0;
  89. }
  90. #ifdef __cplusplus
  91. }
  92. #endif