From: Simon Marchi via Gdb-patches <gdb-patches@sourceware.org>
To: Pedro Alves <pedro@palves.net>, gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb: make "start" breakpoint inferior-specific
Date: Tue, 8 Nov 2022 15:14:02 -0500 [thread overview]
Message-ID: <b881b3db-fb81-b4fa-cff0-208f1584f85f@efficios.com> (raw)
In-Reply-To: <e79677a3-5268-7c27-ca83-8a7018a525df@palves.net>
On 11/8/22 14:43, Pedro Alves wrote:
> On 2022-08-04 6:40 p.m., Simon Marchi via Gdb-patches wrote:
>> +int
>> +main (int argc, const char **argv)
>> +{
>> + if (argc == 999)
>> + return 0;
>> +
>> + for (;;)
>> + main (999, NULL);
>> +
>
> Calling main triggers undefined behavior. The C++ Standard says [1]
> "The function main shall not be used within a program."
>
> E.g., on some targets, global constructors are called from the start of main, by a magic
> call the compiler injects. Calling main like that would run global ctors twice on such
> ports.
>
> [1] https://eel.is/c++draft/basic.start.main#3
How on earth do you know the C++ standard by heart?
Ok, I think I found an alternative solution for the test, to make the
inferiors sleep a bit before main. I can achieve that in a C program
using __attribute__((constructor)), but I believe that's a GCC
extension? Otherwise, I can do it in C++ using the constructor of a
global object. Which one would be best? Or, do you see another way?
Simon
next prev parent reply other threads:[~2022-11-08 20:14 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-04 17:40 Simon Marchi via Gdb-patches
2022-08-17 17:56 ` Simon Marchi via Gdb-patches
2022-08-31 14:03 ` Bruno Larsen via Gdb-patches
2022-11-04 16:52 ` Simon Marchi via Gdb-patches
2022-11-07 8:14 ` Bruno Larsen via Gdb-patches
2022-11-08 17:24 ` Tom Tromey
2022-09-01 10:42 ` Andrew Burgess via Gdb-patches
2022-11-04 17:24 ` Simon Marchi via Gdb-patches
[not found] ` <8735asb7cj.fsf@redhat.com>
2022-11-09 13:19 ` Simon Marchi via Gdb-patches
2022-11-08 19:43 ` Pedro Alves
2022-11-08 20:14 ` Simon Marchi via Gdb-patches [this message]
2022-11-08 21:09 ` Pedro Alves
2022-11-08 21:20 ` [PATCH v2] " Simon Marchi via Gdb-patches
2022-11-10 16:45 ` Pedro Alves
2022-11-10 17:33 ` Simon Marchi via Gdb-patches
2022-11-10 17:36 ` Simon Marchi via Gdb-patches
2022-11-10 17:47 ` Pedro Alves
2022-11-10 17:53 ` Simon Marchi via Gdb-patches
2022-11-11 12:37 ` Tom de Vries via Gdb-patches
2022-11-11 13:53 ` Simon Marchi via Gdb-patches
2022-11-11 15:21 ` Tom de Vries via Gdb-patches
2022-11-11 19:03 ` Simon Marchi via Gdb-patches
2022-11-12 10:43 ` Tom de Vries via Gdb-patches
2022-11-14 11:29 ` Tom de Vries via Gdb-patches
2022-11-14 13:19 ` Simon Marchi via Gdb-patches
2022-11-14 14:18 ` Tom de Vries via Gdb-patches
2022-11-16 16:22 ` Tom Tromey
2022-11-16 16:26 ` Simon Marchi via Gdb-patches
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=b881b3db-fb81-b4fa-cff0-208f1584f85f@efficios.com \
--to=gdb-patches@sourceware.org \
--cc=pedro@palves.net \
--cc=simon.marchi@efficios.com \
/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