Skip to content

Commit 9684132

Browse files
committed
feat: 更强大的调试功能;程序优化和崩溃修复;
1 parent 89250c3 commit 9684132

39 files changed

Lines changed: 4328 additions & 2073 deletions

3rdparty/QHexView/QHexEdit2/chunks.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <limits.h>
2222

2323
#include <QBuffer>
24+
#include <QMutexLocker>
2425

2526
#define NORMAL 0
2627
#define HIGHLIGHTED 1
@@ -43,6 +44,7 @@ Chunks::Chunks(QIODevice *ioDevice, QObject *parent) : QObject(parent) {
4344
}
4445

4546
bool Chunks::setIODevice(QIODevice *ioDevice) {
47+
QMutexLocker locker(&_mutex);
4648
_ioDevice = ioDevice;
4749
bool ok = _ioDevice->open(QIODevice::ReadOnly);
4850
if (ok) // Try to open IODevice
@@ -78,6 +80,7 @@ QByteArray Chunks::data(qint64 pos, qint64 maxSize) const {
7880
else if ((pos + maxSize) > _size)
7981
maxSize = _size - pos;
8082

83+
QMutexLocker locker(&_mutex);
8184
_ioDevice->open(QIODevice::ReadOnly);
8285

8386
while (maxSize > 0) {
@@ -132,6 +135,7 @@ QByteArray Chunks::data(qint64 pos, qint64 maxSize) const {
132135
}
133136

134137
bool Chunks::write(QIODevice *iODevice, qint64 pos, qint64 count) {
138+
QMutexLocker locker(&_mutex);
135139
if (count == -1)
136140
count = _size;
137141
if (iODevice->isOpen()) {
@@ -224,6 +228,7 @@ bool Chunks::insert(qint64 pos, const QByteArray &ba) {
224228
bool Chunks::overwrite(qint64 pos, const QByteArray &ba) {
225229
if ((pos < 0) || (pos >= _size))
226230
return false;
231+
227232
int chunkIdx = getChunkIndex(pos);
228233

229234
auto &chunk = _chunks[chunkIdx];
@@ -249,6 +254,7 @@ bool Chunks::overwrite(qint64 pos, const QByteArray &ba) {
249254
bool Chunks::remove(qint64 pos, qint64 length) {
250255
if ((pos < 0) || (pos >= _size))
251256
return false;
257+
252258
int chunkIdx = getChunkIndex(pos);
253259

254260
auto &chunk = _chunks[chunkIdx];
@@ -310,6 +316,7 @@ int Chunks::getChunkIndex(qint64 absPos) {
310316
}
311317

312318
if (foundIdx == -1) {
319+
QMutexLocker locker(&_mutex);
313320
Chunk newChunk;
314321
qint64 readAbsPos = absPos - ioDelta;
315322
qint64 readPos = (readAbsPos & READ_CHUNK_MASK);

3rdparty/QHexView/QHexEdit2/chunks.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343

4444
#include <QByteArray>
4545
#include <QList>
46+
#include <QMutex>
4647
#include <QObject>
4748

4849
struct Chunk {
@@ -90,6 +91,7 @@ class Chunks : public QObject {
9091

9192
private:
9293
QIODevice *_ioDevice;
94+
mutable QMutex _mutex;
9395
qint64 _size;
9496
QList<Chunk> _chunks;
9597
};

3rdparty/WingCodeEdit

3rdparty/as-debugger/as_debugger.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,7 @@ void asIDBScope::CalcLocals(asIDBDebugger &dbg, asIScriptFunction *function,
139139

140140
asIDBTypeId typeKey{thisTypeId, asTM_NONE};
141141

142-
const std::string_view viewType =
143-
cache.GetTypeNameFromType(typeKey);
142+
const auto viewType = cache.GetTypeNameFromType(typeKey);
144143

145144
asIDBVarAddr idKey{thisTypeId, false, thisPtr};
146145

@@ -173,7 +172,7 @@ void asIDBScope::CalcLocals(asIDBDebugger &dbg, asIScriptFunction *function,
173172
? fmt::format("{} (&{})", name, n)
174173
: fmt::format("&{}", n);
175174

176-
const std::string_view viewType = cache.GetTypeNameFromType(typeKey);
175+
const auto viewType = cache.GetTypeNameFromType(typeKey);
177176

178177
asIDBVarAddr idKey{typeId, (modifiers & asTM_CONST) != 0, ptr};
179178

@@ -191,10 +190,9 @@ void asIDBScope::CalcLocals(asIDBDebugger &dbg, asIScriptFunction *function,
191190

192191
/*virtual*/ void asIDBCache::Refresh() {}
193192

194-
/*virtual*/ const std::string_view
195-
asIDBCache::GetTypeNameFromType(asIDBTypeId id) {
193+
/*virtual*/ const std::string asIDBCache::GetTypeNameFromType(asIDBTypeId id) {
196194
if (auto f = type_names.find(id); f != type_names.end())
197-
return f->second.c_str();
195+
return f->second;
198196

199197
auto type = ctx->GetEngine()->GetTypeInfoById(id.typeId);
200198
const char *rawName;
@@ -250,8 +248,8 @@ asIDBCache::GetTypeNameFromType(asIDBTypeId id) {
250248
: ((id.modifiers & asTM_INOUTREF) == asTM_INREF) ? "&in"
251249
: ((id.modifiers & asTM_INOUTREF) == asTM_OUTREF) ? "&out"
252250
: "");
253-
254-
return type_names.emplace(id, std::move(name)).first->second;
251+
type_names.emplace(id, std::move(name));
252+
return name;
255253
}
256254

257255
void *asIDBCache::ResolvePropertyAddress(const asIDBVarAddr &id,
@@ -560,7 +558,7 @@ asIDBCache::ResolveSubExpression(asIDBVariable::WeakPtr var,
560558
ptr = main->GetAddressOfGlobalVar(n);
561559

562560
asIDBTypeId typeKey{typeId, isConst ? asTM_CONST : asTM_NONE};
563-
const std::string_view viewType = GetTypeNameFromType(typeKey);
561+
const auto viewType = GetTypeNameFromType(typeKey);
564562

565563
asIDBVarAddr idKey{typeId, isConst, ptr};
566564

@@ -580,7 +578,7 @@ asIDBCache::ResolveSubExpression(asIDBVariable::WeakPtr var,
580578
n, &name, &nameSpace, &typeId, &isConst, nullptr, &ptr);
581579

582580
asIDBTypeId typeKey{typeId, isConst ? asTM_CONST : asTM_NONE};
583-
const std::string_view viewType = GetTypeNameFromType(typeKey);
581+
const auto viewType = GetTypeNameFromType(typeKey);
584582

585583
asIDBVarAddr idKey{typeId, isConst, ptr};
586584

@@ -1146,7 +1144,7 @@ void asIDBFileWorkspace::CompileBreakpointPositions() {
11461144
int col;
11471145
int row = ctx->GetLineNumber(0, &col, &section);
11481146

1149-
if (debugger->onLineCallBackExec) {
1147+
if (section && debugger->onLineCallBackExec) {
11501148
debugger->onLineCallBackExec(row, col, section);
11511149
}
11521150

3rdparty/as-debugger/as_debugger.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ struct asIDBVariable {
146146
bool evaluated = false;
147147
bool expandable = false;
148148
std::string value;
149-
std::string_view typeName;
149+
std::string typeName;
150150
asIDBValue stackValue;
151151

152152
// if it's a getter, this will be set.
@@ -318,7 +318,7 @@ class asIDBCache {
318318
virtual void Refresh();
319319

320320
// get a safe view into a cached type string.
321-
virtual const std::string_view GetTypeNameFromType(asIDBTypeId id);
321+
virtual const std::string GetTypeNameFromType(asIDBTypeId id);
322322

323323
// for the given type + property data, fetch the address of the
324324
// value that this property points to.

CMakeLists.txt

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,8 @@ set(CONTROL_SRC
256256
src/control/asobjtreewidget.cpp
257257
src/control/dockwidgettab.h
258258
src/control/dockwidgettab.cpp
259-
src/control/qhextextedit.h
260-
src/control/qhextextedit.cpp
259+
src/control/hexlineedit.h
260+
src/control/hexlineedit.cpp
261261
src/control/popupactionwidget.h
262262
src/control/popupactionwidget.cpp
263263
src/control/settingspopup.cpp
@@ -267,7 +267,9 @@ set(CONTROL_SRC
267267
src/control/gotolinewidget.h
268268
src/control/gotolinewidget.cpp
269269
src/control/codeeditcontrolwidget.h
270-
src/control/codeeditcontrolwidget.cpp)
270+
src/control/codeeditcontrolwidget.cpp
271+
src/control/asidbtreeview.h
272+
src/control/asidbtreeview.cpp)
271273

272274
set(CLASS_SRC
273275
src/class/logger.cpp
@@ -380,10 +382,12 @@ set(MODEL_SRC
380382
src/model/checksummodel.cpp
381383
src/model/dbgcallstackmodel.h
382384
src/model/dbgcallstackmodel.cpp
383-
src/model/dbgvarshowmodel.h
384-
src/model/dbgvarshowmodel.cpp
385385
src/model/codecompletionmodel.h
386-
src/model/codecompletionmodel.cpp)
386+
src/model/codecompletionmodel.cpp
387+
src/model/asidbtreemodel.h
388+
src/model/asidbtreemodel.cpp
389+
src/model/asidbwatchmodel.h
390+
src/model/asidbwatchmodel.cpp)
387391

388392
set(SETTING_SRC
389393
src/settings/settings.h
@@ -527,17 +531,15 @@ add_custom_target(
527531
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
528532
if(WIN32)
529533
set(app_icon_resource_windows "${CMAKE_CURRENT_SOURCE_DIR}/favicon.rc")
530-
qt_add_executable(WingHexExplorer2 MANUAL_FINALIZATION
531-
${PROJECT_SOURCES} ${app_icon_resource_windows})
532-
else()
533-
find_package(Qt6 REQUIRED COMPONENTS Widgets)
534534
find_package(Qt6 REQUIRED COMPONENTS Core)
535535

536536
qt_add_executable(WingHexExplorer2 MANUAL_FINALIZATION
537-
${PROJECT_SOURCES})
537+
${PROJECT_SOURCES} ${app_icon_resource_windows})
538538

539-
target_link_libraries(WingHexExplorer2 PRIVATE Qt6::Widgets)
540539
target_link_libraries(WingHexExplorer2 PRIVATE Qt6::Core)
540+
else()
541+
qt_add_executable(WingHexExplorer2 MANUAL_FINALIZATION
542+
${PROJECT_SOURCES})
541543
endif()
542544
endif()
543545

0 commit comments

Comments
 (0)