From: Yao Qi <yao@codesourcery.com>
To: <gdb-patches@sourceware.org>
Subject: [PATCH 1/6] Remove global variable tracepoint_list and stepping_list.
Date: Thu, 13 Jun 2013 02:46:00 -0000 [thread overview]
Message-ID: <1371086914-8398-2-git-send-email-yao@codesourcery.com> (raw)
In-Reply-To: <1371086914-8398-1-git-send-email-yao@codesourcery.com>
This patch is a refactor patch. Simply, it removes two global
variables tracepoint_list and stepping_list.
gdb:
2013-06-13 Pedro Alves <pedro@codesourcery.com>
Yao Qi <yao@codesourcery.com>
* tracepoint.c (tracepoint_list, stepping_list): Remove.
(clear_collection_list): Free fields 'aexpre_list' and 'list' in
collection_list.
(do_clear_collection_list, init_collection_list): New.
(encode_actions): Add local variables 'tracepoint_list' and
'stepping_list'. Call init_collection_list and make cleanup which
calls do_clear_collection_list. Don't call clear_collection_list.
(_initialize_tracepoint): Delete references to 'tracepoint_list'
and 'stepping_list'.
---
gdb/tracepoint.c | 67 +++++++++++++++++++++++++++++-------------------------
1 files changed, 36 insertions(+), 31 deletions(-)
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index 5bad3e8..9646090 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -873,8 +873,7 @@ struct collection_list
/* True is the user requested a collection of "$_sdata", "static
tracepoint data". */
int strace_data;
- }
-tracepoint_list, stepping_list;
+ };
/* MEMRANGE functions: */
@@ -1239,6 +1238,35 @@ clear_collection_list (struct collection_list *list)
list->next_aexpr_elt = 0;
memset (list->regs_mask, 0, sizeof (list->regs_mask));
list->strace_data = 0;
+
+ xfree (list->aexpr_list);
+ xfree (list->list);
+}
+
+/* A cleanup wrapper for function clear_collection_list. */
+
+static void
+do_clear_collection_list (void *list)
+{
+ struct collection_list *l = list;
+
+ clear_collection_list (l);
+}
+
+/* Initialize collection_list CLIST. */
+
+static void
+init_collection_list (struct collection_list *clist)
+{
+ memset (clist, 0, sizeof *clist);
+
+ clist->listsize = 128;
+ clist->list = xcalloc (clist->listsize,
+ sizeof (struct memrange));
+
+ clist->aexpr_listsize = 128;
+ clist->aexpr_list = xcalloc (clist->aexpr_listsize,
+ sizeof (struct agent_expr *));
}
/* Reduce a collection list to string form (for gdb protocol). */
@@ -1618,11 +1646,15 @@ encode_actions (struct bp_location *tloc, char ***tdp_actions,
int frame_reg;
LONGEST frame_offset;
struct cleanup *back_to;
+ struct collection_list tracepoint_list, stepping_list;
back_to = make_cleanup (null_cleanup, NULL);
- clear_collection_list (&tracepoint_list);
- clear_collection_list (&stepping_list);
+ init_collection_list (&tracepoint_list);
+ init_collection_list (&stepping_list);
+
+ make_cleanup (do_clear_collection_list, &tracepoint_list);
+ make_cleanup (do_clear_collection_list, &stepping_list);
*tdp_actions = NULL;
*stepping_actions = NULL;
@@ -5673,33 +5705,6 @@ _initialize_tracepoint (void)
traceframe_number = -1;
tracepoint_number = -1;
- if (tracepoint_list.list == NULL)
- {
- tracepoint_list.listsize = 128;
- tracepoint_list.list = xmalloc
- (tracepoint_list.listsize * sizeof (struct memrange));
- }
- if (tracepoint_list.aexpr_list == NULL)
- {
- tracepoint_list.aexpr_listsize = 128;
- tracepoint_list.aexpr_list = xmalloc
- (tracepoint_list.aexpr_listsize * sizeof (struct agent_expr *));
- }
-
- if (stepping_list.list == NULL)
- {
- stepping_list.listsize = 128;
- stepping_list.list = xmalloc
- (stepping_list.listsize * sizeof (struct memrange));
- }
-
- if (stepping_list.aexpr_list == NULL)
- {
- stepping_list.aexpr_listsize = 128;
- stepping_list.aexpr_list = xmalloc
- (stepping_list.aexpr_listsize * sizeof (struct agent_expr *));
- }
-
add_info ("scope", scope_info,
_("List the variables local to a scope"));
--
1.7.7.6
next prev parent reply other threads:[~2013-06-13 1:29 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-07 13:07 [PATCH 0/5] New MI command -trace-frame-collected Yao Qi
2013-06-07 13:07 ` [PATCH 3/5] Add id of TSV into traceframe_info Yao Qi
2013-06-07 14:39 ` Eli Zaretskii
2013-06-08 11:06 ` Yao Qi
2013-06-07 13:07 ` [PATCH 2/5] Move code to get_traceframe_location Yao Qi
2013-06-07 21:09 ` Pedro Alves
2013-06-07 13:07 ` [PATCH 5/5] New test: gdb.trace/mi-trace-frame-collected.exp Yao Qi
2013-06-07 13:07 ` [PATCH 1/5] Remove global variable tracepoint_list and stepping_list Yao Qi
2013-06-07 20:50 ` Pedro Alves
2013-06-07 13:07 ` [PATCH 4/5] New MI command -trace-frame-collected Yao Qi
2013-06-13 1:29 ` [PATCH 0/6 V2] " Yao Qi
2013-06-13 1:29 ` [PATCH 3/6] Move code to get_traceframe_location Yao Qi
2013-06-25 15:43 ` Pedro Alves
2013-06-13 1:29 ` [PATCH 6/6] New test: gdb.trace/mi-trace-frame-collected.exp Yao Qi
2013-06-25 18:42 ` Pedro Alves
2013-06-26 10:32 ` Yao Qi
2013-06-13 1:29 ` [PATCH 5/6] New MI command -trace-frame-collected Yao Qi
2013-06-13 14:27 ` Eli Zaretskii
2013-06-14 9:52 ` Yao Qi
2013-06-14 12:34 ` Eli Zaretskii
2013-06-17 10:21 ` Yao Qi
2013-06-17 15:48 ` Eli Zaretskii
2013-06-18 14:09 ` Yao Qi
2013-06-18 17:24 ` Eli Zaretskii
2013-06-25 17:31 ` Pedro Alves
2013-06-26 8:29 ` Yao Qi
2013-06-26 11:22 ` Pedro Alves
2013-06-13 1:29 ` [PATCH 2/6] Emit error in tdump command when traceframe is not selected Yao Qi
2013-06-25 15:32 ` Pedro Alves
2013-06-13 1:29 ` [PATCH 4/6] Add id of TSV into traceframe_info Yao Qi
2013-06-13 3:40 ` Eli Zaretskii
2013-06-25 16:18 ` Pedro Alves
2013-06-26 8:19 ` Yao Qi
2013-06-13 2:46 ` Yao Qi [this message]
2013-06-25 15:28 ` [PATCH 1/6] Remove global variable tracepoint_list and stepping_list Pedro Alves
2013-06-24 15:25 ` [ping]: [PATCH 0/6 V2] New MI command -trace-frame-collected 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=1371086914-8398-2-git-send-email-yao@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