[PATCH v6 5/8] perf: build-id: add support for build-id cache vdso debug

Changbin Du posted 8 patches 1 year, 6 months ago
There is a newer version of this series
[PATCH v6 5/8] perf: build-id: add support for build-id cache vdso debug
Posted by Changbin Du 1 year, 6 months ago
This try to add debugging vdso elf to build-id cache the same as normal
objects. Later we will extend this to find local debugging vdso from
special paths.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Changbin Du <changbin.du@huawei.com>
---
 tools/perf/util/build-id.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c
index 83a1581e8cf1..5bda47de5cf2 100644
--- a/tools/perf/util/build-id.c
+++ b/tools/perf/util/build-id.c
@@ -259,8 +259,8 @@ static bool build_id_cache__valid_id(char *sbuild_id)
 static const char *build_id_cache__basename(bool is_kallsyms, bool is_vdso,
 					    bool is_debug)
 {
-	return is_kallsyms ? "kallsyms" : (is_vdso ? "vdso" : (is_debug ?
-	    "debug" : "elf"));
+	return is_kallsyms ? "kallsyms" : (is_debug ? "debug" : (is_vdso ?
+		"vdso" : "elf"));
 }
 
 char *__dso__build_id_filename(const struct dso *dso, char *bf, size_t size,
@@ -701,13 +701,12 @@ build_id_cache__add(const char *sbuild_id, const char *name, const char *realnam
 	 * file itself may not be very useful to users of our tools without a
 	 * symtab.
 	 */
-	if (!is_kallsyms && !is_vdso &&
-	    strncmp(".ko", name + strlen(name) - 3, 3)) {
+	if (!is_kallsyms && strncmp(".ko", name + strlen(name) - 3, 3)) {
 		debugfile = build_id_cache__find_debug(sbuild_id, nsi, root_dir);
 		if (debugfile) {
 			zfree(&filename);
 			if (asprintf(&filename, "%s/%s", dir_name,
-			    build_id_cache__basename(false, false, true)) < 0) {
+			    build_id_cache__basename(false, is_vdso, true)) < 0) {
 				filename = NULL;
 				goto out_free;
 			}
-- 
2.34.1
Re: [PATCH v6 5/8] perf: build-id: add support for build-id cache vdso debug
Posted by Adrian Hunter 1 year, 5 months ago
On 25/07/24 05:15, Changbin Du wrote:
> This try to add debugging vdso elf to build-id cache the same as normal
> objects. Later we will extend this to find local debugging vdso from
> special paths.
> 
> Cc: Adrian Hunter <adrian.hunter@intel.com>
> Signed-off-by: Changbin Du <changbin.du@huawei.com>

Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>

> ---
>  tools/perf/util/build-id.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c
> index 83a1581e8cf1..5bda47de5cf2 100644
> --- a/tools/perf/util/build-id.c
> +++ b/tools/perf/util/build-id.c
> @@ -259,8 +259,8 @@ static bool build_id_cache__valid_id(char *sbuild_id)
>  static const char *build_id_cache__basename(bool is_kallsyms, bool is_vdso,
>  					    bool is_debug)
>  {
> -	return is_kallsyms ? "kallsyms" : (is_vdso ? "vdso" : (is_debug ?
> -	    "debug" : "elf"));
> +	return is_kallsyms ? "kallsyms" : (is_debug ? "debug" : (is_vdso ?
> +		"vdso" : "elf"));
>  }
>  
>  char *__dso__build_id_filename(const struct dso *dso, char *bf, size_t size,
> @@ -701,13 +701,12 @@ build_id_cache__add(const char *sbuild_id, const char *name, const char *realnam
>  	 * file itself may not be very useful to users of our tools without a
>  	 * symtab.
>  	 */
> -	if (!is_kallsyms && !is_vdso &&
> -	    strncmp(".ko", name + strlen(name) - 3, 3)) {
> +	if (!is_kallsyms && strncmp(".ko", name + strlen(name) - 3, 3)) {
>  		debugfile = build_id_cache__find_debug(sbuild_id, nsi, root_dir);
>  		if (debugfile) {
>  			zfree(&filename);
>  			if (asprintf(&filename, "%s/%s", dir_name,
> -			    build_id_cache__basename(false, false, true)) < 0) {
> +			    build_id_cache__basename(false, is_vdso, true)) < 0) {
>  				filename = NULL;
>  				goto out_free;
>  			}