From: Simon Marchi <simon.marchi@ericsson.com>
To: <gdb-patches@sourceware.org>
Cc: Par Olsson <par.olsson@windriver.com>
Subject: [PATCH 1/2] Fix write endianness/size problem for fast tracepoint enabled flag
Date: Wed, 30 Mar 2016 15:17:00 -0000 [thread overview]
Message-ID: <1459351018-23718-1-git-send-email-simon.marchi@ericsson.com> (raw)
From: Par Olsson <par.olsson@windriver.com>
I am sending this fix on behalf of Par Olsson, as a follow-up of this
one:
https://www.sourceware.org/ml/gdb-patches/2015-10/msg00196.html
This problem is exposed when enabling/disabling fast tracepoints on big
endian machines. The flag is defined as an int8_t, but is written from
gdbserver as an integer (usually 32 bits). When the agent code reads it
as an int8_t, it only considers the most significant byte, which is
always 0.
Also, we were writing 32 bits in an 8 bits field, so the write would
overflow, but since the following bytes are padding (the next field is
an uint64_t), it luckily didn't cause any issue on little endian
systems.
The fix was originally tested on ARM big endian systems, but I don't
have access to such a system. However, thanks to Marcin's PowerPC fast
tracepoint patches and gcc110 (big endian Power7) on the gcc compile
farm, I was able to reproduce the problem, test the fix and write a
test (the following patch).
gdb/gdbserver/ChangeLog:
YYYY-MM-DD Par Olsson <par.olsson@windriver.com>
* tracepoint.c (write_inferior_int8): New function.
(cmd_qtenable_disable): Write enable flag using
write_inferior_int8.
---
gdb/gdbserver/tracepoint.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/gdb/gdbserver/tracepoint.c b/gdb/gdbserver/tracepoint.c
index 7c20612..3e0d57a 100644
--- a/gdb/gdbserver/tracepoint.c
+++ b/gdb/gdbserver/tracepoint.c
@@ -449,6 +449,12 @@ write_inferior_integer (CORE_ADDR symaddr, int val)
}
static int
+write_inferior_int8 (CORE_ADDR symaddr, int8_t val)
+{
+ return write_inferior_memory (symaddr, (unsigned char *) &val, sizeof (val));
+}
+
+static int
write_inferior_uinteger (CORE_ADDR symaddr, unsigned int val)
{
return write_inferior_memory (symaddr, (unsigned char *) &val, sizeof (val));
@@ -2784,7 +2790,7 @@ cmd_qtenable_disable (char *own_buf, int enable)
return;
}
- ret = write_inferior_integer (obj_addr, enable);
+ ret = write_inferior_int8 (obj_addr, enable);
done_accessing_memory ();
if (ret)
--
2.8.0
next reply other threads:[~2016-03-30 15:17 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-30 15:17 Simon Marchi [this message]
2016-03-30 15:17 ` [PATCH 2/2] Add test for fast tracepoint enable/disable Simon Marchi
2016-03-31 10:58 ` Yao Qi
2016-03-31 18:01 ` Simon Marchi
2016-03-31 18:31 ` Simon Marchi
2016-04-01 13:36 ` Yao Qi
2016-04-01 14:42 ` Simon Marchi
2016-04-28 15:30 ` Simon Marchi
2016-04-28 16:03 ` Yao Qi
2016-04-28 16:57 ` Simon Marchi
2016-03-31 10:51 ` [PATCH 1/2] Fix write endianness/size problem for fast tracepoint enabled flag Yao Qi
2016-03-31 11:33 ` Pedro Alves
2016-03-31 12:58 ` Yao Qi
2016-03-31 17:45 ` Simon Marchi
2016-05-05 7:58 ` Yao Qi
2016-05-05 13:50 ` Simon Marchi
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=1459351018-23718-1-git-send-email-simon.marchi@ericsson.com \
--to=simon.marchi@ericsson.com \
--cc=gdb-patches@sourceware.org \
--cc=par.olsson@windriver.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