public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "peter0x44 at disroot dot org" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug gdb/31194] Stepping on "int3" instruction fails assertion.
Date: Sun, 31 Dec 2023 01:46:14 +0000	[thread overview]
Message-ID: <bug-31194-4717-44MTsyic59@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-31194-4717@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=31194

--- Comment #7 from Peter0x44 <peter0x44 at disroot dot org> ---
> I'm not really sure how int3 is supposed to be handled
Perhaps it would be beneficial to state what my preferences would be.
On Windows it is common to use it as a "continuable assertion", the Microsoft
compiler has the intrinsic __debugbreak() to generate it, along with clang
__builtin_debugtrap(). I expect it to break pointing to the line containing the
assertion, if defined in a macro likeso:
#define assert(e) do { if (!e) __asm__("int3") } while (0)

After which "continue" or "step" would behave "as expected"
Maybe there's some cases I haven't considered where this could be problematic,
or the issue actually lies with the gcc/clang generated debug info. To be
clear, the assertion fails in the same way even if you build the executable
using the clang __builtin_debugtrap() intrinsic.

There is a workaround for my case - you can use __builtin_trap, which compiles
to "ud2", and then use `j +1` to skip the ud2 when debugging. However, gcc
treats code following __builtin_trap() as dead, so it's not always possible to
step past the assertion.

Related info that made me think about assert macros more generally:
https://nullprogram.com/blog/2022/06/26/

Some of this is off topic but I figure more info can't hurt.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  parent reply	other threads:[~2023-12-31  1:46 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-27 22:54 [Bug gdb/31194] New: " peter0x44 at disroot dot org
2023-12-27 22:58 ` [Bug gdb/31194] " peter0x44 at disroot dot org
2023-12-27 23:04 ` peter0x44 at disroot dot org
2023-12-28  9:51 ` ssbssa at sourceware dot org
2023-12-28 11:25 ` vries at gcc dot gnu.org
2023-12-28 16:42 ` tromey at sourceware dot org
2023-12-29  5:57 ` vries at gcc dot gnu.org
2023-12-29  6:25 ` vries at gcc dot gnu.org
2023-12-29 18:25 ` tromey at sourceware dot org
2023-12-30 17:30 ` tromey at sourceware dot org
2023-12-31  1:46 ` peter0x44 at disroot dot org [this message]
2023-12-31  5:15 ` vries at gcc dot gnu.org
2023-12-31 20:02 ` tromey at sourceware dot org
2023-12-31 20:45 ` tromey at sourceware dot org
2024-01-07 22:03 ` peter0x44 at disroot dot org
2024-01-10 18:43 ` tromey at sourceware dot org
2024-02-08 19:10 ` tromey at sourceware dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-31194-4717-44MTsyic59@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).