From: Antoine Tremblay <antoine.tremblay@ericsson.com>
To: <gdb-patches@sourceware.org>
Cc: Antoine Tremblay <antoine.tremblay@ericsson.com>
Subject: [PATCH 1/3] Refactor default_breakpoint_kind_from_pc to be used by all targets in GDBServer.
Date: Fri, 23 Oct 2015 17:23:00 -0000 [thread overview]
Message-ID: <1445543917-16839-2-git-send-email-antoine.tremblay@ericsson.com> (raw)
In-Reply-To: <1445543917-16839-1-git-send-email-antoine.tremblay@ericsson.com>
This patch moves default_breakpoint_kind_from_pc to target.c and creates a macro
so that all targets can easily use it.
This allows the breakpoint_kind_from_pc operation to be left unimplemented in
targets that do not need it.
This is preparation to fix the win32/nto/spu build that was broken by this
patch: https://sourceware.org/ml/gdb-patches/2015-10/msg00369.html
No regression on Ubuntu 14.04 x86-64 with gdbserver-{native-extended}
gdb/gdbserver/ChangeLog:
* linux-low.c (default_breakpoint_kind_from_pc): Move to target.c.
* mem-break.c (set_breakpoint_at): Use target_breakpoint_kind_from_pc.
* target.c (default_breakpoint_kind_from_pc): Moved from linux-low.c
* target.h (target_breakpoint_kind_from_pc): New macro.
---
gdb/gdbserver/linux-low.c | 13 -------------
gdb/gdbserver/mem-break.c | 2 +-
gdb/gdbserver/target.c | 16 ++++++++++++++++
gdb/gdbserver/target.h | 7 +++++++
4 files changed, 24 insertions(+), 14 deletions(-)
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index ac8fae3..0c552b8 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -6937,19 +6937,6 @@ current_lwp_ptid (void)
return ptid_of (current_thread);
}
-/* Return the default breakpoint kind as the size of the breakpoint. */
-
-static int
-default_breakpoint_kind_from_pc (CORE_ADDR *pcptr)
-{
- int size = 0;
-
- gdb_assert (the_low_target.sw_breakpoint_from_kind != NULL);
-
- (*the_low_target.sw_breakpoint_from_kind) (0, &size);
- return size;
-}
-
/* Implementation of the target_ops method "breakpoint_kind_from_pc". */
static int
diff --git a/gdb/gdbserver/mem-break.c b/gdb/gdbserver/mem-break.c
index a676ea2..656402a 100644
--- a/gdb/gdbserver/mem-break.c
+++ b/gdb/gdbserver/mem-break.c
@@ -784,7 +784,7 @@ set_breakpoint_at (CORE_ADDR where, int (*handler) (CORE_ADDR))
{
int err_ignored;
CORE_ADDR placed_address = where;
- int breakpoint_kind = the_target->breakpoint_kind_from_pc (&placed_address);
+ int breakpoint_kind = target_breakpoint_kind_from_pc (&placed_address);
return set_breakpoint (other_breakpoint, raw_bkpt_type_sw,
placed_address, breakpoint_kind, handler,
diff --git a/gdb/gdbserver/target.c b/gdb/gdbserver/target.c
index 301f90e..80512d86 100644
--- a/gdb/gdbserver/target.c
+++ b/gdb/gdbserver/target.c
@@ -224,3 +224,19 @@ target_can_do_hardware_single_step (void)
{
return 1;
}
+
+/* Default implementation for breakpoint_kind_for_pc.
+
+ The default behavior for targets that don't implement breakpoint_kind_for_pc
+ is to use the size of a breakpoint as the kind. */
+
+int
+default_breakpoint_kind_from_pc (CORE_ADDR *pcptr)
+{
+ int size = 0;
+
+ gdb_assert (the_target->sw_breakpoint_from_kind != NULL);
+
+ (*the_target->sw_breakpoint_from_kind) (0, &size);
+ return size;
+}
diff --git a/gdb/gdbserver/target.h b/gdb/gdbserver/target.h
index e4c0639..a14c6ff 100644
--- a/gdb/gdbserver/target.h
+++ b/gdb/gdbserver/target.h
@@ -633,6 +633,11 @@ int kill_inferior (int);
(the_target->stopped_by_hw_breakpoint ? \
(*the_target->stopped_by_hw_breakpoint) () : 0)
+#define target_breakpoint_kind_from_pc(pcptr) \
+ (the_target->breakpoint_kind_from_pc \
+ ? (*the_target->breakpoint_kind_from_pc) (pcptr) \
+ : default_breakpoint_kind_from_pc (pcptr))
+
/* Start non-stop mode, returns 0 on success, -1 on failure. */
int start_non_stop (int nonstop);
@@ -667,4 +672,6 @@ const char *target_pid_to_str (ptid_t);
int target_can_do_hardware_single_step (void);
+int default_breakpoint_kind_from_pc (CORE_ADDR *pcptr);
+
#endif /* TARGET_H */
--
1.9.1
next prev parent reply other threads:[~2015-10-22 19:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-23 16:50 [PATCH 0/3] Fix nto, spu and win32 builds of GDBServer Antoine Tremblay
2015-10-23 17:02 ` [PATCH 2/3] Fix nto,spu " Antoine Tremblay
2015-10-23 17:09 ` [PATCH 3/3] Remove set_breakpoint_data definition in GDBServer Antoine Tremblay
2015-10-23 17:23 ` Antoine Tremblay [this message]
2015-10-23 23:56 ` [PATCH 0/3] Fix nto, spu and win32 builds of GDBServer Pedro Alves
2015-10-25 2:31 ` Antoine Tremblay
2015-10-25 11:08 ` Aleksandar Ristovski
2015-10-25 2:42 ` Aleksandar Ristovski
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=1445543917-16839-2-git-send-email-antoine.tremblay@ericsson.com \
--to=antoine.tremblay@ericsson.com \
--cc=gdb-patches@sourceware.org \
/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