MCPcopy Create free account
hub / github.com/MJx0/KittyMemoryEx / setSoftBreakpointAndWait

Method setSoftBreakpointAndWait

KittyMemoryEx/KittyTrace.cpp:877–1077  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

875 break;
876
877 KITTY_LOGE("callSyscall(%d): Process didn't stop after syscall!", int(sysnr));
878
879 KITTY_LOGE("callSyscall(%d): PC(%p) | RET(%p).",
880 int(sysnr),
881 (void *)(return_regs.KT_REG_PC),
882 (void *)(return_regs.KT_REG_RET));
883
884 siginfo_t si = {};
885 getSignalInfo(&si);
886
887 KITTY_LOGE("callSyscall(%d): SIG(%s) | CODE(%d) | ADDR(%p).",
888 int(sysnr),
889 strsignal(si.si_signo),
890 si.si_code,
891 (void *)(si.si_addr));
892
893 auto map = KittyMemoryEx::getAddressMap(_pid, uintptr_t(si.si_addr));
894 if (map.isValid())
895 {
896 KITTY_LOGE("callSyscall(%d): MAP(<base>+%p) %s",
897 int(sysnr),
898 (void *)((map.offset + uintptr_t(si.si_addr)) - map.startAddress),
899 map.toString().c_str());
900 }
901
902 if (!cont(WSTOPSIG(status)))
903 return failure_return(KT_RP_CALL_CONT_FAILED);
904
905 return failure_return(KT_RP_CALL_MISMATCH_STOP);
906
907 } while (true);
908
909 kitty_rp_call_t result = {KT_RP_CALL_SUCCESS, {static_cast<intptr_t>(return_regs.KT_REG_RET)}};
910
911 if (_syscallGadget == 0)
912 {
913 if (!pokeMem(target_pc_mem, backup_code.data(), backup_code.size()))
914 {
915 KITTY_LOGW("callSyscall(%d): Failed to restore PC(%p) memory code!", int(sysnr), (void *)target_pc_mem);
916 }
917 }
918
919 // Restore regs
920 if (_autoRestoreRegs)
921 setRegs(&backup_regs);
922
923 KITTY_LOGD("callSyscall(%d): returned %p.", int(sysnr), (void *)result.result.ptr);
924 return result;
925}
926
927KT_BP_RESULT KittyTraceMgr::setSoftBreakpointAndWait(uintptr_t address,
928 const std::function<bool(user_regs_struct regs)> &cb,
929 int timeout_ms)
930{
931 if (!_attached || _pid <= 0 || address == 0)
932 return KT_BP_FAILED;
933
934#if defined(__arm__)

Callers

nothing calls this directly

Calls 3

getAddressMapFunction · 0.85
toStringMethod · 0.80
isValidMethod · 0.45

Tested by

no test coverage detected