Skip to contentSkip to conversation

perf annotate: Add config option for additional objdump arguments

PATCH In review Anton Blanchard 2 participants 3 messages Apr 16, 2011 – Apr 24, 2011 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf annotate: Add config option for additional objdump arguments

We sometimes need to pass arguments to objdump, for example to specify a particular machine type. In the case below I am profiling on POWER7 and perf annotate is unable to decode a POWER7 specific instruction:

c000000000008ff0: 7f 45 26 98 .long 0x7f452698

With the patch below and the following in ~/.perfconfig:

[objdump]
options = -Mpower7

perf annotate successfully decodes the instruction:

c000000000008ff0: 7f 45 26 98 lxvd2x vs26,r5,r4

---

What do people think of objdump.options? Would annotate.objdump_options be better?

Also we only look at the first occurance of the option, do we want to parse everything found and concatenate them together?

tools/perf/util/annotate.c +26 -1
Index: linux.trees.git/tools/perf/util/annotate.c
===================================================================
@@ -16,10 +16,33 @@
 #include "annotate.h"
 #include <pthread.h>
 
+static char *objdump_options;
+
+static int perf_objdump_config(const char *var, const char *value, void *cb)
+{
+	if (objdump_options == NULL && !strcmp(var, "objdump.options")) {
+		size_t len = strlen(value);
+
+		objdump_options = zalloc(len + 1);
+		strncpy(objdump_options, value, len);
+
+		return 0;
+	}
+
+	return perf_default_config(var, value, cb);
+}
+
 int symbol__annotate_init(struct map *map __used, struct symbol *sym)
 {
 	struct annotation *notes = symbol__annotation(sym);
 	pthread_mutex_init(&notes->lock, NULL);
+
+	if (objdump_options == NULL) {
+		perf_config(perf_objdump_config, NULL);
+		if (objdump_options == NULL)
+			objdump_options = zalloc(1);
+	}
+
 	return 0;
 }
 
@@ -324,9 +347,11 @@ fallback:
 
 	snprintf(command, sizeof(command),
 		 "objdump --start-address=0x%016" PRIx64
-		 " --stop-address=0x%016" PRIx64 " -dS -C %s|grep -v %s|expand",
+		 " --stop-address=0x%016" PRIx64 " %s -dS -C %s|"
+		 "grep -v %s|expand",
 		 map__rip_2objdump(map, sym->start),
 		 map__rip_2objdump(map, sym->end),
+		 objdump_options,
 		 symfs_filename, filename);
 
 	pr_debug("Executing: %s\n", command);
#1 lore raw
Quoted 6 lines · Anton Blanchard

We sometimes need to pass arguments to objdump, for example to specify a particular machine type. In the case below I am profiling on POWER7 and perf annotate is unable to decode a POWER7 specific instruction:

Quoted 6 lines

c000000000008ff0: 7f 45 26 98 .long 0x7f452698

With the patch below and the following in ~/.perfconfig:

[objdump]
options = -Mpower7

Hm, could we please detect the required flags automatically and pass them along without forcing people into twiddling their ~/.perfconfig?

I don't mind the options patch either - but please first automate it, *then* add this as a quick fix for similar future problems.

Thanks,

Ingo

#2 lore raw

Hi Ingo,

Quoted 5 lines

Hm, could we please detect the required flags automatically and pass them along without forcing people into twiddling their ~/.perfconfig?

I don't mind the options patch either - but please first automate it, *then* add this as a quick fix for similar future problems.

Good point. Unfortunately there are some overlapping opcodes between the ppc embedded and server chips but we could get most of the way there by specifying using objdump -Many.

Anton