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