From: Simon Marchi <simark@simark.ca>
To: Tom de Vries <tdevries@suse.de>, gdb-patches@sourceware.org
Subject: Re: [PATCH v2] [gdb/testsuite] Fix gdb.base/enum_cond.exp on arm-linux
Date: Tue, 18 Mar 2025 10:47:46 -0400 [thread overview]
Message-ID: <2f8b7602-d4d8-4c04-ba70-f141f7035247@simark.ca> (raw)
In-Reply-To: <958bb09e-486d-48f1-9ad9-66b42842bd96@suse.de>
On 3/18/25 10:08 AM, Tom de Vries wrote:
> On 3/18/25 14:46, Simon Marchi wrote:
>>
>>
>> On 2025-03-18 03:28, Tom de Vries wrote:
>>> On arm-linux, I run into:
>>> ...
>>> gdb compile failed, ld: warning: enum_cond.o uses variable-size enums yet \
>>> the output is to use 32-bit enums; use of enum values across objects may fail
>>> UNTESTED: gdb.base/enum_cond.exp: failed to compile
>>> ...
>>>
>>> Fix this by using -nostdlib.
>>>
>>> Tested on arm-linux and x86_64-linux.
>>> ---
>>> gdb/testsuite/gdb.base/enum_cond.c | 16 ++++++++++++++++
>>> gdb/testsuite/gdb.base/enum_cond.exp | 15 ++++++++++++++-
>>> gdb/testsuite/lib/gdb.exp | 12 ++++++++++++
>>> 3 files changed, 42 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/gdb/testsuite/gdb.base/enum_cond.c b/gdb/testsuite/gdb.base/enum_cond.c
>>> index 35e126aed45..df8830f0c9e 100644
>>> --- a/gdb/testsuite/gdb.base/enum_cond.c
>>> +++ b/gdb/testsuite/gdb.base/enum_cond.c
>>> @@ -46,3 +46,19 @@ main (void)
>>> return 0;
>>> }
>>> +void
>>> +exit (int status)
>>> +{
>>> +#if HAVE_BUILTIN_TRAP
>>> + __builtin_trap ();
>>> +#endif
>>> + while (1)
>>> + ;
>>
>> Huh, it would be nice to find something that works everywhere.
>> We do
>> have "my_exit" in lib/my-syscalls.h, which we could call, but we would
>> need to provide a syscall implementation for all arches we want to test
>> (not too hard, but still).
>>
>> What about having a global:
>>
>> volatile int *dummy = nullptr;
>>
>> and then do:
>>
>> *dummy = 1;
>>
>> Would that successfully stop the program on all known platforms?
>
> AFAIU that's undefined behaviour, so a valid implementation might just skip the store.
>
> I can submit a v3 using this (note NULL instead of nullptr since this is C, not C++):
> ...
> void
> exit (int status)
> {
> #if HAVE_BUILTIN_TRAP
> __builtin_trap ();
> #endif
>
> {
> volatile int *dummy = NULL;
> *dummy = 1;
> }
>
> while (1)
> ;
> ...
> but AFAIC I'm fine with this v2.
>
> Thanks,
> - Tom
Ok, fair enough, that's a very edgy case anyway.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Simon
prev parent reply other threads:[~2025-03-18 14:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-18 7:28 Tom de Vries
2025-03-18 13:46 ` Simon Marchi
2025-03-18 14:08 ` Tom de Vries
2025-03-18 14:47 ` Simon Marchi [this message]
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=2f8b7602-d4d8-4c04-ba70-f141f7035247@simark.ca \
--to=simark@simark.ca \
--cc=gdb-patches@sourceware.org \
--cc=tdevries@suse.de \
/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