From: Yao Qi <yao@codesourcery.com>
To: <gdb-patches@sourceware.org>
Subject: [patch] Replace magic numbers with macros in gdbserver/tracepoint.c
Date: Mon, 12 Dec 2011 09:39:00 -0000 [thread overview]
Message-ID: <4EE5674B.7050205@codesourcery.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 247 bytes --]
I happen to read gdbserver/tracepoint.c and find there have been some
macros defined but some magic numbers are still there. This patch is
replace exiting magic numbers with existing macros.
I'll check it in later today.
--
Yao (é½å°§)
[-- Attachment #2: 0002-replace-magic-number.patch --]
[-- Type: text/x-patch, Size: 1885 bytes --]
gdb/gdbserver/
2011-12-12 Yao Qi <yao@codesourcery.com>
* tracepoint.c (trace_buffer_alloc): Replace magic numbers with macros.
(upload_fast_traceframes, upload_fast_traceframes): Likewise.
---
gdb/gdbserver/tracepoint.c | 15 ++++++++-------
1 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/gdb/gdbserver/tracepoint.c b/gdb/gdbserver/tracepoint.c
index 585f18d..d53d26b 100644
--- a/gdb/gdbserver/tracepoint.c
+++ b/gdb/gdbserver/tracepoint.c
@@ -1588,8 +1588,9 @@ trace_buffer_alloc (size_t amt)
#ifdef IN_PROCESS_AGENT
/* Build the tentative token. */
- commit_count = (((prev & 0x0007ff00) + 0x100) & 0x0007ff00);
- commit = (((prev & 0x0007ff00) << 12)
+ commit_count = (((prev & GDBSERVER_FLUSH_COUNT_MASK_CURR) + 0x100)
+ & GDBSERVER_FLUSH_COUNT_MASK_CURR);
+ commit = (((prev & GDBSERVER_FLUSH_COUNT_MASK_CURR) << 12)
| commit_count
| curr);
@@ -1621,8 +1622,8 @@ trace_buffer_alloc (size_t amt)
refetch = trace_buffer_ctrl_curr;
- if ((refetch == commit
- || ((refetch & 0x7ff00000) >> 12) == commit_count))
+ if (refetch == commit
+ || ((refetch & GDBSERVER_FLUSH_COUNT_MASK_PREV) >> 12) == commit_count)
{
/* effective */
trace_debug ("change is effective: (prev=%08x, commit=%08x, "
@@ -7080,10 +7081,10 @@ upload_fast_traceframes (void)
/* Update the token, with new counters, and the GDBserver stamp
bit. Alway reuse the current TBC index. */
- prev = ipa_trace_buffer_ctrl_curr & 0x0007ff00;
- counter = (prev + 0x100) & 0x0007ff00;
+ prev = ipa_trace_buffer_ctrl_curr & GDBSERVER_FLUSH_COUNT_MASK_CURR;
+ counter = (prev + 0x100) & GDBSERVER_FLUSH_COUNT_MASK_CURR;
- ipa_trace_buffer_ctrl_curr = (0x80000000
+ ipa_trace_buffer_ctrl_curr = ( GDBSERVER_UPDATED_FLUSH_COUNT_BIT
| (prev << 12)
| counter
| curr_tbctrl_idx);
--
1.7.0.4
next reply other threads:[~2011-12-12 2:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-12 9:39 Yao Qi [this message]
2011-12-12 11:21 ` Jan Kratochvil
2011-12-13 2:03 ` [committed] " Yao Qi
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=4EE5674B.7050205@codesourcery.com \
--to=yao@codesourcery.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