-
Notifications
You must be signed in to change notification settings - Fork 747
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Qiling.emu_stop()
does not stop the emulator when gdb debugger is attached
#1310
Comments
Thank you for your response. Sorry I didn't include sufficient instructions to reproduce. I recorded a video of how to reproduce the bug here: https://user-images.githubusercontent.com/22305849/217649795-98f72b3b-9dfc-4c38-9049-4afe84de8371.mp4 When I reach the target instruction using #!/usr/bin/env python3
from qiling import Qiling
from qiling.const import QL_VERBOSE
ROOTFS = r'/'
ARGV = [fr'./test']
if __name__ == "__main__":
ql = Qiling(ARGV, ROOTFS, verbose=QL_VERBOSE.DEFAULT)
ql.debugger = True
ba = ql.loader.images[0].base
print("BASE ADDRESS:", hex(ba))
foo_begins = ba + 0x1135
foo_ends = ba + 0x1158
def print_asm(ql: Qiling, address: int, size: int):
print(f"INSTRUCTION: {address:08x}")
if address == foo_ends:
print("--- TARGET INSTRUCTION REACHED ---")
ql.emu_stop()
ql.hook_code(print_asm, begin=ba + 0x1000, end=ba + 0x2000)
ql.run() Log of inferior Python script:
Log of gdb session:
|
OK, I understand this now and found the reason for this behavior. |
Awesome! Thank you for fixing it. |
Hey @bstee615, |
Wow, this is awesome! Thank you very much. |
Describe the bug
Thank you for your work on this useful framework.
When executing this sample code, Qiling waits for gdb to connect. I attached gdb using
target remote 127.0.0.1:9999
, then used thestepi
command repeatedly until the executable reached the entry offoo
. When I usestepi
on the entry tofoo
, then my script's functionprint_asm
callsql.emu_stop()
, which should stop the emulator, but the emulator does not stop - it remains on the same instruction. Because of this, if instead I use thestep
command to step to the next statement, then gdb hang in an infinite loop.Sample Code
Qiling script:
Log of qiling script output: test_gdb.log
Expected behavior
When the
ql.emu_stop()
line is executed, emulation will quit and gdb will detach.Additional context
I ran this test case on the official Docker container
qilingframework/qiling:latest
with the latest code from thedev
branch.It should be possible to reproduce the bug with any executable by calling
Qiling.emu_stop()
during execution.Here is the target program I used:
Compiled executable (unzip it first): test.zip
The text was updated successfully, but these errors were encountered: