qilingframework / qilingframework/qiling
Qiling gdbserver not handling stepi instruction
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 6.1k
- Forks
- 798
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 9
Description
Describe the bug
The gdbserver is sending a SIGTERM each time I perform the si command and this cause my gdbclient to consider the program exited although it's not.
Sample Code
Not related to any particular code, would happen with all examples.
Expected behavior
I think that the gdbserver should send the SIGTRAP signal instead.
Addtionnal context
I debugged a bit the gdbserver and I think that the cause is below : in gdb.py
def handle_s(subcmd: str) -> Reply:
"""Perform a single step.
"""
self.gdb.resume_emu(steps=1)
# if emulation has been stopped, signal program termination
# ===== The condition is always True ===
if self.ql.emu_state is QL_STATE.STOPPED:
return f'S{SIGTERM:02x}'
# ====================================================================
# otherwise, this is just single stepping
return f'S{SIGTRAP:02x}'
Wonder if this condition is useful in a particular case that is not related to mine. I've tested to comment these two lines and everything works perfectly fine after that. I think it also causes other bugs with breakpoint but not so sure and didn't have the time to verify this point.
Additional context
I worked with the dev branch.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in gdb.py at handle_s and reproduce the issue by using the si command against an example. Check the gdbserver response after single-stepping and verify that an active emulation returns SIGTRAP rather than SIGTERM. Also investigate whether the same condition affects breakpoint handling, as reported but not confirmed in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools, reverse-engineering
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100