Skip to content

[cpu] support TF single-stepping to make gdb work#1574

Closed
lqs wants to merge 1 commit into
copy:masterfrom
lqs:flag-trap
Closed

[cpu] support TF single-stepping to make gdb work#1574
lqs wants to merge 1 commit into
copy:masterfrom
lqs:flag-trap

Conversation

@lqs

@lqs lqs commented Jun 2, 2026

Copy link
Copy Markdown

The trap flag (FLAG_TRAP) was previously logged as unsupported and cleared on update_eflags, so any guest debugger relying on single-stepping didn't work.

This adds proper TF handling: when TF is set, cycle_internal interprets one instruction at a time and raises #DB afterwards. DR6.BS is set so the guest can distinguish a single-step trap from a hardware breakpoint.

With this, gdb breakpoints and single-stepping (stepi/continue over breakpoints) now work inside the guest.

Fixes #278.

@copy

copy commented Jun 6, 2026

Copy link
Copy Markdown
Owner

Hi @lqs, thanks for the contribution. Just as a heads-up, it will be very difficult to get this merged. I will need the following:

  • an assurance that all code here is entirely written by yourself (as opposed to code-generating llms). I don't review llm-generated code on principle
  • handle trap-inhibit instructions (e.g. mov SS)
  • handle jit-compiled code. It will need to bail out when popf or another instruction sets TF
  • verify interaction with various system instructions (e.g. INT, IRET, HLT, STI, ...)
  • test cases
  • a benchmark that shows this doesn't negatively affect performance

@lqs

lqs commented Jun 6, 2026

Copy link
Copy Markdown
Author

Thanks for the review. Apologies, I missed this policy. The code was llm-generated, so I'll close the PR. Sorry for the noise.

@lqs lqs closed this Jun 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SIGSEGV when run a program in gdb

2 participants