This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 11/11] [SQUASH] btrace: Cleanup.
- From: Tim Wiederhake <tim dot wiederhake at intel dot com>
- To: gdb-patches at sourceware dot org
- Cc: markus dot t dot metzger at intel dot com
- Date: Fri, 17 Feb 2017 14:26:29 +0100
- Subject: [PATCH 11/11] [SQUASH] btrace: Cleanup.
- Authentication-results: sourceware.org; auth=none
- References: <1487337989-6367-1-git-send-email-tim.wiederhake@intel.com>
This patch stands alone for easier review and is meant to be squashed together
for committing. ChangeLog will be added to the squashed commit.
2017-02-17 Tim Wiederhake <tim.wiederhake@intel.com>
---
gdb/btrace.c | 38 +++++++++++++-------------------------
1 file changed, 13 insertions(+), 25 deletions(-)
diff --git a/gdb/btrace.c b/gdb/btrace.c
index 859c87f..aa6959d 100644
--- a/gdb/btrace.c
+++ b/gdb/btrace.c
@@ -218,31 +218,28 @@ ftrace_new_function (struct btrace_thread_info *btinfo,
struct minimal_symbol *mfun,
struct symbol *fun)
{
- struct btrace_function *prev = NULL, *bfun;
+ struct btrace_function bfun;
- if (!VEC_empty (btrace_fun_s, btinfo->functions))
- prev = VEC_last (btrace_fun_s, btinfo->functions);
-
- bfun = VEC_safe_push (btrace_fun_s, btinfo->functions, NULL);
- memset (bfun, 0, sizeof (*bfun));
+ memset (&bfun, 0, sizeof (bfun));
+ bfun.msym = mfun;
+ bfun.sym = fun;
- bfun->msym = mfun;
- bfun->sym = fun;
-
- if (prev == NULL)
+ if (VEC_empty (btrace_fun_s, btinfo->functions))
{
/* Start counting at one. */
- bfun->number = 1;
- bfun->insn_offset = 1;
+ bfun.number = 1;
+ bfun.insn_offset = 1;
}
else
{
- bfun->number = prev->number + 1;
- bfun->insn_offset = prev->insn_offset + ftrace_call_num_insn (prev);
- bfun->level = prev->level;
+ struct btrace_function *prev = VEC_last (btrace_fun_s, btinfo->functions);
+
+ bfun.number = prev->number + 1;
+ bfun.insn_offset = prev->insn_offset + ftrace_call_num_insn (prev);
+ bfun.level = prev->level;
}
- return bfun;
+ return VEC_safe_push (btrace_fun_s, btinfo->functions, &bfun);
}
/* Update the UP field of a function segment. */
@@ -1496,10 +1493,6 @@ btrace_enable (struct thread_info *tp, const struct btrace_config *conf)
DEBUG ("enable thread %s (%s)", print_thread_id (tp),
target_pid_to_str (tp->ptid));
- /* Temporarily prevent resizing the vector until reworking struct
- btrace_function is complete. */
- VEC_reserve (btrace_fun_s, tp->btrace.functions, 1000000);
-
tp->btrace.target = target_enable_btrace (tp->ptid, conf);
/* We're done if we failed to enable tracing. */
@@ -1816,11 +1809,6 @@ btrace_fetch (struct thread_info *tp)
/* We should not be called on running or exited threads. */
gdb_assert (can_access_registers_ptid (tp->ptid));
- /* Temporarily prevent resizing the vector until reworking struct
- btrace_function is complete. */
- if (btinfo->functions == NULL)
- VEC_reserve (btrace_fun_s, btinfo->functions, 1000000);
-
btrace_data_init (&btrace);
cleanup = make_cleanup_btrace_data (&btrace);
--
2.7.4