From owner-freebsd-bugs@FreeBSD.ORG Sat Mar 3 08:20:09 2012 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EC12B106566B for ; Sat, 3 Mar 2012 08:20:09 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id C96488FC0A for ; Sat, 3 Mar 2012 08:20:09 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q238K9Zi019299 for ; Sat, 3 Mar 2012 08:20:09 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q238K9M8019298; Sat, 3 Mar 2012 08:20:09 GMT (envelope-from gnats) Resent-Date: Sat, 3 Mar 2012 08:20:09 GMT Resent-Message-Id: <201203030820.q238K9M8019298@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Vitaly Magerya Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3D6A9106566B for ; Sat, 3 Mar 2012 08:18:45 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id 13CB78FC12 for ; Sat, 3 Mar 2012 08:18:45 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q238IiNa006935 for ; Sat, 3 Mar 2012 08:18:44 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.4/8.14.4/Submit) id q238IinM006934; Sat, 3 Mar 2012 08:18:44 GMT (envelope-from nobody) Message-Id: <201203030818.q238IinM006934@red.freebsd.org> Date: Sat, 3 Mar 2012 08:18:44 GMT From: Vitaly Magerya To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: bin/165654: [patch] make /usr/sbin/pmcannotate work on amd64 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Mar 2012 08:20:10 -0000 >Number: 165654 >Category: bin >Synopsis: [patch] make /usr/sbin/pmcannotate work on amd64 >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat Mar 03 08:20:09 UTC 2012 >Closed-Date: >Last-Modified: >Originator: Vitaly Magerya >Release: FreeBSD 8.2-RELEASE amd64 >Organization: >Environment: >Description: pmcannotate does not print out source code or assembly code on my system. This seems to be caused by isasminline function at line 116 fail to recognize objdump source dump output: it expects the second character of assembly line to be a hex number, while at least on amd64 objdump seems to ident asm lines by two spaces. >How-To-Repeat: Create a simple C program: cat > test.c <= 0; i--); return i; } EOF Compile it with debug info: cc -g -o test test.c Load hwpmc module (if not already): kldload hwpmc Collect statistics: pmcstat -O test.log -P instructions ./test Now pmcannotate should show C source annotated with profile statistics: pmcannotate test.log test .. or the same, but with disassembly: pmcannotate -a test.log test In both cases I see output like this: [...] Profile trace for function: main() [81.48%] Profile trace for function: get_pv_entry() [3.70%] [...] While I'd like to see something like this: [...] Profile trace for function: main() [81.48%] | 400530: 55 push %rbp | 400531: 48 89 e5 mov %rsp,%rbp | 400534: c7 45 fc 40 42 0f 00 movl $0xf4240,-4(%rbp) | 40053b: eb 04 jmp 400541 59.09% | 40053d: 83 6d fc 01 subl $0x1,-4(%rbp) 22.73% | 400541: 83 7d fc 00 cmpl $0x0,-4(%rbp) 18.18% | 400545: 79 f6 jns 40053d | 400547: 8b 45 fc mov -4(%rbp),%eax | 40054a: c9 leaveq | 40054b: c3 retq | 40054c: 90 nop Profile trace for function: get_pv_entry() [3.70%] [...] Or like this (for C source annotation): [...] Profile trace for function: main() [81.48%] | int main() { 100.00% | int i; | for (i = 1000000; i >= 0; i--); | return i; | } [...] (It annotates the wrong line when no-op lines are encountered; still better than no output). >Fix: Just remove the test for second character being a hex number. The sscanf call on the next line will check that anyway, but it will skip any amount of spaces too. Note that I only tested this on amd64. I don't know how i386 is affected. Patch attached with submission follows: --- pmcannotate.c.orig 2012-03-03 09:16:30.000000000 +0200 +++ pmcannotate.c 2012-03-03 09:18:32.000000000 +0200 @@ -118,8 +118,6 @@ void *ptr; int nbytes; - if (isxdigit(str[1]) == 0) - return (0); if (sscanf(str, " %p%n", &ptr, &nbytes) != 1) return (0); if (str[nbytes] != ':' || isspace(str[nbytes + 1]) == 0) >Release-Note: >Audit-Trail: >Unformatted: