Updated contents of the About box, thereby fixing a long-standing potential
[kdbg.git] / kdbg / main.cpp
blobd2d5d06050608687fe9a830c51c502879a5f4098
1 // $Id$
3 // Copyright by Johannes Sixt
4 // This file is under GPL, the GNU General Public Licence
7 #include <kapp.h>
8 #include <klocale.h> /* i18n */
9 #include <kmessagebox.h>
10 #include <kglobal.h>
11 #include <kstddirs.h>
12 #include <kcmdlineargs.h>
13 #include <kaboutdata.h>
14 #include <kpopupmenu.h>
15 #include <kmenubar.h>
16 #include "dbgmainwnd.h"
17 #include "typetable.h"
18 #ifdef HAVE_CONFIG_H
19 #include "config.h"
20 #endif
21 #ifndef VERSION
22 #define VERSION ""
23 #endif
24 #ifdef HAVE_FCNTL_H
25 #include <fcntl.h> /* open(2) */
26 #endif
27 #ifdef HAVE_UNISTD_H
28 #include <unistd.h> /* getopt(3) */
29 #endif
30 #include <stdlib.h> /* getenv(3) */
31 #include "mydebug.h"
34 int main(int argc, char** argv)
36 KAboutData aboutData("kdbg", "KDbg",
37 VERSION,
38 I18N_NOOP("A Debugger"),
39 KAboutData::License_GPL,
40 "(c) 1998-2003 Johannes Sixt",
41 0, /* any text */
42 "http://members.nextra.at/johsixt/kdbg.html",
43 "Johannes.Sixt@telecom.at");
44 aboutData.addAuthor("Johannes Sixt", 0, "Johannes.Sixt@telecom.at");
45 aboutData.addCredit("Keith Isdale",
46 I18N_NOOP("XSLT debugging"),
47 "k_isdale@tpg.com.au");
48 KCmdLineArgs::init( argc, argv, &aboutData );
50 static KCmdLineOptions options[] = {
51 { "t <file>", I18N_NOOP("transcript of conversation with the debugger"), 0 },
52 { "r <device>", I18N_NOOP("remote debugging via <device>"), 0 },
53 { "l <language>", I18N_NOOP("specify language: C, XSLT"), ""},
54 { "x", I18N_NOOP("use language XSLT (deprecated)"), 0 },
55 { "+[program]", I18N_NOOP("path of executable to debug"), 0 },
56 { "+[core]", I18N_NOOP("a core file to use"), 0},
57 { 0, 0, 0 }
59 KCmdLineArgs::addCmdLineOptions(options);
61 KApplication app;
63 KGlobal::dirs()->addResourceType("types", "share/apps/kdbg/types");
65 DebuggerMainWnd debugger("kdbg_main");
67 /* type libraries */
68 TypeTable::initTypeLibraries();
70 // session management
71 bool restored = false;
72 if (app.isRestored()) {
73 if (KMainWindow::canBeRestored(1)) {
74 debugger.restore(1);
75 restored = true;
79 app.setMainWidget(&debugger);
81 debugger.show();
83 // handle options
85 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
86 QCString t = args->getOption("t");
87 const char* transcript = t.data();
88 QString remote = args->getOption("r");
89 if (!remote.isEmpty())
90 debugger.setRemoteDevice(remote);
92 QCString lang = args->getOption("l");
94 // deprecated option; overrides -l
95 if (args->isSet("x")){
96 /* run in xsldbg mode */
97 lang = "xslt";
100 // check environment variable for transcript file name
101 if (transcript == 0) {
102 transcript = getenv("KDBG_TRANSCRIPT");
104 debugger.setTranscript(transcript);
106 if (!restored && args->count() > 0) {
107 // check for core file
108 if (args->count() > 1) {
109 debugger.setCoreFile(args->arg(1));
111 if (!debugger.debugProgram(args->arg(0), lang)) {
112 // failed
113 TRACE("cannot start debugger");
114 KMessageBox::error(&debugger, i18n("Cannot start debugger."));
115 debugger.setCoreFile("");
119 int rc = app.exec();
120 return rc;