diff --git a/src/cross/ElfBug/ElfBug/api/elfbug_api.cpp b/src/cross/ElfBug/ElfBug/api/elfbug_api.cpp index 4f6e62ba0..82052c79a 100644 --- a/src/cross/ElfBug/ElfBug/api/elfbug_api.cpp +++ b/src/cross/ElfBug/ElfBug/api/elfbug_api.cpp @@ -165,9 +165,9 @@ protected: void cbCreateProcessEvent(const pid_t pid, const ElfBug::ptr ep) override { activePid.store(pid, std::memory_order_release); - active.store(true, std::memory_order_release); entryPoint = ep; refreshMemoryMap(); + active.store(true, std::memory_order_release); if(cb.onCreateProcess) cb.onCreateProcess(pid, ep, cb.userdata); } diff --git a/src/cross/ElfBug/ElfBug/core/Debugger.Loop.cpp b/src/cross/ElfBug/ElfBug/core/Debugger.Loop.cpp index ed98489f5..e4ddaad02 100644 --- a/src/cross/ElfBug/ElfBug/core/Debugger.Loop.cpp +++ b/src/cross/ElfBug/ElfBug/core/Debugger.Loop.cpp @@ -34,6 +34,7 @@ namespace ElfBug if(mStepPending.load(std::memory_order_acquire) && mThread) { mStepPending.store(false, std::memory_order_release); + // TODO: mPendingSignal is dropped here, decide the policy mThread->StepInto(); } else diff --git a/src/cross/ElfBug/ElfBug/core/Debugger.cpp b/src/cross/ElfBug/ElfBug/core/Debugger.cpp index b63d63055..dd023ea94 100644 --- a/src/cross/ElfBug/ElfBug/core/Debugger.cpp +++ b/src/cross/ElfBug/ElfBug/core/Debugger.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -114,9 +115,21 @@ namespace ElfBug close(pipeFds[1]); char errBuf[256] = {}; - const ssize_t n = read(pipeFds[0], errBuf, sizeof(errBuf) - 1); + ssize_t n; + do + { + n = read(pipeFds[0], errBuf, sizeof(errBuf) - 1); + } while(n == -1 && errno == EINTR); close(pipeFds[0]); + if(n == -1) + { + const std::string err = strerror(errno); + waitpid(pid, nullptr, 0); + cbInternalError("read() from child pipe failed: " + err); + return false; + } + if(n > 0) { waitpid(pid, nullptr, 0);