1 /*
2 * This file is part of the Code::Blocks IDE and licensed under the GNU General Public License, version 3
3 * http://www.gnu.org/licenses/gpl-3.0.html
4 *
5 * $Revision: 7109 $
6 * $Id: symtab.cpp 7109 2011-04-15 11:53:16Z mortenmacfly $
7 * $HeadURL: svn://svn.code.sf.net/p/codeblocks/code/branches/release-20.xx/src/plugins/contrib/symtab/symtab.cpp $
8 */
9
10 #include "sdk.h"
11
12 #ifndef CB_PRECOMP
13 #include <wx/intl.h>
14 #include <wx/string.h>
15 #include "globals.h"
16 #include "manager.h"
17 #include "configmanager.h"
18 #endif
19
20 //#define TRACE_SYMTAB
21 #ifdef TRACE_SYMTAB
22 #ifndef CB_PRECOMP
23 #include "logmanager.h"
24 #endif
25 #endif
26
27 #include <wx/choicdlg.h>
28 #include <wx/filedlg.h>
29 #include "symtab.h"
30 #include "symtabconfig.h"
31 #include "symtabexec.h"
32
33 /* ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- */
34
35 // Register the plugin
36 namespace
37 {
38 PluginRegistrant<SymTab> reg(_T("SymTab"));
39 };
40
41 /* ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- */
42
SymTab()43 SymTab::SymTab() : CfgDlg(0L), ExeDlg(0L)
44 {
45 //ctor
46 if(!Manager::LoadResource(_T("SymTab.zip")))
47 {
48 NotifyMissingFile(_T("SymTab.zip"));
49 }
50 }// SymTab
51
52 /* ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- */
53
~SymTab()54 SymTab::~SymTab()
55 {
56 //dtor
57 }// ~SymTab
58
59 /* ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- */
60
OnAttach()61 void SymTab::OnAttach()
62 {
63 // do whatever initialization you need for your plugin
64 // NOTE: after this function, the inherited member variable
65 // IsAttached() will be TRUE...
66 // You should check for it in other functions, because if it
67 // is FALSE, it means that the application did *not* "load"
68 // (see: does not need) this plugin...
69 }// OnAttach
70
71 /* ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- */
72
OnRelease(bool)73 void SymTab::OnRelease(bool /*appShutDown*/)
74 {
75 // do de-initialization for your plugin
76 // if appShutDown is false, the plugin is unloaded because Code::Blocks is being shut down,
77 // which means you must not use any of the SDK Managers
78 // NOTE: after this function, the inherited member variable
79 // IsAttached() will be FALSE...
80 if (CfgDlg) {CfgDlg->Destroy(); CfgDlg = 0L;}
81 if (ExeDlg) {ExeDlg->Destroy(); ExeDlg = 0L;}
82 }// OnRelease
83
84 /* ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- */
85
Execute()86 int SymTab::Execute()
87 {
88 // if not attached, exit
89 if (!IsAttached())
90 return -1;
91
92 #ifdef TRACE_SYMTAB
93 Manager::Get()->GetLogManager()->DebugLog(F(_T("SymTab::Execute")));
94 #endif
95
96 if (!CfgDlg)
97 CfgDlg = new SymTabConfigDlg(Manager::Get()->GetAppWindow());
98
99 if ((!CfgDlg) || (CfgDlg->Execute() != wxID_OK))
100 return -1;
101
102 // Load the config settings
103 ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("symtab"));
104
105 // Loading configuration
106 struct_config config;
107 config.choWhatToDo = cfg->ReadInt (_T("/what_to_do"), 0);
108
109 config.txtLibraryPath = cfg->Read (_T("/library_path"), wxEmptyString);
110 config.chkIncludeA = cfg->ReadBool(_T("/include_a"), true);
111 config.chkIncludeLib = cfg->ReadBool(_T("/include_lib"), true);
112 config.chkIncludeO = cfg->ReadBool(_T("/include_o"), false);
113 config.chkIncludeObj = cfg->ReadBool(_T("/include_obj"), false);
114 config.chkIncludeDll = cfg->ReadBool(_T("/include_dll"), false);
115
116 config.txtLibrary = cfg->Read (_T("/library"), wxEmptyString);
117
118 config.txtSymbol = cfg->Read (_T("/symbol"), wxEmptyString);
119
120 config.txtNM = cfg->Read (_T("/nm"), wxEmptyString);
121
122 config.chkDebug = cfg->ReadBool(_T("/debug"), false);
123 config.chkDefined = cfg->ReadBool(_T("/defined"), false);
124 config.chkDemangle = cfg->ReadBool(_T("/demangle"), false);
125 config.chkExtern = cfg->ReadBool(_T("/extern"), false);
126 config.chkSpecial = cfg->ReadBool(_T("/special"), false);
127 config.chkSynthetic = cfg->ReadBool(_T("/synthetic"), false);
128 config.chkUndefined = cfg->ReadBool(_T("/undefined"), false);
129
130 // If we got this far, all is left is to call nm
131 if (!ExeDlg)
132 ExeDlg = new SymTabExecDlg(Manager::Get()->GetAppWindow());
133
134 // Do we need to show the dialog (process successful)?
135 if ((!ExeDlg) || (ExeDlg->Execute(config) != wxID_OK))
136 return -1;
137
138 return 0;
139 }// Execute
140