Added the return address information in the call stack
[clinton/Virtual-Jaguar-Rx.git] / src / debugger / debuggertab.cpp
1 //
2 // debuggertab.cpp: "Debugger" tab on the settings dialog
3 //
4 // by Jean-Paul Mari
5 //
6 // JPM = Jean-Paul Mari <djipi.mari@gmail.com>
7 //
8 // WHO WHEN WHAT
9 // --- ---------- ------------------------------------------------------------
10 // JPM Sept./2016 Created this file, and added Soft debugger support
11 // JPM 10/09/2018 Added source file search paths
12 //
13
14 #include "debuggertab.h"
15 #include "settings.h"
16
17
18 //
19 DebuggerTab::DebuggerTab(QWidget * parent/*= 0*/): QWidget(parent)
20 {
21 // Number of disassembly lines
22 QLabel *label3 = new QLabel("Disassembly lines:");
23 QVBoxLayout *layout1 = new QVBoxLayout;
24 layout1->addWidget(label3);
25 QVBoxLayout *layout2 = new QVBoxLayout;
26 nbrdisasmlines = new QLineEdit("");
27 nbrdisasmlines->setPlaceholderText("Number of disassembly lines");
28 layout2->addWidget(nbrdisasmlines);
29
30 // Sources code paths
31 QLabel *label4 = new QLabel("Source file search paths:");
32 QVBoxLayout *layout5 = new QVBoxLayout;
33 layout5->addWidget(label4);
34 QVBoxLayout *layout6 = new QVBoxLayout;
35 sourcefilesearchpaths = new QLineEdit("");
36 sourcefilesearchpaths->setMaxLength(sizeof(vjs.sourcefilesearchPaths));
37 sourcefilesearchpaths->setPlaceholderText("Each path must be separate by a ';', search is recursive and based on each path");
38 layout6->addWidget(sourcefilesearchpaths);
39
40 QHBoxLayout *layout3 = new QHBoxLayout;
41 layout3->addLayout(layout1);
42 layout3->addLayout(layout2);
43 QHBoxLayout *layout7 = new QHBoxLayout;
44 layout7->addLayout(layout5);
45 layout7->addLayout(layout6);
46
47 QVBoxLayout *layout4 = new QVBoxLayout;
48 layout4->addLayout(layout3);
49 layout4->addLayout(layout7);
50
51 // Checkboxes
52 displayHWlabels = new QCheckBox(tr("Display HW labels"));
53 disasmopcodes = new QCheckBox(tr("Display M68000 opcodes"));
54 displayFullSourceFilename = new QCheckBox(tr("Display source filename"));
55 disasmopcodes->setDisabled(false);
56 displayHWlabels->setDisabled(false);
57 displayFullSourceFilename->setDisabled(false);
58
59 layout4->addWidget(disasmopcodes);
60 layout4->addWidget(displayHWlabels);
61 layout4->addWidget(displayFullSourceFilename);
62
63 setLayout(layout4);
64 }
65
66
67 //
68 DebuggerTab::~DebuggerTab()
69 {
70 }
71
72
73 // Save / Update the settings from the tabs dialog
74 void DebuggerTab::SetSettings(void)
75 {
76 bool ok;
77
78 strcpy(vjs.debuggerROMPath, vjs.alpineROMPath);
79 strcpy(vjs.sourcefilesearchPaths, CheckForTrailingSlash(sourcefilesearchpaths->text()).toUtf8().data());
80 vjs.nbrdisasmlines = nbrdisasmlines->text().toUInt(&ok, 10);
81 vjs.displayHWlabels = displayHWlabels->isChecked();
82 vjs.disasmopcodes = disasmopcodes->isChecked();
83 vjs.displayFullSourceFilename = displayFullSourceFilename->isChecked();
84 }
85
86
87 // Load / Update the tabs dialog from the settings
88 void DebuggerTab::GetSettings(void)
89 {
90 QVariant v(vjs.nbrdisasmlines);
91 nbrdisasmlines->setText(v.toString());
92 sourcefilesearchpaths->setText(vjs.sourcefilesearchPaths);
93 displayHWlabels->setChecked(vjs.displayHWlabels);
94 disasmopcodes->setChecked(vjs.disasmopcodes);
95 displayFullSourceFilename->setChecked(vjs.displayFullSourceFilename);
96 }
97
98
99 // Remove the last character if slash or backslash at the end of each string
100 // Depend the platform transform slashes or backslashes
101 QString DebuggerTab::CheckForTrailingSlash(QString s)
102 {
103 if (s.endsWith('/') || s.endsWith('\\'))
104 {
105 s.remove(s.length() - 1, 1);
106 }
107 #ifdef _WIN32
108 s.replace(QString("/"), QString("\\"));
109 s.replace(QString("\\;"), QString(";"));
110 #else
111 s.replace(QString("\\"), QString("/"));
112 s.replace(QString("/;"), QString(";"));
113 #endif
114 return s;
115 }