public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/2] gdb: testsuite: remove pass statement in can_spawn_for_attach
@ 2022-03-04 10:15 Tiezhu Yang
  2022-03-04 10:15 ` [PATCH 2/2] gdb: testsuite: fix failed testcases in gdb.base/jit-elf.exp Tiezhu Yang
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Tiezhu Yang @ 2022-03-04 10:15 UTC (permalink / raw)
  To: gdb-patches

After execute the following command:

  make check-gdb TESTS="gdb.base/attach-pie-noexec.exp"

we can see the following messages in gdb/testsuite/gdb.log:

  (gdb) gdb_do_cache_wrap ignoring pass: can spawn for attach

the pass statement is ignored, just remove them in can_spawn_for_attach.

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
 gdb/testsuite/lib/gdb.exp | 2 --
 1 file changed, 2 deletions(-)

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index a35d08a..f21b22c 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -5111,7 +5111,6 @@ gdb_caching_proc can_spawn_for_attach {
     file delete $obj
     gdb_test_multiple "attach $test_pid" "can spawn for attach" {
         -re -wrap "Attaching to process $test_pid\r\n.*No executable file now.*" {
-          pass $gdb_test_name
           kill_wait_spawned_process $test_spawn_id
           return 1
         }
@@ -5126,7 +5125,6 @@ gdb_caching_proc can_spawn_for_attach {
           return 0
         }
         -re -wrap "Attaching to process $test_pid\r\n.*XML support was disabled at compile time.*" {
-          pass $gdb_test_name
           kill_wait_spawned_process $test_spawn_id
           return 1
         }
-- 
2.1.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 2/2] gdb: testsuite: fix failed testcases in gdb.base/jit-elf.exp
  2022-03-04 10:15 [PATCH 1/2] gdb: testsuite: remove pass statement in can_spawn_for_attach Tiezhu Yang
@ 2022-03-04 10:15 ` Tiezhu Yang
  2022-03-14 13:08   ` [PING] " Tiezhu Yang
  2022-03-14 13:07 ` [PING] [PATCH 1/2] gdb: testsuite: remove pass statement in can_spawn_for_attach Tiezhu Yang
  2022-03-16  1:21 ` Simon Marchi
  2 siblings, 1 reply; 6+ messages in thread
From: Tiezhu Yang @ 2022-03-04 10:15 UTC (permalink / raw)
  To: gdb-patches

If /proc/sys/kernel/yama/ptrace_scope is 0 or you are root user,
When execute the following command:

  make check-gdb TESTS="gdb.base/jit-elf.exp"

we can see the following messages in gdb/testsuite/gdb.log:

  attach 3431435
  ...
  Unable to read JIT descriptor from remote memory
  0x00007fafc9384334 in ?? ()
  (gdb) FAIL: gdb.base/jit-elf.exp: can spawn for attach

or

  attach 1155345
  ...
  Unsupported JIT protocol version 0 in descriptor (expected 1)
  0x00007f01d130337a in clock_nanosleep@GLIBC_2.2.5 () from /lib64/libc.so.6
  (gdb) FAIL: gdb.base/jit-elf.exp: can spawn for attach

handle the cases related with "*JIT*" in can_spawn_for_attach to
fix the above failed testcases.

If /proc/sys/kernel/yama/ptrace_scope is 1 and you are normal user,
When execute the following command:

  make check-gdb TESTS="gdb.base/jit-elf.exp"

we can see the following messages in gdb/testsuite/gdb.log:

  attach 1350549
  A program is being debugged already.  Kill it? (y or n) y
  Attaching to program: /home/yangtiezhu/build/gdb/testsuite/outputs/gdb.base/jit-elf/jit-elf-main, process 1350549
  ptrace: Operation not permitted.
  (gdb) FAIL: gdb.base/jit-elf.exp: can spawn for attach

also handle the above case in can_spawn_for_attach.

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
 gdb/testsuite/lib/gdb.exp | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index f21b22c..8db5d1a 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -5119,6 +5119,11 @@ gdb_caching_proc can_spawn_for_attach {
           kill_wait_spawned_process $test_spawn_id
           return 0
         }
+        -re -wrap "Attaching to program: .*, process $test_pid\r\n.*ptrace: Operation not permitted\\." {
+          unsupported "$gdb_test_name (Operation not permitted)"
+          kill_wait_spawned_process $test_spawn_id
+          return 0
+        }
         -re -wrap "Attaching to process $test_pid\r\n.*Attaching to process $test_pid failed" {
           unsupported "$gdb_test_name (Attaching to process failed)"
           kill_wait_spawned_process $test_spawn_id
@@ -5128,6 +5133,10 @@ gdb_caching_proc can_spawn_for_attach {
           kill_wait_spawned_process $test_spawn_id
           return 1
         }
+        -re -wrap ".*JIT.*" {
+          kill_wait_spawned_process $test_spawn_id
+          return 1
+        }
         -re "A program is being debugged already.  Kill it. .y or n. " {
           send_gdb "y\n"
           exp_continue
-- 
2.1.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PING] [PATCH 1/2] gdb: testsuite: remove pass statement in can_spawn_for_attach
  2022-03-04 10:15 [PATCH 1/2] gdb: testsuite: remove pass statement in can_spawn_for_attach Tiezhu Yang
  2022-03-04 10:15 ` [PATCH 2/2] gdb: testsuite: fix failed testcases in gdb.base/jit-elf.exp Tiezhu Yang
