Fixed printing of QString values for some at least gdb 5.2.1.
[kdbg.git] / kdbg / main.cpp
blob88d6649e757714b4250e97848be28ef1aa3f7c6a
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 static const char* description =
37 i18n("A Debugger");
39 KAboutData aboutData("kdbg", "KDbg",
40 VERSION,
41 description,
42 KAboutData::License_GPL,
43 "(c) 1998-2001 Johannes Sixt",
44 0, /* any text */
45 "http://members.nextra.at/johsixt/kdbg.html",
46 "Johannes.Sixt@telecom.at");
47 aboutData.addAuthor("Johannes Sixt", 0, "Johannes.Sixt@telecom.at");
48 aboutData.addCredit("Max Judin",
49 I18N_NOOP("Docking windows"),
50 "novaprint@mtu-net.ru");
51 aboutData.addCredit("Keith Isdale",
52 I18N_NOOP("XSLT debugging"),
53 "k_isdale@tpg.com.au");
54 KCmdLineArgs::init( argc, argv, &aboutData );
56 static KCmdLineOptions options[] = {
57 { "t <file>", I18N_NOOP("transcript of conversation with the debugger"), 0 },
58 { "r <device>", I18N_NOOP("remote debugging via <device>"), 0 },
59 { "l <language>", I18N_NOOP("specify language: C, XSLT"), ""},
60 { "x", I18N_NOOP("use language XSLT (deprecated)"), 0 },
61 { "+[program]", I18N_NOOP("path of executable to debug"), 0 },
62 { "+[core]", I18N_NOOP("a core file to use"), 0},
63 { 0, 0, 0 }
65 KCmdLineArgs::addCmdLineOptions(options);
67 KApplication app;
69 KGlobal::dirs()->addResourceType("types", "share/apps/kdbg/types");
71 DebuggerMainWnd debugger("kdbg_main");
73 /* type libraries */
74 TypeTable::initTypeLibraries();
76 // session management
77 bool restored = false;
78 if (app.isRestored()) {
79 if (KMainWindow::canBeRestored(1)) {
80 debugger.restore(1);
81 restored = true;
85 app.setMainWidget(&debugger);
87 debugger.show();
89 // handle options
91 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
92 QCString t = args->getOption("t");
93 const char* transcript = t.data();
94 QString remote = args->getOption("r");
95 if (!remote.isEmpty())
96 debugger.setRemoteDevice(remote);
98 QCString lang = args->getOption("l");
100 // deprecated option; overrides -l
101 if (args->isSet("x")){
102 /* run in xsldbg mode */
103 lang = "xslt";
106 // check environment variable for transcript file name
107 if (transcript == 0) {
108 transcript = getenv("KDBG_TRANSCRIPT");
110 debugger.setTranscript(transcript);
112 if (!restored && args->count() > 0) {
113 // check for core file
114 if (args->count() > 1) {
115 debugger.setCoreFile(args->arg(1));
117 if (!debugger.debugProgram(args->arg(0), lang)) {
118 // failed
119 TRACE("cannot start debugger");
120 KMessageBox::error(&debugger, i18n("Cannot start debugger."));
121 debugger.setCoreFile("");
125 int rc = app.exec();
126 return rc;