Team Fortress 2 Source Code as on 22/4/2020
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.

82 lines
2.5 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. #include <windows.h>
  3. //#include <conio.h>
  4. #include "vgui_controls/ListPanel.h"
  5. #include "KeyValues.h"
  6. #include "isqlwrapper.h"
  7. #include "vgui/ISystem.h"
  8. #include "tier0/memdbgon.h"
  9. using namespace vgui;
  10. extern ISQLWrapper *g_pSqlWrapper;
  11. void getMiniDumpHandles( char* pszQuery, const char *errorid, CUtlVector<HANDLE> *pMiniDumpHandles )
  12. {
  13. char rgchQueryBuf[ 1024 ];
  14. Q_snprintf( rgchQueryBuf, sizeof(rgchQueryBuf), pszQuery );
  15. IResultSet *results = g_pSqlWrapper->PResultSetQuery( rgchQueryBuf ); // do the query
  16. Assert( results != NULL );
  17. char command[1024] = "";
  18. strcat( command, errorid );
  19. strcat( command, " minidumptool" );
  20. ::_spawnl( _P_WAIT, ".\\minidump.bat", "minidump.bat ", command, NULL );
  21. char path[1024] = "";
  22. char *pathTraverse;
  23. char newPath[1024] = "";
  24. for ( int i = 0; i < results->GetCSQLRow(); i++ )
  25. {
  26. const ISQLRow *row = results->PSQLRowNextResult();
  27. Assert( row != NULL );
  28. strcpy( path, row->PchData(0) );
  29. pathTraverse = strchr( path, '/' ) + 1;
  30. pathTraverse = strchr( pathTraverse, '/' ) + 1;
  31. pathTraverse = strchr( pathTraverse, '/' ) + 1;
  32. pathTraverse = strchr( pathTraverse, '/' );
  33. strcat( newPath, "c:/minidumptool" );
  34. strcat( newPath, pathTraverse );
  35. HANDLE hFile = CreateFile(newPath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
  36. pMiniDumpHandles->AddToTail( hFile );
  37. newPath[0] = 0;
  38. }
  39. g_pSqlWrapper->FreeResult();
  40. }
  41. void errorsToListPanel( vgui::ListPanel *pTokenList, char* pszQuery )
  42. {
  43. char rgchQueryBuf[ 1024 ];
  44. Q_snprintf( rgchQueryBuf, sizeof(rgchQueryBuf), pszQuery );
  45. IResultSet *results = g_pSqlWrapper->PResultSetQuery( rgchQueryBuf ); // do the query
  46. Assert( results != NULL );
  47. int errorid;
  48. char errorbuf[128];
  49. char module[128];
  50. int count;
  51. int minidumps;
  52. char keyNameBuf[1024] = "module";
  53. char modNumBuf[4] = "";
  54. for ( int i = 0; i < results->GetCSQLRow(); i++ )
  55. {
  56. const ISQLRow *row = results->PSQLRowNextResult();
  57. itoa( i, modNumBuf, 10 );
  58. strcat( keyNameBuf, modNumBuf );
  59. errorid = row->NData(0);
  60. itoa( errorid, errorbuf, 10 );
  61. strcpy( module, row->PchData(1) );
  62. count = row->NData(2);
  63. minidumps = row->NData(3);
  64. KeyValues *kv = new KeyValues( keyNameBuf, "errorid", errorbuf, "module", module );
  65. kv->SetInt( "count", count );
  66. kv->SetInt( "minidumps", minidumps );
  67. pTokenList->AddItem(kv, i, false, false);
  68. }
  69. g_pSqlWrapper->FreeResult();
  70. }