Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
About breakpoints and the JIT cache
#1
1. Is the fact that execute breakpoints only work with dynarec enabled a bug or intended?

2. Is there any way to flush the JIT cache manually? I'm writing a patch for a game that involves injecting a lot of code, and to simplify the injection I wrote a big "cheat" code that loads all of the instructions into memory. But using this code causes the entire emulator to crash unless dynarec is disabled, which wouldn't be a problem except I can't use execute breakpoints in interpreter mode. So I either have to test my code without breakpoints or enable dynarec and right click->"assemble opcode" for 100+ instructions. I'm guessing it crashes because the cheat just lays a bunch of instructions into memory without telling the JIT, so is there any way to manually refresh the JIT cache after loading my code?
#2
1. Intended. Otherwise, you must build a debug build. Checking for breakpoints is extremely slow in the interpreter (even if there are 0) and not enabled in release mode. Jit only gets slower if you add memory breakpoints, and so they are always enabled.

2. You should be able to call sceKernelIcacheInvalidateRange(). Alternatively, you can write the entire range. As long as you overwrite the first word of each block, it will automatically recompile it during jit.

If you modify (e.g. xor, add, etc.) the existing opcodes, you are very likely to cause a crash while in jit. If you are doing this, call sceKernelIcacheInvalidateRange() __BEFORE__ modifying them. Jit actually modifies the opcodes to indicate where the jitted code is in host memory, so when you alter this, it confuses jit. It's a bit of a hack but seems to work with the self-modifying code of all games we've run into.

-[Unknown]
#3
edit: ok, you can close the thread. Turns out I was just stupid and you're supposed to jump to the functions when in usermode, not syscall them directly.
#4
Closing and moving to the Development subforum.


Forum Jump: