public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH][gdb/tdep, rs6000] Don't skip system call in skip_prologue
@ 2021-11-02 11:33 Tom de Vries
  2021-11-02 16:26 ` Simon Marchi
  2021-11-02 16:54 ` Kevin Buettner
  0 siblings, 2 replies; 4+ messages in thread
From: Tom de Vries @ 2021-11-02 11:33 UTC (permalink / raw)
  To: gdb-patches; +Cc: Ulrich Weigand, Kevin Buettner, Carl Love

Hi,

I ran into a case where a breakpoint on _exit never triggered, because it was
set past the end of the _exit prologue, past the end of the exit_group system
call (which does not return).

Fix this by treating system calls the same as branches in skip_prologue:
by default, don't skip.

Tested on ppc64le-linux, on a power 8 machine.

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

Any comments?

Thanks,
- Tom

[gdb/tdep, rs6000] Don't skip system call in skip_prologue

---
 gdb/rs6000-tdep.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c
index 78b4fd1a913..4830ed22593 100644
--- a/gdb/rs6000-tdep.c
+++ b/gdb/rs6000-tdep.c
@@ -2137,6 +2137,12 @@ skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR lim_pc,
 	    /* Never skip branches.  */
 	    break;
 
+	  /* Test based on opcode and mask values of
+	     powerpc_opcodes[svc..svcla] in opcodes/ppc-opc.c.  */
+	  if ((op & 0xffff0000) == 0x44000000)
+	    /* Never skip system calls.  */
+	    break;
+
 	  if (num_skip_non_prologue_insns++ > max_skip_non_prologue_insns)
 	    /* Do not scan too many insns, scanning insns is expensive with
 	       remote targets.  */

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

* Re: [PATCH][gdb/tdep, rs6000] Don't skip system call in skip_prologue
  2021-11-02 11:33 [PATCH][gdb/tdep, rs6000] Don't skip system call in skip_prologue Tom de Vries
@ 2021-11-02 16:26 ` Simon Marchi
  2021-11-02 18:13   ` Tom de Vries
  2021-11-02 16:54 ` Kevin Buettner
  1 sibling, 1 reply; 4+ messages in thread
From: Simon Marchi @ 2021-11-02 16:26 UTC (permalink / raw)
  To: Tom de Vries, gdb-patches; +Cc: Ulrich Weigand

On 2021-11-02 7:33 a.m., Tom de Vries via Gdb-patches wrote:
> Hi,
> 
> I ran into a case where a breakpoint on _exit never triggered, because it was
> set past the end of the _exit prologue, past the end of the exit_group system
> call (which does not return).
> 
> Fix this by treating system calls the same as branches in skip_prologue:
> by default, don't skip.
> 
> Tested on ppc64le-linux, on a power 8 machine.
> 
> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28527
> 
> Any comments?
> 
> Thanks,
> - Tom
> 
> [gdb/tdep, rs6000] Don't skip system call in skip_prologue
> 
> ---
>  gdb/rs6000-tdep.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c
> index 78b4fd1a913..4830ed22593 100644
> --- a/gdb/rs6000-tdep.c
> +++ b/gdb/rs6000-tdep.c
> @@ -2137,6 +2137,12 @@ skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR lim_pc,
>  	    /* Never skip branches.  */
>  	    break;
>  
> +	  /* Test based on opcode and mask values of
> +	     powerpc_opcodes[svc..svcla] in opcodes/ppc-opc.c.  */
> +	  if ((op & 0xffff0000) == 0x44000000)
> +	    /* Never skip system calls.  */
> +	    break;
> +
>  	  if (num_skip_non_prologue_insns++ > max_skip_non_prologue_insns)
>  	    /* Do not scan too many insns, scanning insns is expensive with
>  	       remote targets.  */
> 


The explanation makes sense, but I think a powerpc maintainer should ack the
patch.

And I think it would be useful to paste the "disassembly /r" of the _exit
function in the commit message, showing where the breakpoint used to be
placed, and where it is placed now.

Simon

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

* Re: [PATCH][gdb/tdep, rs6000] Don't skip system call in skip_prologue
  2021-11-02 11:33 [PATCH][gdb/tdep, rs6000] Don't skip system call in skip_prologue Tom de Vries
  2021-11-02 16:26 ` Simon Marchi
