Skip to content
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

Add "nop" to IM_DEBUG_BREAK macro to work around GDB bug #7266

Closed
wants to merge 2 commits into from

Conversation

Peter0x44
Copy link
Contributor

There are two issues here - first, this macro uses AT&T specific syntax with $, which is not necessary. Also, some assemblers (nasm) emit different bytes for "int 3" and "int3" (cd 03 vs cc), so it's better to use "int3" for consistency.

More importantly, GDB (as of 14.1) has some failing assertion whenever stepping after hitting a lone "int3" instruction. This makes it practically useless, as is. For some reason, putting a nop afterwards as a workaround is okay.

Related discussions:
https://sourceware.org/bugzilla/show_bug.cgi?id=31194
https://lists.sr.ht/~skeeto/public-inbox/%3C2d3d7662a361ddd049f7dc65b94cecdd%40disroot.org%3E

Also, clang's __builtin_debugtrap() runs into this same issue with GDB. I feel uncomfortable commenting the __builtin_debugtrap() line out, but if it's desired, I'll do so.

Of course, there's also the possibility this change is entirely undesired and can be fixed on my end by defining this macro "properly" on my own.

There are two issues here - first, this macro uses AT&T specific syntax with $, which is not necessary. Also, some assemblers (nasm) emit different bytes for "int 3" and "int3", so it's better to use "int3" (cd 03 vs cc)

More importantly, GDB has some failing assertion whenever stepping after hitting an "int3" instruction. This makes it practically useless, as is. For some reason, putting a nop afterwards as a workaround is okay.

Related discussions:
https://sourceware.org/bugzilla/show_bug.cgi?id=31194
https://lists.sr.ht/~skeeto/public-inbox/%3C2d3d7662a361ddd049f7dc65b94cecdd%40disroot.org%3E
@Peter0x44 Peter0x44 mentioned this pull request Jan 25, 2024
ocornut pushed a commit that referenced this pull request Jan 25, 2024
)

There are two issues here - first, this macro uses AT&T specific syntax with $, which is not necessary. Also, some assemblers (nasm) emit different bytes for "int 3" and "int3", so it's better to use "int3" (cd 03 vs cc)

More importantly, GDB has some failing assertion whenever stepping after hitting an "int3" instruction. This makes it practically useless, as is. For some reason, putting a nop afterwards as a workaround is okay.

Related discussions:
https://sourceware.org/bugzilla/show_bug.cgi?id=31194
https://lists.sr.ht/~skeeto/public-inbox/%3C2d3d7662a361ddd049f7dc65b94cecdd%40disroot.org%3E
@ocornut
Copy link
Owner

ocornut commented Jan 25, 2024

Thank you Peter! Merged as f1960b6

@ocornut ocornut closed this Jan 25, 2024
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.

2 participants