public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb/riscv: fix creating breakpoints at invalid addresses
@ 2021-03-25  8:47 Changbin Du
  2021-03-25  9:17 ` Andrew Burgess
  0 siblings, 1 reply; 3+ messages in thread
From: Changbin Du @ 2021-03-25  8:47 UTC (permalink / raw)
  To: gdb-patches; +Cc: Changbin Du

To allow breakpoints to be created at invalid addresses,
target_read_code() is used instead of read_code(). The
original read_code() should be removed, otherwise the
breakpoint command will fail.

(gdb) hbreak setup_arch
Cannot access memory at address 0xffffffe000c036ac

gdb/ChangeLog:
2021-03-24  Changbin Du <changbin.du@gmail.com>

        * riscv-tdep.c (riscv_breakpoint_kind_from_pc): Update.
---
 gdb/ChangeLog    | 4 ++++
 gdb/riscv-tdep.c | 1 -
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index a548c58e8f72..a84299a2cc38 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,7 @@
+2021-03-25  Changbin Du <changbin.du@gmail.com>
+
+	* riscv-tdep.c (riscv_breakpoint_kind_from_pc): Update.
+
 2021-03-24  Simon Marchi  <simon.marchi@polymtl.ca>
 
 	* target.h (current_top_target): Remove, make callers use the
diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c
index ca3efaf71cf8..c17839968465 100644
--- a/gdb/riscv-tdep.c
+++ b/gdb/riscv-tdep.c
@@ -706,7 +706,6 @@ riscv_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
 	     user.  */
 	  if (target_read_code (*pcptr, buf, 1) == -1)
 	    buf[0] = 0;
-	  read_code (*pcptr, buf, 1);
 	}
 
       if (riscv_debug_breakpoints)
-- 
2.27.0



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

* Re: [PATCH] gdb/riscv: fix creating breakpoints at invalid addresses
  2021-03-25  8:47 [PATCH] gdb/riscv: fix creating breakpoints at invalid addresses Changbin Du
@ 2021-03-25  9:17 ` Andrew Burgess
  2021-03-25  9:39   ` Changbin Du
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Burgess @ 2021-03-25  9:17 UTC (permalink / raw)
  To: Changbin Du; +Cc: gdb-patches

* Changbin Du via Gdb-patches <gdb-patches@sourceware.org> [2021-03-25 08:47:57 +0000]:

> To allow breakpoints to be created at invalid addresses,
> target_read_code() is used instead of read_code(). The
> original read_code() should be removed, otherwise the
> breakpoint command will fail.
> 
> (gdb) hbreak setup_arch
> Cannot access memory at address 0xffffffe000c036ac
> 
> gdb/ChangeLog:
> 2021-03-24  Changbin Du <changbin.du@gmail.com>
> 
>         * riscv-tdep.c (riscv_breakpoint_kind_from_pc): Update.

Can you change this to 'Remove call to read_code.' or similar.  Just
saying 'Update.' isn't very helpful.

Approved with that change.

Thanks,
Andrew



> ---
>  gdb/ChangeLog    | 4 ++++
>  gdb/riscv-tdep.c | 1 -
>  2 files changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/gdb/ChangeLog b/gdb/ChangeLog
> index a548c58e8f72..a84299a2cc38 100644
> --- a/gdb/ChangeLog
> +++ b/gdb/ChangeLog
> @@ -1,3 +1,7 @@
> +2021-03-25  Changbin Du <changbin.du@gmail.com>
> +
> +	* riscv-tdep.c (riscv_breakpoint_kind_from_pc): Update.
> +
>  2021-03-24  Simon Marchi  <simon.marchi@polymtl.ca>
>  
>  	* target.h (current_top_target): Remove, make callers use the
> diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c
> index ca3efaf71cf8..c17839968465 100644
> --- a/gdb/riscv-tdep.c
> +++ b/gdb/riscv-tdep.c
> @@ -706,7 +706,6 @@ riscv_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
>  	     user.  */
>  	  if (target_read_code (*pcptr, buf, 1) == -1)
>  	    buf[0] = 0;
> -	  read_code (*pcptr, buf, 1);
>  	}
>  
>        if (riscv_debug_breakpoints)
> -- 
> 2.27.0
> 
> 

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

* Re: [PATCH] gdb/riscv: fix creating breakpoints at invalid addresses
  2021-03-25  9:17 ` Andrew Burgess
@ 2021-03-25  9:39   ` Changbin Du
  0 siblings, 0 replies; 3+ messages in thread
From: Changbin Du @ 2021-03-25  9:39 UTC (permalink / raw)
  To: Andrew Burgess; +Cc: Changbin Du, gdb-patches

On Thu, Mar 25, 2021 at 09:17:52AM +0000, Andrew Burgess wrote:
> * Changbin Du via Gdb-patches <gdb-patches@sourceware.org> [2021-03-25 08:47:57 +0000]:
> 
> > To allow breakpoints to be created at invalid addresses,
> > target_read_code() is used instead of read_code(). The
> > original read_code() should be removed, otherwise the
> > breakpoint command will fail.
> > 
> > (gdb) hbreak setup_arch
> > Cannot access memory at address 0xffffffe000c036ac
> > 
> > gdb/ChangeLog:
> > 2021-03-24  Changbin Du <changbin.du@gmail.com>
> > 
> >         * riscv-tdep.c (riscv_breakpoint_kind_from_pc): Update.
> 
> Can you change this to 'Remove call to read_code.' or similar.  Just
> saying 'Update.' isn't very helpful.
>
Sure, please checkout in v2. Thanks.
 
> Approved with that change.
> 
> Thanks,
> Andrew
> 
> 
> 
> > ---
> >  gdb/ChangeLog    | 4 ++++
> >  gdb/riscv-tdep.c | 1 -
> >  2 files changed, 4 insertions(+), 1 deletion(-)
> > 
> > diff --git a/gdb/ChangeLog b/gdb/ChangeLog
> > index a548c58e8f72..a84299a2cc38 100644
> > --- a/gdb/ChangeLog
> > +++ b/gdb/ChangeLog
> > @@ -1,3 +1,7 @@
> > +2021-03-25  Changbin Du <changbin.du@gmail.com>
> > +
> > +	* riscv-tdep.c (riscv_breakpoint_kind_from_pc): Update.
> > +
> >  2021-03-24  Simon Marchi  <simon.marchi@polymtl.ca>
> >  
> >  	* target.h (current_top_target): Remove, make callers use the
> > diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c
> > index ca3efaf71cf8..c17839968465 100644
> > --- a/gdb/riscv-tdep.c
> > +++ b/gdb/riscv-tdep.c
> > @@ -706,7 +706,6 @@ riscv_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
> >  	     user.  */
> >  	  if (target_read_code (*pcptr, buf, 1) == -1)
> >  	    buf[0] = 0;
> > -	  read_code (*pcptr, buf, 1);
> >  	}
> >  
> >        if (riscv_debug_breakpoints)
> > -- 
> > 2.27.0
> > 
> > 

-- 
Cheers,
Changbin Du

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

end of thread, other threads:[~2021-03-25  9:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-25  8:47 [PATCH] gdb/riscv: fix creating breakpoints at invalid addresses Changbin Du
2021-03-25  9:17 ` Andrew Burgess
2021-03-25  9:39   ` Changbin Du

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