public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Bernd Edlinger <bernd.edlinger@hotmail.de>
To: Pedro Alves <pedro@palves.net>, Tom Tromey <tom@tromey.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 09/12] gdb_target_is_native -> gdb_protocol_is_native
Date: Thu, 9 May 2024 20:44:07 +0200	[thread overview]
Message-ID: <PAXP193MB12964A598DC14888A8293CCDE4E62@PAXP193MB1296.EURP193.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <275dc4af-a3ac-4e3b-96f0-6bc60a3a3f99@palves.net>

On 5/9/24 17:49, Pedro Alves wrote:
> On 2024-05-09 16:01, Bernd Edlinger wrote:
>> On 5/9/24 15:31, Pedro Alves wrote:
>>>
>>> On 2024-05-09 14:19, Bernd Edlinger wrote:
>>>> Hmm, okay, it is better than now, 
>>>
>>> Indeed, seems strictly better.  Some tests that are meant for the native target are now properly
>>> skipped.
>>>
>>>> but the test casese that are affected, would probably
>>>> be broken by this change, if my target toolchain would either have the -linux in the name,
>>>> or the newlib would have a sleep and/or support the #include <sys/mman.h>.
>>>
>>> I am afraid I don't know what you mean by this.  Why would they be broken?  Can you clarify?
>>
>> What I mean is this:
>>
>> there are in total 44 test cases failed to compile because of undefined reference to sleep, usleep or nanosleep
>> with your patch it is now one less.
>>
>> But it would be piece of cake to implement some functions like
>> sleep(), usleep(), and nanosleep in the newlib, and then make the simulator simulate it.
>>
>> Likewise there are currently 5 test cases failed to compile because of missing sys/mman.h header,
>> and with your patch it will be one less, but what if we want to add that to the
>> simulator, why cant we simulate a linux O/S?
>>
>> What is so special in the one test case that changed the behavior, that
>> explains why the other 4 are good enough to try to include, and see if <sys/mman.h> works?
>>
> 
> The gdb.base/load-command.exp testcase just doesn't make sense to test with the native
> target, since with the native target, you don't use the "load" command to load programs.
> So the testcase checks for that:
> 
> if [gdb_protocol_is_native] {
>     unsupported "the native target does not support the load command"
>     return
> }
> 
> Normally, a testcase that checks whether it is testing with the native target does so because it is
> testing some feature of the native target (the ptrace support, etc.), and so such an early check
> isn't that much about whether sleep or sys/mman.h exists (they don't exist on native Windows,
> for example, and there are native-only tests that you'd still want to run there).
> 
> If a testcase should run against the sim target and would no longer run because we set
> gdb_protocol, then that would be a problem with the testcase itself, for using the wrong
> predicate to skip itself.  We've had plenty of cases of testcases using the wrong
> predicate over the years, that is something that we're fixing pretty frequently, so
> please don't be surprised if we need to do that after this change too.
> 
> Looking at gdb.base/many-headers.exp for example (the first in your previous message
> that shows compile errors), it has:
> 
> if { [target_info gdb_protocol] != "" } {
>     # Even though the feature under features being tested are supported by
>     # gdbserver, the way this test is written doesn't make it easy with a
>     # remote target.
>     unsupported "not native"
>     return
> }
> 
> Note the comment -- it is saying to skip testing on remote, but then it skips
> on any board that sets gdb_protocol to anything (meaning, not native).
> If this truly should only be skipped with remote targets, then it should instead
> do this:
> 
> require gdb_protocol_is_remote
> 
> which is equivalent to:
> 
>   if { [target_info gdb_protocol] == "remote" || [target_info gdb_protocol] == "extended-remote" } {
>      return
>   }
> 
> But, actually looking at the testcase, we see that it launches a program outside gdb, so that
> the program crashes and generates a core (core_find), and then debugs the core under gdb,
> with GDB stack limited to 4MB.  From the commit's log (31aceee86308), it's the equivalent
> of doing:
> 
>     $ ulimit -s 4096
>     $ gdb -batch ./a.out core.saved
>     [New LWP 19379]
>     Segmentation fault (core dumped)
>     ...
> 
> So, I don't really understand what the "features being tested are supported by gdbserver"
> remark is alluding to, since gdbserver does not support loading cores.  But then again,
> the test doesn't even connect to the native target nor the remote target anyhow.  So
> we could let the testcase run when testing against a gdbserver board anyhow.
> 
> Maybe what the comment is trying to say is, not easy to test with a "remote target"
> in dejagnu sense, i.e., when you have to connect to a remote host board running on a
> separate system, as in that scenario it's not easy to set ulimit.  Is so, a better
> predicate to check would be "require !is_remote host" or "require isnative".
> 
> A similar analysis would have to be done to the other testcases.

Ah, okay, thanks for the explanation.