@ 2021-11-02 16:54 ` Kevin Buettner
  1 sibling, 0 replies; 4+ messages in thread
From: Kevin Buettner @ 2021-11-02 16:54 UTC (permalink / raw)
  To: Tom de Vries; +Cc: gdb-patches, Ulrich Weigand, Carl Love

On Tue, 2 Nov 2021 12:33:04 +0100
Tom de Vries <tdevries@suse.de> wrote:

> I ran into a case where a breakpoint on _exit never triggered, because it was
> set past the end of the _exit prologue, past the end of the exit_group system
> call (which does not return).
> 
> Fix this by treating system calls the same as branches in skip_prologue:
> by default, don't skip.

LGTM.

Kevin


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

* Re: [PATCH][gdb/tdep, rs6000] Don't skip system call in skip_prologue
  2021-11-02 16:26 ` Simon Marchi
@ 2021-11-02 18:13   ` Tom de Vries
  0 siblings, 0 replies; 4+ messages in thread
From: Tom de Vries @ 2021-11-02 18:13 UTC (permalink / raw)
  To: Simon Marchi, gdb-patches; +Cc: Ulrich Weigand

On 11/2/21 5:26 PM, Simon Marchi wrote:
> On 2021-11-02 7:33 a.m., Tom de Vries via Gdb-patches wrote:
>> Hi,
>>
>> I ran into a case where a breakpoint on _exit never triggered, because it was
>> set past the end of the _exit prologue, past the end of the exit_group system
>> call (which does not return).
>>
>> Fix this by treating system calls the same as branches in skip_prologue:
>> by default, don't skip.
>>
>> Tested on ppc64le-linux, on a power 8 machine.
>>
>> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28527
>>
>> Any comments?
>>
>> Thanks,
>> - Tom
>>
>> [gdb/tdep, rs6000] Don't skip system call in skip_prologue
>>
>> ---
>>  gdb/rs6000-tdep.c | 6 ++++++
>>  1 file changed, 6 insertions(+)
>>
>> diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c
>> index 78b4fd1a913..4830ed22593 100644
>> --- a/gdb/rs6000-tdep.c
>> +++ b/gdb/rs6000-tdep.c
>> @@ -2137,6 +2137,12 @@ skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR lim_pc,
>>  	    /* Never skip branches.  */
>>  	    break;
>>  
>> +	  /* Test based on opcode and mask values of
>> +	     powerpc_opcodes[svc..svcla] in opcodes/ppc-opc.c.  */
>> +	  if ((op & 0xffff0000) == 0x44000000)
>> +	    /* Never skip system calls.  */
>> +	    break;
>> +
>>  	  if (num_skip_non_prologue_insns++ > max_skip_non_prologue_insns)
>>  	    /* Do not scan too many insns, scanning insns is expensive with
>>  	       remote targets.  */
>>
> 
> 
> The explanation makes sense, but I think a powerpc maintainer should ack the
> patch.
> 

The only mention I found in gdb/MAINTAINERS related to powerpc is Kevin,
and he approved it.

> And I think it would be useful to paste the "disassembly /r" of the _exit
> function in the commit message, showing where the breakpoint used to be
> placed, and where it is placed now.

Ack, good suggestion, done and committed.

Thanks,
- Tom


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

end of thread, other threads:[~2021-11-02 18:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-02 11:33 [PATCH][gdb/tdep, rs6000] Don't skip system call in skip_prologue Tom de Vries
2021-11-02 16:26 ` Simon Marchi
2021-11-02 18:13   ` Tom de Vries
2021-11-02 16:54 ` Kevin Buettner

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