-
Notifications
You must be signed in to change notification settings - Fork 0
/
cbGcov.h
219 lines (188 loc) · 9.42 KB
/
cbGcov.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
/***************************************************************
* Name: cbGcov
* Purpose: Code::Blocks plugin
* Author: danselmi ()
* Created: 2010-04-11
* Copyright: danselmi
* License: GPL
**************************************************************/
#ifndef CBGCOV_H_INCLUDED
#define CBGCOV_H_INCLUDED
// For compilers that support precompilation, includes <wx/wx.h>
#include <wx/wxprec.h>
#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif
#include <map>
#include <wx/process.h>
#include <cbplugin.h> // for "class cbPlugin"
class cbStyledTextCtrl;
class GcovProcess;
struct cbGcovConfig;
const int NoCode = -1;
struct cbGcovConfig;
/**
* @brief Implements main functionality of the plugin.
*
*/
class cbGcov : public cbPlugin
{
public:
cbGcov();
virtual ~cbGcov(){}
/** Invoke configuration dialog. */
virtual int Configure();
/** Return the plugin's configuration priority.
* This is a number (default is 50) that is used to sort plugins
* in configuration dialogs. Lower numbers mean the plugin's
* configuration is put higher in the list.
*/
virtual int GetConfigurationPriority() const { return 50; }
/** Return the configuration group for this plugin. Default is cgUnknown.
* Notice that you can logically OR more than one configuration groups,
* so you could set it, for example, as "cgCompiler | cgContribPlugin".
*/
virtual int GetConfigurationGroup() const { return cgUnknown; }
/** Return plugin's configuration panel.
* @param parent The parent window.
* @return A pointer to the plugin's cbConfigurationPanel. It is deleted by the caller.
*/
virtual cbConfigurationPanel* GetConfigurationPanel(wxWindow* parent);
/** Return plugin's configuration panel for projects.
* The panel returned from this function will be added in the project's
* configuration dialog.
* @param parent The parent window.
* @param project The project that is being edited.
* @return A pointer to the plugin's cbConfigurationPanel. It is deleted by the caller.
*/
virtual cbConfigurationPanel* GetProjectConfigurationPanel(wxWindow* parent, cbProject* project){ return 0; }
/** This method is called by Code::Blocks and is used by the plugin
* to add any menu items it needs on Code::Blocks's menu bar.\n
* It is a pure virtual method that needs to be implemented by all
* plugins. If the plugin does not need to add items on the menu,
* just do nothing ;)
* @param menuBar the wxMenuBar to create items in
*/
virtual void BuildMenu(wxMenuBar* menuBar);
/** This method is called by Code::Blocks core modules (EditorManager,
* ProjectManager etc) and is used by the plugin to add any menu
* items it needs in the module's popup menu. For example, when
* the user right-clicks on a project file in the project tree,
* ProjectManager prepares a popup menu to display with context
* sensitive options for that file. Before it displays this popup
* menu, it asks all attached plugins (by asking PluginManager to call
* this method), if they need to add any entries
* in that menu. This method is called.\n
* If the plugin does not need to add items in the menu,
* just do nothing ;)
* @param type the module that's preparing a popup menu
* @param menu pointer to the popup menu
* @param data pointer to FileTreeData object (to access/modify the file tree)
*/
virtual void BuildModuleMenu(const ModuleType type, wxMenu* menu, const FileTreeData* data = 0);
/** This method is called by Code::Blocks and is used by the plugin
* to add any toolbar items it needs on Code::Blocks's toolbar.\n
* It is a pure virtual method that needs to be implemented by all
* plugins. If the plugin does not need to add items on the toolbar,
* just do nothing ;)
* @param toolBar the wxToolBar to create items on
* @return The plugin should return true if it needed the toolbar, false if not
*/
virtual bool BuildToolBar(wxToolBar* toolBar);
protected:
/** Any descendent plugin should override this virtual method and
* perform any necessary initialization. This method is called by
* Code::Blocks (PluginManager actually) when the plugin has been
* loaded and should attach in Code::Blocks. When Code::Blocks
* starts up, it finds and <em>loads</em> all plugins but <em>does
* not</em> activate (attaches) them. It then activates all plugins
* that the user has selected to be activated on start-up.\n
* This means that a plugin might be loaded but <b>not</b> activated...\n
* Think of this method as the actual constructor...
*/
virtual void OnAttach();
/** Any descendent plugin should override this virtual method and
* perform any necessary de-initialization. This method is called by
* Code::Blocks (PluginManager actually) when the plugin has been
* loaded, attached and should de-attach from Code::Blocks.\n
* Think of this method as the actual destructor...
* @param appShutDown If true, the application is shutting down. In this
* case *don't* use Manager::Get()->Get...() functions or the
* behaviour is undefined...
*/
virtual void OnRelease(bool appShutDown);
private:
struct LineInfo {int executionCount;
wxArrayString functionCalls;
wxArrayString branchInfos;
wxArrayString callInfos;};
typedef std::map<unsigned int, LineInfo> LineInformations;
struct ExecNotexecLines{
std::vector<unsigned int> ExecLines;
std::vector<unsigned int> NotexecLines;
};
typedef std::map<cbEditor*, ExecNotexecLines> EditorExecNotexecLines;
EditorExecNotexecLines edLineExecInfos;
typedef std::map<int, wxArrayString> Output_t; /**< wxProcessEvent::GetPid(), Log of process output */
typedef std::map<int, GcovProcess*> GcovProcesses_t; /**< wxProcessEvent::GetPid(), GcovProcess* */
unsigned int m_LocalCodeLines; /**< lines of code per file */
unsigned int m_LocalCodeLinesCalled; /**< lines of executed code per file */
unsigned int m_LocalNonExecutableCodeLines; /**< lines of not executable code per file */
unsigned int m_CodeLines; /**< lines of code per workspace */
unsigned int m_CodeLinesCalled; /**< lines of executed code per workspace */
unsigned int m_ParallelProcessCount; /**< number of processes for parallel execution */
Output_t m_Output; /**< captured gcov process output */
std::vector<cbProject*> m_Prjs; /**< projects in queue */
cbProject* m_Prj; /**< currently processed project */
GcovProcesses_t m_pProcesses; /**< currently running gcov processes */
wxString m_JobsWorkingdir;
wxArrayString m_Cmds; /**< array of commands to invode gcov for each file*/
wxArrayString m_JobsFileList; /**< files that gcov was run against */
wxDateTime m_TimeSpan; /**< total cbGcov execution time */
void Log(wxString str);
void InitTextCtrlForCovData(cbStyledTextCtrl *stc);
void ShowCovData(cbEditor *ed, cbProject* prj = 0);
void ShowCovData(cbEditor *ed, LineInformations &lineInfos);
void ClearCovData(cbEditor *ed);
void UpdateEditors(cbProject*);
void GetLineInfos(wxFileName filename, LineInformations &lineInfos);
void AddInfoFromLine(wxString &line, LineInformations &lineInfos);
void GcovProject(cbProject*);
void GetStats(cbProject*);
void Initialize();
int IsRunning();
int WorkspaceNextProject();
const wxString GetGcovBinaryName();
void StartGcov();
void StartGcovParallel();
void CleanProject(cbProject* prj);
void OnAddInstrumentationToProject(wxCommandEvent &event);
void OnUpdateAddInstrumentationToProject(wxUpdateUIEvent& event);
void OnDoGcov(wxCommandEvent &event);
void OnUpdateGcov(wxUpdateUIEvent& event);
void OnDoGcovWorkspace(wxCommandEvent &event);
void OnUpdateGcovWorkspace(wxUpdateUIEvent& event);
void OnEditorOpen(CodeBlocksEvent &event);
void OnEditorClose(CodeBlocksEvent &event);
void OnEditorModified(CodeBlocksEvent &event);
void OnCleanProject(CodeBlocksEvent &event);
void OnCleanWorkspace(CodeBlocksEvent &event);
void OnProjectActivate(CodeBlocksEvent &event);
void OnGcovReturned(wxProcessEvent &event);
void OnIdle(wxIdleEvent& event);
DECLARE_EVENT_TABLE();
cbGcovConfig *config_;
void OnGotoNextNotExecutedLine(wxCommandEvent &event);
void OnGotoPreviousNotExecutedLine(wxCommandEvent &event);
void OnGotoNextExecutedLine(wxCommandEvent &event);
void OnGotoPreviousExecutedLine(wxCommandEvent &event);
void OnUpdateNextNotExecutedLine(wxUpdateUIEvent &event);
void OnUpdatePreviousNotExecutedLine(wxUpdateUIEvent &event);
void OnUpdateNextExecutedLine(wxUpdateUIEvent &event);
void OnUpdatePreviousExecutedLine(wxUpdateUIEvent &event);
wxToolBar* m_pTbar;
public:
void OnProcessGeneratedOutputLine(const wxString &line, unsigned int id);
void UpdateConfig();
};
#endif // CBGCOV_H_INCLUDED