public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2] gdb/riscv: fix creating breakpoints at invalid addresses
@ 2021-03-25  9:39 Changbin Du
  2021-03-25 11:10 ` Andrew Burgess
  0 siblings, 1 reply; 2+ messages in thread
From: Changbin Du @ 2021-03-25  9:39 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): Remove call to read_code.
---
 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): Remove call to read_code.
+
 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] 2+ messages in thread

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

* Changbin Du via Gdb-patches <gdb-patches@sourceware.org> [2021-03-25 09:39:54 +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): Remove call to read_code.

Thanks.

I pushed this fix to master.

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): Remove call to read_code.
> +
>  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] 2+ messages in thread

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

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

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