@ 2022-03-14 13:07 ` Tiezhu Yang
  2022-03-16  1:21 ` Simon Marchi
  2 siblings, 0 replies; 6+ messages in thread
From: Tiezhu Yang @ 2022-03-14 13:07 UTC (permalink / raw)
  To: gdb-patches



On 03/04/2022 06:15 PM, Tiezhu Yang wrote:
> After execute the following command:
>
>   make check-gdb TESTS="gdb.base/attach-pie-noexec.exp"
>
> we can see the following messages in gdb/testsuite/gdb.log:
>
>   (gdb) gdb_do_cache_wrap ignoring pass: can spawn for attach
>
> the pass statement is ignored, just remove them in can_spawn_for_attach.
>
> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
> ---
>  gdb/testsuite/lib/gdb.exp | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
> index a35d08a..f21b22c 100644
> --- a/gdb/testsuite/lib/gdb.exp
> +++ b/gdb/testsuite/lib/gdb.exp
> @@ -5111,7 +5111,6 @@ gdb_caching_proc can_spawn_for_attach {
>      file delete $obj
>      gdb_test_multiple "attach $test_pid" "can spawn for attach" {
>          -re -wrap "Attaching to process $test_pid\r\n.*No executable file now.*" {
> -          pass $gdb_test_name
>            kill_wait_spawned_process $test_spawn_id
>            return 1
>          }
> @@ -5126,7 +5125,6 @@ gdb_caching_proc can_spawn_for_attach {
>            return 0
>          }
>          -re -wrap "Attaching to process $test_pid\r\n.*XML support was disabled at compile time.*" {
> -          pass $gdb_test_name
>            kill_wait_spawned_process $test_spawn_id
>            return 1
>          }
>

Any comments?

Thanks,
Tiezhu


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PING] [PATCH 2/2] gdb: testsuite: fix failed testcases in gdb.base/jit-elf.exp
  2022-03-04 10:15 ` [PATCH 2/2] gdb: testsuite: fix failed testcases in gdb.base/jit-elf.exp Tiezhu Yang
@ 2022-03-14 13:08   ` Tiezhu Yang
  0 siblings, 0 replies; 6+ messages in thread
From: Tiezhu Yang @ 2022-03-14 13:08 UTC (permalink / raw)
  To: gdb-patches



On 03/04/2022 06:15 PM, Tiezhu Yang wrote:
> If /proc/sys/kernel/yama/ptrace_scope is 0 or you are root user,
> When execute the following command:
>
>   make check-gdb TESTS="gdb.base/jit-elf.exp"
>
> we can see the following messages in gdb/testsuite/gdb.log:
>
>   attach 3431435
>   ...
>   Unable to read JIT descriptor from remote memory
>   0x00007fafc9384334 in ?? ()
>   (gdb) FAIL: gdb.base/jit-elf.exp: can spawn for attach
>
> or
>
>   attach 1155345
>   ...
>   Unsupported JIT protocol version 0 in descriptor (expected 1)
>   0x00007f01d130337a in clock_nanosleep@GLIBC_2.2.5 () from /lib64/libc.so.6
>   (gdb) FAIL: gdb.base/jit-elf.exp: can spawn for attach
>
> handle the cases related with "*JIT*" in can_spawn_for_attach to
> fix the above failed testcases.
>
> If /proc/sys/kernel/yama/ptrace_scope is 1 and you are normal user,
> When execute the following command:
>
>   make check-gdb TESTS="gdb.base/jit-elf.exp"
>
> we can see the following messages in gdb/testsuite/gdb.log:
>
>   attach 1350549
>   A program is being debugged already.  Kill it? (y or n) y
>   Attaching to program: /home/yangtiezhu/build/gdb/testsuite/outputs/gdb.base/jit-elf/jit-elf-main, process 1350549
>   ptrace: Operation not permitted.
>   (gdb) FAIL: gdb.base/jit-elf.exp: can spawn for attach
>
> also handle the above case in can_spawn_for_attach.
>
> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
> ---
>  gdb/testsuite/lib/gdb.exp | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
> index f21b22c..8db5d1a 100644
> --- a/gdb/testsuite/lib/gdb.exp
> +++ b/gdb/testsuite/lib/gdb.exp
> @@ -5119,6 +5119,11 @@ gdb_caching_proc can_spawn_for_attach {
>            kill_wait_spawned_process $test_spawn_id
>            return 0
>          }
> +        -re -wrap "Attaching to program: .*, process $test_pid\r\n.*ptrace: Operation not permitted\\." {
> +          unsupported "$gdb_test_name (Operation not permitted)"
> +          kill_wait_spawned_process $test_spawn_id
> +          return 0
> +        }
>          -re -wrap "Attaching to process $test_pid\r\n.*Attaching to process $test_pid failed" {
>            unsupported "$gdb_test_name (Attaching to process failed)"
>            kill_wait_spawned_process $test_spawn_id
> @@ -5128,6 +5133,10 @@ gdb_caching_proc can_spawn_for_attach {
>            kill_wait_spawned_process $test_spawn_id
>            return 1
>          }
> +        -re -wrap ".*JIT.*" {
> +          kill_wait_spawned_process $test_spawn_id
> +          return 1
> +        }
>          -re "A program is being debugged already.  Kill it. .y or n. " {
>            send_gdb "y\n"
>            exp_continue
>

Any comments?

Thanks,
Tiezhu


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] gdb: testsuite: remove pass statement in can_spawn_for_attach
  2022-03-04 10:15 [PATCH 1/2] gdb: testsuite: remove pass statement in can_spawn_for_attach Tiezhu Yang
  2022-03-04 10:15 ` [PATCH 2/2] gdb: testsuite: fix failed testcases in gdb.base/jit-elf.exp Tiezhu Yang
  2022-03-14 13:07 ` [PING] [PATCH 1/2] gdb: testsuite: remove pass statement in can_spawn_for_attach Tiezhu Yang
@ 2022-03-16  1:21 ` Simon Marchi
  2022-03-16  6:15   ` Tiezhu Yang
  2 siblings, 1 reply; 6+ messages in thread
From: Simon Marchi @ 2022-03-16  1:21 UTC (permalink / raw)
  To: Tiezhu Yang, gdb-patches

Hi Tiezhu,

Did you consider changing the approach to what Pedro suggested here?

https://sourceware.org/pipermail/gdb-patches/2022-March/186311.html

I have to admit that I approved your patch because I didn't really have
a better suggestion, and I know that it's a real problem (which I
encounter myself sometimes).  But Pedro's suggestion seems more
straightforward.

Simon

On 2022-03-04 05:15, Tiezhu Yang wrote:
> After execute the following command:
> 
>   make check-gdb TESTS="gdb.base/attach-pie-noexec.exp"
> 
> we can see the following messages in gdb/testsuite/gdb.log:
> 
>   (gdb) gdb_do_cache_wrap ignoring pass: can spawn for attach
> 
> the pass statement is ignored, just remove them in can_spawn_for_attach.
> 
> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
> ---
>  gdb/testsuite/lib/gdb.exp | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
> index a35d08a..f21b22c 100644
> --- a/gdb/testsuite/lib/gdb.exp
> +++ b/gdb/testsuite/lib/gdb.exp
> @@ -5111,7 +5111,6 @@ gdb_caching_proc can_spawn_for_attach {
>      file delete $obj
>      gdb_test_multiple "attach $test_pid" "can spawn for attach" {
>          -re -wrap "Attaching to process $test_pid\r\n.*No executable file now.*" {
> -          pass $gdb_test_name
>            kill_wait_spawned_process $test_spawn_id
>            return 1
>          }
> @@ -5126,7 +5125,6 @@ gdb_caching_proc can_spawn_for_attach {
>            return 0
>          }
>          -re -wrap "Attaching to process $test_pid\r\n.*XML support was disabled at compile time.*" {
> -          pass $gdb_test_name
>            kill_wait_spawned_process $test_spawn_id
>            return 1
>          }

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] gdb: testsuite: remove pass statement in can_spawn_for_attach
  2022-03-16  1:21 ` Simon Marchi
@ 2022-03-16  6:15   ` Tiezhu Yang
  0 siblings, 0 replies; 6+ messages in thread
From: Tiezhu Yang @ 2022-03-16  6:15 UTC (permalink / raw)
  To: Simon Marchi, gdb-patches



On 03/16/2022 09:21 AM, Simon Marchi wrote:
> Hi Tiezhu,
>
> Did you consider changing the approach to what Pedro suggested here?
>
> https://sourceware.org/pipermail/gdb-patches/2022-March/186311.html
>
> I have to admit that I approved your patch because I didn't really have
> a better suggestion, and I know that it's a real problem (which I
> encounter myself sometimes).  But Pedro's suggestion seems more
> straightforward.

OK, thank you, I will send patches later.

Thanks,
Tiezhu

>
> Simon
>
> On 2022-03-04 05:15, Tiezhu Yang wrote:
>> After execute the following command:
>>
>>   make check-gdb TESTS="gdb.base/attach-pie-noexec.exp"
>>
>> we can see the following messages in gdb/testsuite/gdb.log:
>>
>>   (gdb) gdb_do_cache_wrap ignoring pass: can spawn for attach
>>
>> the pass statement is ignored, just remove them in can_spawn_for_attach.
>>
>> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
>> ---
>>  gdb/testsuite/lib/gdb.exp | 2 --
>>  1 file changed, 2 deletions(-)
>>
>> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
>> index a35d08a..f21b22c 100644
>> --- a/gdb/testsuite/lib/gdb.exp
>> +++ b/gdb/testsuite/lib/gdb.exp
>> @@ -5111,7 +5111,6 @@ gdb_caching_proc can_spawn_for_attach {
>>      file delete $obj
>>      gdb_test_multiple "attach $test_pid" "can spawn for attach" {
>>          -re -wrap "Attaching to process $test_pid\r\n.*No executable file now.*" {
>> -          pass $gdb_test_name
>>            kill_wait_spawned_process $test_spawn_id
>>            return 1
>>          }
>> @@ -5126,7 +5125,6 @@ gdb_caching_proc can_spawn_for_attach {
>>            return 0
>>          }
>>          -re -wrap "Attaching to process $test_pid\r\n.*XML support was disabled at compile time.*" {
>> -          pass $gdb_test_name
>>            kill_wait_spawned_process $test_spawn_id
>>            return 1
>>          }


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-03-16  6:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-04 10:15 [PATCH 1/2] gdb: testsuite: remove pass statement in can_spawn_for_attach Tiezhu Yang
2022-03-04 10:15 ` [PATCH 2/2] gdb: testsuite: fix failed testcases in gdb.base/jit-elf.exp Tiezhu Yang
2022-03-14 13:08   ` [PING] " Tiezhu Yang
2022-03-14 13:07 ` [PING] [PATCH 1/2] gdb: testsuite: remove pass statement in can_spawn_for_attach Tiezhu Yang
2022-03-16  1:21 ` Simon Marchi
2022-03-16  6:15   ` Tiezhu Yang

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).