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.

139 lines
3.7 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //#include <windows.h>
  3. #include "mdmpRipper.h"
  4. #include "vgui_controls/MessageMap.h"
  5. #include "vgui_controls/MenuBar.h"
  6. #include "vgui_controls/Menu.h"
  7. #include "vgui_controls/TextEntry.h"
  8. #include "vgui/ISurface.h"
  9. #include "vgui_controls/Frame.h"
  10. #include "CMDErrorPanel.h"
  11. #include "vgui_controls/ListPanel.h"
  12. #include "KeyValues.h"
  13. #include "vgui/ISystem.h"
  14. #include "CMDDetailPanel.h"
  15. using namespace vgui;
  16. CMDErrorPanel::CMDErrorPanel( vgui::Panel *pParent, const char *pName ) :
  17. BaseClass( pParent, pName )
  18. {
  19. SetParent( pParent );
  20. m_pTokenList = new ListPanel(this, "ErrorList");
  21. m_pTokenList->AddColumnHeader(0, "errorid", "Error ID", 100, 0);
  22. m_pTokenList->AddColumnHeader(1, "module", "Module Name", 200, 0);
  23. m_pTokenList->AddColumnHeader(2, "count", "Count", 100, 0);
  24. m_pTokenList->AddColumnHeader(3, "minidumps", "Minidump Count", 100, 0);
  25. m_pMaxResults = new vgui::TextEntry( this, "maxResults" );
  26. m_pQueryCounts = new vgui::TextEntry( this, "numCrashes" );
  27. m_pMaxResults->SetText( "100" );
  28. m_pQueryCounts->SetText( "10000" );
  29. LoadControlSettings( "MDErrorPanel.res" );
  30. }
  31. void CMDErrorPanel::OnCommand( const char *pCommand )
  32. {
  33. if ( !Q_strcmp( pCommand, "Close" ) )
  34. {
  35. Close();
  36. }
  37. if ( !Q_strcmp( pCommand, "CheckModules" ) )
  38. {
  39. CheckModules();
  40. }
  41. if ( !Q_strcmp( pCommand, "NewQuery" ) )
  42. {
  43. NewQuery();
  44. }
  45. if ( !Q_strcmp( pCommand, "Download" ) )
  46. {
  47. DownloadMinidumps();
  48. }
  49. if ( !Q_strcmp( pCommand, "Details" ) )
  50. {
  51. DetailScreen();
  52. }
  53. }
  54. void CMDErrorPanel::Close()
  55. {
  56. if ( this )
  57. {
  58. m_pTokenList->DeleteAllItems();
  59. SetVisible( false );
  60. KeyValues *kv = new KeyValues( "Refresh" );
  61. this->PostActionSignal( kv );
  62. }
  63. }
  64. void CMDErrorPanel::CheckModules()
  65. {
  66. char sql[255] = "";
  67. extern void getMiniDumpHandles( char *pszQuery, const char *errorid, CUtlVector<HANDLE> *pMiniDumpHandles );
  68. int selectedIndex = m_pTokenList->GetSelectedItem( 0 );
  69. void *kv = m_pTokenList->GetItem( selectedIndex );
  70. if ( kv )
  71. {
  72. strcat( sql, "select MinidumpFilePath from minidumps where ErrorID=" );
  73. strcat( sql, ((KeyValues *)kv)->GetString( "errorid", "" ) );
  74. strcat( sql, " order by MinidumpFilePath desc limit " );
  75. strcat( sql, ((KeyValues *)kv)->GetString( "minidumps", "" ) );
  76. strcat( sql, ";" );
  77. getMiniDumpHandles( sql, ((KeyValues *)kv)->GetString( "errorid", "" ), &m_MiniDumpHandles );
  78. KeyValues *kv = new KeyValues( "Compare", "handlePointer", (int)(&m_MiniDumpHandles) );
  79. this->PostActionSignal( kv );
  80. }
  81. }
  82. void CMDErrorPanel::NewQuery()
  83. {
  84. m_pTokenList->DeleteAllItems();
  85. extern void errorsToListPanel( vgui::ListPanel *pTokenList, char* pszQuery );
  86. char sql[255] = "";
  87. char temp[10];
  88. strcat( sql, "select errorid, module, count, minidumpsonhand from error_types where processed=0 and minidumpsonhand > 0 and count > " );
  89. m_pQueryCounts->GetText( temp, 10 );
  90. strcat( sql, temp );
  91. strcat( sql, " limit " );
  92. m_pMaxResults->GetText( temp, 10 );
  93. strcat( sql, temp );
  94. strcat( sql, ";" );
  95. errorsToListPanel( m_pTokenList, sql );
  96. Repaint();
  97. }
  98. void CMDErrorPanel::DownloadMinidumps()
  99. {
  100. int selectedIndex = m_pTokenList->GetSelectedItem( 0 );
  101. void *kv = m_pTokenList->GetItem( selectedIndex );
  102. if ( kv )
  103. {
  104. char command[1024] = "";
  105. strcat( command, ((KeyValues *)kv)->GetString( "errorid", "" ));
  106. strcat( command, " minidumpSaves" );
  107. ::_spawnl( _P_WAIT, ".\\minidump.bat", "minidump.bat ", command, NULL );
  108. }
  109. }
  110. void CMDErrorPanel::DetailScreen()
  111. {
  112. int selectedIndex = m_pTokenList->GetSelectedItem( 0 );
  113. void *kv = m_pTokenList->GetItem( selectedIndex );
  114. if ( kv )
  115. {
  116. KeyValues *kvPost = new KeyValues( "Detail", "errorID", ((KeyValues *)kv)->GetString( "errorid", "" ) );
  117. this->PostActionSignal( kvPost );
  118. }
  119. }