From: Pedro Alves <palves@redhat.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@ericsson.com>
Subject: [PATCH 4/6] [C++] breakpoint.c: "no memory" software watchpoints and enum casts
Date: Wed, 18 Nov 2015 16:40:00 -0000 [thread overview]
Message-ID: <1447864802-24016-5-git-send-email-palves@redhat.com> (raw)
In-Reply-To: <1447864802-24016-1-git-send-email-palves@redhat.com>
Fixes:
src/gdb/breakpoint.c: In function âvoid update_watchpoint(watchpoint*, int)â:
src/gdb/breakpoint.c:2147:31: error: invalid conversion from âintâ to âtarget_hw_bp_typeâ [-fpermissive]
base->loc->watchpoint_type = -1;
^
Seems better to rely on "address == -1 && length == -1" than on a enum
value that's not really part of the set of supposedly valid enum
values. Also, factor that out to separate functions for better
localization of the concept.
gdb/ChangeLog:
2015-11-18 Pedro Alves <palves@redhat.com>
* breakpoint.c (software_watchpoint_add_memoryless_location)
(is_memoryless_software_watchpoint): New functions.
(update_watchpoint): Use
software_watchpoint_add_memoryless_location.
(breakpoint_address_bits): Use is_memoryless_software_watchpoint.
---
gdb/breakpoint.c | 49 ++++++++++++++++++++++++++++++++++++-------------
1 file changed, 36 insertions(+), 13 deletions(-)
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 5863573..1425d2d 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -1775,6 +1775,36 @@ extract_bitfield_from_watchpoint_value (struct watchpoint *w, struct value *val)
return bit_val;
}
+/* Allocate a dummy location and add it to B, which must be a software
+ watchpoint. This is required because even if a software watchpoint
+ is not watching any memory, bpstat_stop_status requires a location
+ to be able to report stops. */
+
+static void
+software_watchpoint_add_no_memory_location (struct breakpoint *b,
+ struct program_space *pspace)
+{
+ gdb_assert (b->type == bp_watchpoint && b->loc == NULL);
+
+ b->loc = allocate_bp_location (b);
+ b->loc->pspace = pspace;
+ b->loc->address = -1;
+ b->loc->length = -1;
+}
+
+/* Returns true if B is a software watchpoint that is not watching any
+ memory (e.g., "watch $pc"). */
+
+static int
+is_no_memory_software_watchpoint (struct breakpoint *b)
+{
+ return (b->type == bp_watchpoint
+ && b->loc != NULL
+ && b->loc->next == NULL
+ && b->loc->address == -1
+ && b->loc->length == -1);
+}
+
/* Assuming that B is a watchpoint:
- Reparse watchpoint expression, if REPARSE is non-zero
- Evaluate expression and store the result in B->val
@@ -2138,14 +2168,7 @@ update_watchpoint (struct watchpoint *b, int reparse)
bpstat_stop_status requires a location to be able to report
stops, so make sure there's at least a dummy one. */
if (b->base.type == bp_watchpoint && b->base.loc == NULL)
- {
- struct breakpoint *base = &b->base;
- base->loc = allocate_bp_location (base);
- base->loc->pspace = frame_pspace;
- base->loc->address = -1;
- base->loc->length = -1;
- base->loc->watchpoint_type = -1;
- }
+ software_watchpoint_add_no_memory_location (&b->base, frame_pspace);
}
else if (!within_current_scope)
{
@@ -6667,15 +6690,15 @@ breakpoint_address_bits (struct breakpoint *b)
int print_address_bits = 0;
struct bp_location *loc;
+ /* Software watchpoints that aren't watching memory don't have an
+ address to print. */
+ if (is_no_memory_software_watchpoint (b))
+ return 0;
+
for (loc = b->loc; loc; loc = loc->next)
{
int addr_bit;
- /* Software watchpoints that aren't watching memory don't have
- an address to print. */
- if (b->type == bp_watchpoint && loc->watchpoint_type == -1)
- continue;
-
addr_bit = gdbarch_addr_bit (loc->gdbarch);
if (addr_bit > print_address_bits)
print_address_bits = addr_bit;
--
1.9.3
next prev parent reply other threads:[~2015-11-18 16:40 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-18 16:40 [PATCH 0/6] [C++] Drop -fpermissive hack, enable -Werror Pedro Alves
2015-11-18 16:40 ` [PATCH 1/6] [C++] remote.c: Avoid enum arithmetic Pedro Alves
2015-11-18 16:40 ` [PATCH 3/6] [C++] s390: Fix enum gdb_syscall conversion Pedro Alves
2015-11-18 16:40 ` [PATCH 2/6] [C++] linux-thread-db.c: dladdr cast Pedro Alves
2015-11-18 16:40 ` Pedro Alves [this message]
2015-11-18 16:40 ` [PATCH 5/6] [C++] Drop -fpermissive hack Pedro Alves
2015-11-18 16:48 ` [PATCH 0/6] [C++] Drop -fpermissive hack, enable -Werror Simon Marchi
2015-11-18 16:49 ` [PATCH 6/6] [C++] Default to -Werror in C++ mode too Pedro Alves
2015-11-18 17:44 ` [PATCH 0/6] [C++] Drop -fpermissive hack, enable -Werror Yao Qi
2015-11-18 17:53 ` Pedro Alves
2015-11-19 11:28 ` Yao Qi
2015-11-19 15:14 ` Pedro Alves
2015-11-20 9:46 ` Yao Qi
2015-11-20 11:21 ` Pedro Alves
2015-11-24 11:01 ` Yao Qi
2015-11-24 13:17 ` Pedro Alves
2015-11-24 14:37 ` Joel Brobecker
2015-11-24 13:19 ` Pedro Alves
2015-11-19 15:17 ` Pedro Alves
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=1447864802-24016-5-git-send-email-palves@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@ericsson.com \
/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