I was probably confused that sim looks an feels like a kind of native target,
but it supports the load command, and the test cases can read and write
local files, etc.  Therefore it is of course easy to fix things in the wrong way.
So I agree with your patch, and that any fallout can be fixed later
in the test cases when necessary.


Thanks
Bernd.

  reply	other threads:[~2024-05-09 18:42 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-19 15:13 [PATCH 00/12] Fix attach/run failure handling - gdbserver & Windows, document "E.MESSAGE" RSP errors, more Pedro Alves
2024-04-19 15:13 ` [PATCH 01/12] Document conventions for describing packet syntax Pedro Alves
2024-04-19 15:25   ` Eli Zaretskii
2024-04-19 15:42     ` Eli Zaretskii
2024-04-22 19:10       ` Pedro Alves
2024-04-22 19:01     ` Pedro Alves
2024-04-22 19:44       ` Eli Zaretskii
2024-04-19 15:13 ` [PATCH 02/12] Centralize documentation of error and empty RSP responses Pedro Alves
2024-04-19 15:36   ` Eli Zaretskii
2024-04-19 15:42     ` Eli Zaretskii
2024-04-22 19:00     ` Pedro Alves
2024-04-22 19:42       ` Eli Zaretskii
2024-04-19 15:13 ` [PATCH 03/12] Document "E.MESSAGE" RSP errors Pedro Alves
2024-04-19 15:37   ` Eli Zaretskii
2024-04-22  8:50   ` Andrew Burgess
2024-04-22 19:04     ` Pedro Alves
2024-04-26 19:02       ` Pedro Alves
2024-04-26 19:18         ` Eli Zaretskii
2024-04-29 13:42         ` Andrew Burgess
2024-04-19 15:13 ` [PATCH 04/12] Windows: Fix run/attach hang after bad run/attach Pedro Alves
2024-04-19 18:35   ` Tom Tromey
2024-04-19 15:13 ` [PATCH 05/12] Fix "run" failure handling with GDBserver Pedro Alves
2024-04-19 18:41   ` Tom Tromey
2024-04-19 15:13 ` [PATCH 06/12] Improve vRun error reporting Pedro Alves
2024-04-19 18:43   ` Tom Tromey
2024-04-22 11:32     ` Alexandra Petlanova Hajkova
2024-04-19 15:13 ` [PATCH 07/12] Fix "attach" failure handling with GDBserver Pedro Alves
2024-04-19 18:47   ` Tom Tromey
2024-04-19 15:13 ` [PATCH 08/12] gdbserver: Fix vAttach response when attaching is not supported Pedro Alves
2024-04-19 18:48   ` Tom Tromey
2024-04-19 15:13 ` [PATCH 09/12] gdb_target_is_native -> gdb_protocol_is_native Pedro Alves
2024-04-19 18:50   ` Tom Tromey
2024-05-09  8:47     ` Bernd Edlinger
2024-05-09  9:47       ` Pedro Alves
2024-05-09 11:54         ` Bernd Edlinger
2024-05-09 12:05           ` Pedro Alves
2024-05-09 13:19             ` Bernd Edlinger
2024-05-09 13:31               ` Pedro Alves
2024-05-09 15:01                 ` Bernd Edlinger
2024-05-09 15:49                   ` Pedro Alves
2024-05-09 18:44                     ` Bernd Edlinger [this message]
2024-05-10 10:52                       ` [pushed] gdb sim testing, set gdb_protocol to "sim" Pedro Alves
2024-04-22  8:25   ` [PATCH 09/12] gdb_target_is_native -> gdb_protocol_is_native Aktemur, Tankut Baris
2024-04-23 12:33     ` Pedro Alves
2024-04-19 15:13 ` [PATCH 10/12] gdb_target_is_remote -> gdb_protocol_is_remote Pedro Alves
2024-04-19 18:56   ` Tom Tromey
2024-04-23 12:30     ` Pedro Alves
2024-04-22  8:30   ` Aktemur, Tankut Baris
2024-04-23 12:47     ` Pedro Alves
2024-04-24 13:48       ` Aktemur, Tankut Baris
2024-04-19 15:13 ` [PATCH 11/12] Eliminate gdb_is_target_remote / gdb_is_target_native & friends Pedro Alves
2024-04-19 18:57   ` Tom Tromey
2024-04-19 15:13 ` [PATCH 12/12] Fix gdb.base/attach.exp --pid test skipping on native-extended-gdbserver Pedro Alves
2024-04-19 18:59   ` Tom Tromey
2024-04-26 20:25 ` [PATCH 00/12] Fix attach/run failure handling - gdbserver & Windows, document "E.MESSAGE" RSP errors, more Pedro Alves

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=PAXP193MB12964A598DC14888A8293CCDE4E62@PAXP193MB1296.EURP193.PROD.OUTLOOK.COM \
    --to=bernd.edlinger@hotmail.de \
    --cc=gdb-patches@sourceware.org \
    --cc=pedro@palves.net \
    --cc=tom@tromey.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).