| 1 | #cxx . . $ `<file>/src/DebugSession.cpp`/include "DebugSession.h"cxx . . $ `<file>/src/DebugSession.h`/ |
| 2 | #include <QXmlStreamReader> |
| 3 | #include <QXmlStreamWriter> |
| 4 | #include <QFile> |
| 5 | #include <QMessageBox> |
| 6 | |
| 7 | DebugSessioncxx . . $ DebugSession#::DebugSessioncxx . . $ DebugSession#DebugSession(49f6e7a06ebc5aa8).() |
| 8 | : modifiedcxx . . $ DebugSession#modified.(false) |
| 9 | { |
| 10 | } |
| 11 | |
| 12 | bool DebugSessioncxx . . $ DebugSession#::existsAsFilecxx . . $ DebugSession#existsAsFile(50ce9a9e25b4a850).() const |
| 13 | { |
| 14 | return !fileNamecxx . . $ DebugSession#fileName..isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).(); |
| 15 | } |
| 16 | |
| 17 | const QStringcxx . . $ QString#& DebugSessioncxx . . $ DebugSession#::filenamecxx . . $ DebugSession#filename(a2fb7a6ce195d51).() const |
| 18 | { |
| 19 | return fileNamecxx . . $ DebugSession#fileName.; |
| 20 | } |
| 21 | |
| 22 | bool DebugSessioncxx . . $ DebugSession#::isModifiedcxx . . $ DebugSession#isModified(50ce9a9e25b4a850).() const |
| 23 | { |
| 24 | if (fileNamecxx . . $ DebugSession#fileName..isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).() && symTablecxx . . $ DebugSession#symTable..sizecxx . . $ SymbolTable#size(455f465bc33b4cdf).() == 0) { |
| 25 | return false; |
| 26 | } else { |
| 27 | return modifiedcxx . . $ DebugSession#modified.; |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | Breakpointscxx . . $ Breakpoints#& DebugSessioncxx . . $ DebugSession#::breakpointscxx . . $ DebugSession#breakpoints(23c5ed405c07696).() |
| 32 | { |
| 33 | return breakscxx . . $ DebugSession#breaks.; |
| 34 | } |
| 35 | |
| 36 | SymbolTablecxx . . $ SymbolTable#& DebugSessioncxx . . $ DebugSession#::symbolTablecxx . . $ DebugSession#symbolTable(2a4b6678dec31d42).() |
| 37 | { |
| 38 | return symTablecxx . . $ DebugSession#symTable.; |
| 39 | } |
| 40 | |
| 41 | void DebugSessioncxx . . $ DebugSession#::clearcxx . . $ DebugSession#clear(49f6e7a06ebc5aa8).() |
| 42 | { |
| 43 | // clear everything |
| 44 | symTablecxx . . $ DebugSession#symTable..clearcxx . . $ SymbolTable#clear(49f6e7a06ebc5aa8).(); |
| 45 | breakscxx . . $ DebugSession#breaks..clearcxx . . $ Breakpoints#clear(49f6e7a06ebc5aa8).(); |
| 46 | fileNamecxx . . $ DebugSession#fileName..clearcxx . . $ QString#clear(49f6e7a06ebc5aa8).(); |
| 47 | modifiedcxx . . $ DebugSession#modified. = false; |
| 48 | } |
| 49 | |
| 50 | void DebugSessioncxx . . $ DebugSession#::opencxx . . $ DebugSession#open(3520e46b33348bf6).(const QStringcxx . . $ QString#& file) |
| 51 | { |
| 52 | QFilecxx . . $ QFile# fcxx . . $ QFile#QFile(3520e46b33348bf6).(file); |
| 53 | if (!f.opencxx . . $ QFile#open(dca164408be960c8).(QFilecxx . . $ QFile#::ReadOnlycxx . . $ QIODevice#ReadOnly. |cxx . . $ `operator|`(c9e45f682471e48d). QFilecxx . . $ QFile#::Textcxx . . $ QIODevice#Text.)) { |
| 54 | QMessageBoxcxx . . $ QMessageBox#::warningcxx . . $ QMessageBox#warning(a9e3742e6f7b4147).(nullptr, trcxx . . $ DebugSession#tr(75d9f1c324b4579d).("Open session ..."), |
| 55 | trcxx . . $ DebugSession#tr(75d9f1c324b4579d).("Cannot read file %1:\n%2.") |
| 56 | .argcxx . . $ QString#arg(bc823072288cbbb5).(file) |
| 57 | .argcxx . . $ QString#arg(bc823072288cbbb5).(f.errorStringcxx . . $ QIODevice#errorString(6ef7b6c27b00b43d).())); |
| 58 | return; |
| 59 | } |
| 60 | |
| 61 | // clear current project and start reading xml file |
| 62 | clearcxx . . $ DebugSession#clear(49f6e7a06ebc5aa8).(); |
| 63 | QXmlStreamReadercxx . . $ QXmlStreamReader# sescxx . . $ QXmlStreamReader#QXmlStreamReader(49f6e7a06ebc5aa8).; |
| 64 | ses.setDevicecxx . . $ QXmlStreamReader#setDevice(bebe8f2dee7f9e86).(&f); |
| 65 | while (!ses.atEndcxx . . $ QXmlStreamReader#atEnd(50ce9a9e25b4a850).()) { |
| 66 | ses.readNextcxx . . $ QXmlStreamReader#readNext(b7ff4e19d2a802cc).(); |
| 67 | if (ses.isStartElementcxx . . $ QXmlStreamReader#isStartElement(50ce9a9e25b4a850).() && (ses.namecxx . . $ QXmlStreamReader#name(d2d1e01c834b11a).() ==cxx . . $ QStringRef#`operator==`(7d4bdb1abc417636). "DebugSession")) { |
| 68 | // debug session data |
| 69 | while (!ses.atEndcxx . . $ QXmlStreamReader#atEnd(50ce9a9e25b4a850).()) { |
| 70 | ses.readNextcxx . . $ QXmlStreamReader#readNext(b7ff4e19d2a802cc).(); |
| 71 | // end tag |
| 72 | if (ses.isEndElementcxx . . $ QXmlStreamReader#isEndElement(50ce9a9e25b4a850).()) break; |
| 73 | // begin tag |
| 74 | if (ses.isStartElementcxx . . $ QXmlStreamReader#isStartElement(50ce9a9e25b4a850).()) { |
| 75 | if (ses.namecxx . . $ QXmlStreamReader#name(d2d1e01c834b11a).() ==cxx . . $ QStringRef#`operator==`(7d4bdb1abc417636). "Symbols") { |
| 76 | symTablecxx . . $ DebugSession#symTable..loadSymbolscxx . . $ SymbolTable#loadSymbols(e225a1e01f50193c).(ses); |
| 77 | } else if (ses.namecxx . . $ QXmlStreamReader#name(d2d1e01c834b11a).() ==cxx . . $ QStringRef#`operator==`(7d4bdb1abc417636). "Breakpoints") { |
| 78 | breakscxx . . $ DebugSession#breaks..loadBreakpointscxx . . $ Breakpoints#loadBreakpoints(e225a1e01f50193c).(ses); |
| 79 | } else { |
| 80 | skipUnknownElementcxx . . $ DebugSession#skipUnknownElement(e225a1e01f50193c).(ses); |
| 81 | } |
| 82 | } |
| 83 | } |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | fileNamecxx . . $ DebugSession#fileName. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). file; |
| 88 | modifiedcxx . . $ DebugSession#modified. = false; |
| 89 | } |
| 90 | |
| 91 | void DebugSessioncxx . . $ DebugSession#::skipUnknownElementcxx . . $ DebugSession#skipUnknownElement(e225a1e01f50193c).(QXmlStreamReadercxx . . $ QXmlStreamReader#& ses) |
| 92 | { |
| 93 | while (!ses.atEndcxx . . $ QXmlStreamReader#atEnd(50ce9a9e25b4a850).()) { |
| 94 | ses.readNextcxx . . $ QXmlStreamReader#readNext(b7ff4e19d2a802cc).(); |
| 95 | if (ses.isEndElementcxx . . $ QXmlStreamReader#isEndElement(50ce9a9e25b4a850).()) break; |
| 96 | if (ses.isStartElementcxx . . $ QXmlStreamReader#isStartElement(50ce9a9e25b4a850).()) skipUnknownElementcxx . . $ DebugSession#skipUnknownElement(e225a1e01f50193c).(ses); |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | bool DebugSessioncxx . . $ DebugSession#::savecxx . . $ DebugSession#save(c9857a73d68e59ba).() |
| 101 | { |
| 102 | return saveAscxx . . $ DebugSession#saveAs(e1defb592416720d).(fileNamecxx . . $ DebugSession#fileName.); |
| 103 | } |
| 104 | |
| 105 | bool DebugSessioncxx . . $ DebugSession#::saveAscxx . . $ DebugSession#saveAs(e1defb592416720d).(const QStringcxx . . $ QString#& newFileName) |
| 106 | { |
| 107 | // open file for save |
| 108 | QFilecxx . . $ QFile# filecxx . . $ QFile#QFile(3520e46b33348bf6).(newFileName); |
| 109 | if (!file.opencxx . . $ QFile#open(dca164408be960c8).(QFilecxx . . $ QFile#::WriteOnlycxx . . $ QIODevice#WriteOnly. |cxx . . $ `operator|`(c9e45f682471e48d). QFilecxx . . $ QFile#::Textcxx . . $ QIODevice#Text.)) { |
| 110 | QMessageBoxcxx . . $ QMessageBox#::warningcxx . . $ QMessageBox#warning(a9e3742e6f7b4147).(nullptr, trcxx . . $ DebugSession#tr(75d9f1c324b4579d).("Save session ..."), |
| 111 | trcxx . . $ DebugSession#tr(75d9f1c324b4579d).("Cannot write file %1:\n%2.") |
| 112 | .argcxx . . $ QString#arg(bc823072288cbbb5).(fileNamecxx . . $ DebugSession#fileName.) |
| 113 | .argcxx . . $ QString#arg(bc823072288cbbb5).(file.errorStringcxx . . $ QIODevice#errorString(6ef7b6c27b00b43d).())); |
| 114 | return false; |
| 115 | } |
| 116 | |
| 117 | // start xml file |
| 118 | QXmlStreamWritercxx . . $ QXmlStreamWriter# sescxx . . $ QXmlStreamWriter#QXmlStreamWriter(49f6e7a06ebc5aa8).; |
| 119 | ses.setDevicecxx . . $ QXmlStreamWriter#setDevice(bebe8f2dee7f9e86).(&file); |
| 120 | ses.setAutoFormattingcxx . . $ QXmlStreamWriter#setAutoFormatting(b45ddcbc8423892c).(true); |
| 121 | ses.writeDTDcxx . . $ QXmlStreamWriter#writeDTD(3520e46b33348bf6).("<!DOCTYPE xomds>"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 122 | ses.writeStartElementcxx . . $ QXmlStreamWriter#writeStartElement(3520e46b33348bf6).("DebugSession"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 123 | ses.writeAttributecxx . . $ QXmlStreamWriter#writeAttribute(c1427772cd1877b0).("version"cxx . . $ QString#QString(85c52e162fed56f9)., "0.1"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 124 | |
| 125 | // write symbols |
| 126 | ses.writeStartElementcxx . . $ QXmlStreamWriter#writeStartElement(3520e46b33348bf6).("Symbols"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 127 | symTablecxx . . $ DebugSession#symTable..saveSymbolscxx . . $ SymbolTable#saveSymbols(b6139443264d70c1).(ses); |
| 128 | ses.writeEndElementcxx . . $ QXmlStreamWriter#writeEndElement(49f6e7a06ebc5aa8).(); |
| 129 | |
| 130 | // write breakpoints |
| 131 | ses.writeStartElementcxx . . $ QXmlStreamWriter#writeStartElement(3520e46b33348bf6).("Breakpoints"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 132 | breakscxx . . $ DebugSession#breaks..saveBreakpointscxx . . $ Breakpoints#saveBreakpoints(b6139443264d70c1).(ses); |
| 133 | ses.writeEndElementcxx . . $ QXmlStreamWriter#writeEndElement(49f6e7a06ebc5aa8).(); |
| 134 | |
| 135 | // end |
| 136 | ses.writeEndDocumentcxx . . $ QXmlStreamWriter#writeEndDocument(49f6e7a06ebc5aa8).(); |
| 137 | modifiedcxx . . $ DebugSession#modified. = false; |
| 138 | fileNamecxx . . $ DebugSession#fileName. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). newFileName; // only set after successful save |
| 139 | return true; |
| 140 | } |
| 141 | |
| 142 | void DebugSessioncxx . . $ DebugSession#::sessionModifiedcxx . . $ DebugSession#sessionModified(49f6e7a06ebc5aa8).() |
| 143 | { |
| 144 | modifiedcxx . . $ DebugSession#modified. = true; |
| 145 | } |