perf: Support for Openembedded/Yocto -dbg packages
PATCH v2 1/1 perf: Support for Openembedded/Yocto -dbg packages
On OpenEmbedded the symbol files are located under a .debug folder on the same folder as the binary file.
This patch adds support for such files.
Without this patch on perf top you can see:
no symbols found in /usr/lib/gstreamer-1.0/libtheoraenc.so.1.1.2, maybe install a debug package?
84.56% libtheoraenc.so.1.1.2 [.] 0x000000000000b346
With this patch symbols are shown:
19.06% libtheoraenc.so.1.1.2 [.] oc_int_frag_satd_thresh_mmxext 9.76% libtheoraenc.so.1.1.2 [.] oc_analyze_mb_mode_luma 5.58% libtheoraenc.so.1.1.2 [.] oc_qii_state_advance 4.84% libtheoraenc.so.1.1.2 [.] oc_enc_tokenize_ac
...
---
v2: Changes proposed by Ingo Molnar
-Improve changeset
-Improve multi-snprintf readability
-Code Style
tools/perf/util/dso.c | 42 +++++++++++++++++++++++++++++------------- tools/perf/util/dso.h | 1 + tools/perf/util/symbol.c | 1 + 3 files changed, 31 insertions(+), 13 deletions(-)
tools/perf/util/dso.c +29 -13
@@ -7,19 +7,20 @@char dso__symtab_origin (const struct dso *dso) {static const char origin[] = { - [DSO_BINARY_TYPE__KALLSYMS ] ='k' , - [DSO_BINARY_TYPE__VMLINUX ] ='v' , - [DSO_BINARY_TYPE__JAVA_JIT ] ='j' , - [DSO_BINARY_TYPE__DEBUGLINK ] ='l' , - [DSO_BINARY_TYPE__BUILD_ID_CACHE ] ='B' , - [DSO_BINARY_TYPE__FEDORA_DEBUGINFO ] ='f' , - [DSO_BINARY_TYPE__UBUNTU_DEBUGINFO ] ='u' , - [DSO_BINARY_TYPE__BUILDID_DEBUGINFO ] ='b' , - [DSO_BINARY_TYPE__SYSTEM_PATH_DSO ] ='d' , - [DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE ] ='K' , - [DSO_BINARY_TYPE__GUEST_KALLSYMS ] ='g' , - [DSO_BINARY_TYPE__GUEST_KMODULE ] ='G' , - [DSO_BINARY_TYPE__GUEST_VMLINUX ] ='V' , + [DSO_BINARY_TYPE__KALLSYMS ] ='k' , + [DSO_BINARY_TYPE__VMLINUX ] ='v' , + [DSO_BINARY_TYPE__JAVA_JIT ] ='j' , + [DSO_BINARY_TYPE__DEBUGLINK ] ='l' , + [DSO_BINARY_TYPE__BUILD_ID_CACHE ] ='B' , + [DSO_BINARY_TYPE__FEDORA_DEBUGINFO ] ='f' , + [DSO_BINARY_TYPE__UBUNTU_DEBUGINFO ] ='u' , + [DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO ] ='o' , + [DSO_BINARY_TYPE__BUILDID_DEBUGINFO ] ='b' , + [DSO_BINARY_TYPE__SYSTEM_PATH_DSO ] ='d' , + [DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE ] ='K' , + [DSO_BINARY_TYPE__GUEST_KALLSYMS ] ='g' , + [DSO_BINARY_TYPE__GUEST_KMODULE ] ='G' , + [DSO_BINARY_TYPE__GUEST_VMLINUX ] ='V' , };if (dso ==NULL || dso->symtab_type ==DSO_BINARY_TYPE__NOT_FOUND )
@@ -64,6 +65,21 @@ int dso__binary_type_file(struct dso *dso, enum dso_binary_type type, symbol_conf.symfs, dso->long_name);break ; +case DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO :{ +char *last_slash; + + last_slash = dso->long_name + dso->long_name_len; +while (last_slash != dso->long_name && *last_slash !='/' ) + last_slash--; + + size -=snprintf (file,MIN (size,strlen (symbol_conf.symfs) + + (last_slash - dso->long_name) +2 ),"%s%s" , + symbol_conf.symfs, dso->long_name); +snprintf (file +strlen (file), size,".debug%s" , + last_slash); +break ; + } +case DSO_BINARY_TYPE__BUILDID_DEBUGINFO :if (!dso->has_build_id) { ret =-1 ;
tools/perf/util/dso.h +1 -0
@@ -23,6 +23,7 @@ enum dso_binary_type {DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE ,DSO_BINARY_TYPE__KCORE ,DSO_BINARY_TYPE__GUEST_KCORE , +DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO , DSO_BINARY_TYPE__NOT_FOUND, };
tools/perf/util/symbol.c +1 -0
@@ -51,6 +51,7 @@ static enum dso_binary_type binary_type_symtab[] = {DSO_BINARY_TYPE__SYSTEM_PATH_DSO ,DSO_BINARY_TYPE__GUEST_KMODULE ,DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE , +DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO , DSO_BINARY_TYPE__NOT_FOUND, };
Signature · 1 line
1.8.4.rc3
Quoted 12 lines · Ricardo Ribalda Delgado
On OpenEmbedded the symbol files are located under a .debug folder on the same folder as the binary file.
This patch adds support for such files.
Without this patch on perf top you can see:
no symbols found in
/usr/lib/gstreamer-1.0/libtheoraenc.so.1.1.2, maybe install a debug package?84.56% libtheoraenc.so.1.1.2 [.]
0x000000000000b346
Quoted 7 lines
With this patch symbols are shown:
19.06% libtheoraenc.so.1.1.2 [.] oc_int_frag_satd_thresh_mmxext 9.76% libtheoraenc.so.1.1.2 [.] oc_analyze_mb_mode_luma 5.58% libtheoraenc.so.1.1.2 [.] oc_qii_state_advance 4.84% libtheoraenc.so.1.1.2 [.] oc_enc_tokenize_ac...
Nice! Two nits are remaining:
tools/perf/util/dso.c int dso__binary_type_file(struct dso *dso, enum dso_binary_type type, · line 68
Quoted 5 lines
tools/perf/util/dso.c +1
-0@@ -64,6 +65,21 @@ int dso__binary_type_file(struct dso *dso, enum dso_binary_type type, symbol_conf.symfs, dso->long_name);break ; +case DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO :{
I think you missed the review feedback I gave for this line in the previous mail.
tools/perf/util/dso.c int dso__binary_type_file(struct dso *dso, enum dso_binary_type type, · line 81
Quoted 13 lines
tools/perf/util/dso.c +13
-0+char *last_slash; + + last_slash = dso->long_name + dso->long_name_len; +while (last_slash != dso->long_name && *last_slash !='/' ) + last_slash--; + + size -=snprintf (file,MIN (size,strlen (symbol_conf.symfs) + + (last_slash - dso->long_name) +2 ),"%s%s" , + symbol_conf.symfs, dso->long_name); +snprintf (file +strlen (file), size,".debug%s" , + last_slash); +break ; + }
The 'MIN' still looks superfluous (btw., we use min()) - why not simply set 'size' to the correct value when you set and iterate last_slash?
(and scnprintf() should be used, as Arnaldo suggested.)
Thanks,
Ingo