@@ -2075,16 +2075,23 @@ void CutterCore::attachDebug(int pid)
2075
2075
offsetPriorDebugging = getOffset ();
2076
2076
}
2077
2077
2078
- CORE_LOCK ();
2079
- setConfig (" cfg.debug" , true );
2080
- auto uri = rz_str_newf (" dbg://%d" , pid);
2081
- if (currentlyOpenFile.isEmpty ()) {
2082
- rz_core_file_open_load (core, uri, 0 , RZ_PERM_R, false );
2083
- } else {
2084
- rz_core_file_reopen_remote_debug (core, uri, 0 );
2078
+ if (!asyncTask (
2079
+ [&](RzCore *core) {
2080
+ // cannot use setConfig because core is
2081
+ // already locked, which causes a deadlock
2082
+ rz_config_set_b (core->config , " cfg.debug" , true );
2083
+ auto uri = rz_str_newf (" dbg://%d" , pid);
2084
+ if (currentlyOpenFile.isEmpty ()) {
2085
+ rz_core_file_open_load (core, uri, 0 , RZ_PERM_R, false );
2086
+ } else {
2087
+ rz_core_file_reopen_remote_debug (core, uri, 0 );
2088
+ }
2089
+ free (uri);
2090
+ return nullptr ;
2091
+ },
2092
+ debugTask)) {
2093
+ return ;
2085
2094
}
2086
- free (uri);
2087
-
2088
2095
emit debugTaskStateChanged ();
2089
2096
2090
2097
connect (debugTask.data (), &RizinTask::finished, this , [this , pid]() {
@@ -2144,7 +2151,10 @@ void CutterCore::stopDebug()
2144
2151
rz_core_analysis_esil_trace_stop (core);
2145
2152
currentlyEmulating = false ;
2146
2153
} else {
2147
- rz_core_debug_process_close (core);
2154
+ // ensure we have opened a file.
2155
+ if (core->io ->desc ) {
2156
+ rz_core_debug_process_close (core);
2157
+ }
2148
2158
currentlyAttachedToPID = -1 ;
2149
2159
}
2150
2160
@@ -4579,4 +4589,4 @@ void CutterCore::writeGraphvizGraphToFile(QString path, QString format, RzCoreGr
4579
4589
qWarning () << " Cannot get graph at " << RzAddressString (address);
4580
4590
}
4581
4591
}
4582
- }
4592
+ }
0 commit comments