Added ELF sections check so a potential unknown section will stop, or not stop, the...
[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 // JPM 04/06/2019 Added ELF sections check
13 //
14
15 #include "debuggertab.h"
16 #include "settings.h"
17
18
19 //
20 DebuggerTab::DebuggerTab(QWidget * parent/*= 0*/): QWidget(parent)
21 {
22 // Number of disassembly lines
23 QLabel *label3 = new QLabel("Disassembly lines:");
24 QVBoxLayout *layout1 = new QVBoxLayout;
25 layout1->addWidget(label3);
26 QVBoxLayout *layout2 = new QVBoxLayout;
27 nbrdisasmlines = new QLineEdit("");
28 nbrdisasmlines->setPlaceholderText("Number of disassembly lines");
29 layout2->addWidget(nbrdisasmlines);
30
31 // Sources code paths
32 QLabel *label4 = new QLabel("Source file search paths:");
33 QVBoxLayout *layout5 = new QVBoxLayout;
34 layout5->addWidget(label4);
35 QVBoxLayout *layout6 = new QVBoxLayout;
36 sourcefilesearchpaths = new QLineEdit("");
37 sourcefilesearchpaths->setMaxLength(sizeof(vjs.sourcefilesearchPaths));
38 sourcefilesearchpaths->setPlaceholderText("Each path must be separate by a ';', search is recursive and based on each path");
39 layout6->addWidget(sourcefilesearchpaths);
40
41 QHBoxLayout *layout3 = new QHBoxLayout;
42 layout3->addLayout(layout1);
43 layout3->addLayout(layout2);
44 QHBoxLayout *layout7 = new QHBoxLayout;
45 layout7->addLayout(layout5);
46 layout7->addLayout(layout6);
47
48 QVBoxLayout *layout4 = new QVBoxLayout;
49 layout4->addLayout(layout3);
50 layout4->addLayout(layout7);
51
52 // Checkboxes
53 displayHWlabels = new QCheckBox(tr("Display HW labels"));
54 disasmopcodes = new QCheckBox(tr("Display M68000 opcodes"));
55 displayFullSourceFilename = new QCheckBox(tr("Display source filename"));
56 ELFSectionsCheck = new QCheckBox(tr("ELF sections check"));
57 disasmopcodes->setDisabled(false);
58 displayHWlabels->setDisabled(false);
59 displayFullSourceFilename->setDisabled(false);
60 ELFSectionsCheck->setDisabled(false);
61
62 layout4->addWidget(disasmopcodes);
63 layout4->addWidget(displayHWlabels);
64 layout4->addWidget(displayFullSourceFilename);
65 layout4->addWidget(ELFSectionsCheck);
66
67 setLayout(layout4);
68 }
69
70
71 //
72 DebuggerTab::~DebuggerTab()
73 {
74 }
75
76
77 // Save / Update the settings from the tabs dialog
78 void DebuggerTab::SetSettings(void)
79 {
80 bool ok;
81
82 strcpy(vjs.debuggerROMPath, vjs.alpineROMPath);
83 strcpy(vjs.sourcefilesearchPaths, CheckForTrailingSlash(sourcefilesearchpaths->text()).toUtf8().data());
84 vjs.nbrdisasmlines = nbrdisasmlines->text().toUInt(&ok, 10);
85 vjs.displayHWlabels = displayHWlabels->isChecked();
86 vjs.disasmopcodes = disasmopcodes->isChecked();
87 vjs.displayFullSourceFilename = displayFullSourceFilename->isChecked();
88 vjs.ELFSectionsCheck = ELFSectionsCheck->isChecked();
89 }
90
91
92 // Load / Update the tabs dialog from the settings
93 void DebuggerTab::GetSettings(void)
94 {
95 QVariant v(vjs.nbrdisasmlines);
96 nbrdisasmlines->setText(v.toString());
97 sourcefilesearchpaths->setText(vjs.sourcefilesearchPaths);
98 displayHWlabels->setChecked(vjs.displayHWlabels);
99 disasmopcodes->setChecked(vjs.disasmopcodes);
100 displayFullSourceFilename->setChecked(vjs.displayFullSourceFilename);
101 ELFSectionsCheck->setChecked(vjs.ELFSectionsCheck);
102 }
103
104
105 // Remove the last character if slash or backslash at the end of each string
106 // Depend the platform transform slashes or backslashes
107 QString DebuggerTab::CheckForTrailingSlash(QString s)
108 {
109 if (s.endsWith('/') || s.endsWith('\\'))
110 {
111 s.remove(s.length() - 1, 1);
112 }
113 #ifdef _WIN32
114 s.replace(QString("/"), QString("\\"));
115 s.replace(QString("\\;"), QString(";"));
116 #else
117 s.replace(QString("\\"), QString("/"));
118 s.replace(QString("/;"), QString(";"));
119 #endif
120 return s;
121 }