linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tri Vo <trong@android.com>
To: oberpar@linux.ibm.com
Cc: ghackmann@android.com, ndesaulniers@google.com,
	linux-kernel@vger.kernel.org, kernel-team@android.com,
	Tri Vo <trong@android.com>, Trilok Soni <tsoni@quicinc.com>,
	Prasad Sodagudi <psodagud@quicinc.com>
Subject: [PATCH 3/4] gcov: clang: link/unlink profiling data set.
Date: Mon, 14 Jan 2019 13:04:25 -0800	[thread overview]
Message-ID: <20190114210426.177543-4-trong@android.com> (raw)
In-Reply-To: <20190114210426.177543-1-trong@android.com>

From: Nick Desaulniers <ndesaulniers@google.com>

gcov.h defines an interface to access gcov_info data.

Add Clang implementation of gcov_info_link/gcov_info_unlink interfaces.

Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Tri Vo <trong@android.com>
Tested-by: Trilok Soni <tsoni@quicinc.com>
Tested-by: Prasad Sodagudi <psodagud@quicinc.com>
Tested-by: Tri Vo <trong@android.com>
---
 kernel/gcov/clang.c | 33 ++++++++++++++++++++++++++++-----
 1 file changed, 28 insertions(+), 5 deletions(-)

diff --git a/kernel/gcov/clang.c b/kernel/gcov/clang.c
index b00795d28137..ea42deb852f7 100644
--- a/kernel/gcov/clang.c
+++ b/kernel/gcov/clang.c
@@ -77,6 +77,7 @@ struct gcov_fn_info {
 
 	u32 num_counters;
 	u64 *counters;
+	const char *function_name;
 };
 
 static struct gcov_info *current_info;
@@ -124,7 +125,7 @@ void llvm_gcda_emit_function(u32 ident, const char *function_name,
 
 	if (!info) {
 		pr_warn_ratelimited("failed to allocate gcov function info for %s\n",
-				function_name);
+				function_name ?: "UNKNOWN");
 		return;
 	}
 
@@ -133,6 +134,8 @@ void llvm_gcda_emit_function(u32 ident, const char *function_name,
 	info->checksum = func_checksum;
 	info->use_extra_checksum = use_extra_checksum;
 	info->cfg_checksum = cfg_checksum;
+	if (function_name)
+		info->function_name = kstrdup(function_name, GFP_KERNEL);
 
 	list_add_tail(&info->head, &current_info->functions);
 }
@@ -193,6 +196,26 @@ struct gcov_info *gcov_info_next(struct gcov_info *info)
 	return list_next_entry(info, head);
 }
 
+/**
+ * gcov_info_link - link/add profiling data set to the list
+ * @info: profiling data set
+ */
+void gcov_info_link(struct gcov_info *info)
+{
+	list_add_tail(&info->head, &clang_gcov_list);
+}
+
+/**
+ * gcov_info_unlink - unlink/remove profiling data set from the list
+ * @prev: previous profiling data set
+ * @info: profiling data set
+ */
+void gcov_info_unlink(struct gcov_info *prev, struct gcov_info *info)
+{
+	if (prev)
+		list_del(&prev->head);
+}
+
 /* Symbolic links to be created for each profiling data file. */
 const struct gcov_link gcov_link[] = {
 	{ OBJ_TREE, "gcno" },	/* Link to .gcno file in $(objtree). */
@@ -256,8 +279,8 @@ static struct gcov_fn_info *gcov_fn_info_dup(struct gcov_fn_info *fn)
 		return NULL;
 	INIT_LIST_HEAD(&fn_dup->head);
 
-	fn_dup->name = kstrdup(fn->name, GFP_KERNEL);
-	if (!fn_dup->name)
+	fn_dup->function_name = kstrdup(fn->function_name, GFP_KERNEL);
+	if (!fn_dup->function_name)
 		goto err_name;
 
 	fn_dup->counters = kmemdup(fn->counters,
@@ -269,7 +292,7 @@ static struct gcov_fn_info *gcov_fn_info_dup(struct gcov_fn_info *fn)
 	return fn_dup;
 
 err_counters:
-	kfree(fn_dup->name);
+	kfree(fn_dup->function_name);
 err_name:
 	kfree(fn_dup);
 	return NULL;
@@ -317,7 +340,7 @@ void gcov_info_free(struct gcov_info *info)
 	struct gcov_fn_info *fn, *tmp;
 
 	list_for_each_entry_safe(fn, tmp, &info->functions, head) {
-		kfree(fn->name);
+		kfree(fn->function_name);
 		kfree(fn->counters);
 		list_del(&fn->head);
 		kfree(fn);
-- 
2.20.1.97.g81188d93c3-goog


  parent reply	other threads:[~2019-01-14 21:05 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-14 21:04 [PATCH 0/4] gcov: add Clang support Tri Vo
2019-01-14 21:04 ` [PATCH 1/4] gcov: clang: move common gcc code into gcc_base.c Tri Vo
2019-01-16 15:32   ` Peter Oberparleiter
2019-01-14 21:04 ` [PATCH 2/4] gcov: clang support Tri Vo
2019-01-16 16:06   ` Peter Oberparleiter
2019-01-14 21:04 ` Tri Vo [this message]
2019-01-16 16:14   ` [PATCH 3/4] gcov: clang: link/unlink profiling data set Peter Oberparleiter
2019-01-14 21:04 ` [PATCH 4/4] gcov: clang: pick GCC vs Clang format depending on compiler Tri Vo
2019-01-14 21:11   ` Nick Desaulniers
2019-01-15  1:24   ` Masahiro Yamada
2019-01-15 17:52     ` Tri Vo
2019-01-14 21:32 ` [PATCH 0/4] gcov: add Clang support Nick Desaulniers
2019-01-14 21:53   ` Tri Vo
2019-01-14 22:00     ` Nick Desaulniers

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=20190114210426.177543-4-trong@android.com \
    --to=trong@android.com \
    --cc=ghackmann@android.com \
    --cc=kernel-team@android.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=oberpar@linux.ibm.com \
    --cc=psodagud@quicinc.com \
    --cc=tsoni@quicinc.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;
as well as URLs for NNTP newsgroup(s).