Received: by 10.223.164.202 with SMTP id h10csp2734701wrb; Mon, 27 Nov 2017 23:57:40 -0800 (PST) X-Google-Smtp-Source: AGs4zMa6PZ1tKI5nqxAJcjj3YEAOArowv2NEuoCemy81nq8yVetCe322KsTJBkcgA8ToB1UxqiN6 X-Received: by 10.159.251.140 with SMTP id m12mr42120279pls.199.1511855859997; Mon, 27 Nov 2017 23:57:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511855859; cv=none; d=google.com; s=arc-20160816; b=GvbXUwqUuG5Q67T09y5jgYOx56cx9x7WG1O5/gAeQOZJ3OsRrfdvEsrtStocGq5fIm iAPvuRWO06cHho0Xy9TgdKElCRbAtH9jfBb+E1pOsWVpOhRahE7feebTP0MRW/M2d/JN xfTWcBfQ59H1q2vKyGhYn4RCdwwaS3SQ3LjdiMVGQDJQk7mD4imyWqihTLExrF7VhJim INzpJPVfXZvcePBAwVqtJhwfq/U9sT+UGMPgk25ECyxANZY1k0ERCaVTQ/A5gMfj0FTX QsCwhktdMjFIBARsSaqhFk0YX4wiF6cnWFOz6IlDjpsr/cdvWkTOurC6wK8HQg169pdi K4aQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=jXJkT7I0V6TlTw9w6taCIDdXawpQ+0fgf19o4V1HwyM=; b=viKDXMugmlBNVeD7SM/AMzyS2dTIl8K/3+jX0eBQR/F3706DeI9QkjCDs/uJu+xwRO LQtmRaCgHrreCSX36q5Wi3nf5NtqyQakKEfrfjoEkV50gtIV2DkZ6/Uaxif54Xodfljq Nt0VG2rovZEJzz4yq5IUaWT4z1KqyC2Req2gQaQdDUJ/hawTpzXsRkmoz9rK+/YXv+9E ax9V72B92LMkRU9mtMZj6KF43pNG8o5F30okyMSjao7vif7csDr4FBij9xTmKvhjiCLC C5D1R7Mz1oh238he5Xu8PuHl9Y8Fr/M4ITB5wlGE2FEUS20DKH62EW2G0838qTZzIa3h uFmw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f82si19229810pfe.355.2017.11.27.23.57.28; Mon, 27 Nov 2017 23:57:39 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751610AbdK1H4p (ORCPT + 78 others); Tue, 28 Nov 2017 02:56:45 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:49094 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750839AbdK1H4n (ORCPT ); Tue, 28 Nov 2017 02:56:43 -0500 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vAS7ruod104905 for ; Tue, 28 Nov 2017 02:56:42 -0500 Received: from e06smtp13.uk.ibm.com (e06smtp13.uk.ibm.com [195.75.94.109]) by mx0a-001b2d01.pphosted.com with ESMTP id 2eh2q0jtaw-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 28 Nov 2017 02:56:42 -0500 Received: from localhost by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 28 Nov 2017 07:56:39 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 28 Nov 2017 07:56:36 -0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id vAS7uaps45220070; Tue, 28 Nov 2017 07:56:36 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4D9FD52043; Tue, 28 Nov 2017 06:49:59 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 0BAF552041; Tue, 28 Nov 2017 06:49:59 +0000 (GMT) From: Thomas Richter To: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, acme@kernel.org Cc: brueckner@linux.vnet.ibm.com, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com, Thomas Richter Subject: [PATCH] perf annotate: Fix objdump comment parsing for Intel mov dissassembly Date: Tue, 28 Nov 2017 08:56:32 +0100 X-Mailer: git-send-email 2.13.5 X-TM-AS-GCONF: 00 x-cbid: 17112807-0012-0000-0000-000005924723 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17112807-0013-0000-0000-0000190D2C56 Message-Id: <20171128075632.72182-1-tmricht@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-11-28_03:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1711280107 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The command 'perf annotate' parses the output of objdump and also investigates the comments produced by objdump. For example the output of objdump produces (on x86): 23eee: 4c 8b 3d 13 01 21 00 mov 0x210113(%rip),%r15 # 234008 and the function mov__parse() is called to investigate the complete line. Mov__parse() breaks this line into several parts and finally calls function comment__symbol() to parse the data after the comment character '#'. Comment__symbol() expects a hexadecimal address followed by a symbol in '<' and '>' brackets. However the 2nd parameter given to function comment__symbol() always points to the comment character '#'. The address parsing always returns 0 because the character '#' is not a digit and strtoull() fails without being noticed. Fix this by advancing the second parameter to function comment__symbol() by one byte before invocation and add an error check after strtoull() has been called. Signed-off-by: Thomas Richter Reviewed-by: Hendrik Brueckner --- tools/perf/util/annotate.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index aa66791b1bfc..900147454fe9 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -323,6 +323,8 @@ static int comment__symbol(char *raw, char *comment, u64 *addrp, char **namep) return 0; *addrp = strtoull(comment, &endptr, 16); + if (endptr == comment) + return 0; name = strchr(endptr, '<'); if (name == NULL) return -1; @@ -436,8 +438,8 @@ static int mov__parse(struct arch *arch, struct ins_operands *ops, struct map *m return 0; comment = ltrim(comment); - comment__symbol(ops->source.raw, comment, &ops->source.addr, &ops->source.name); - comment__symbol(ops->target.raw, comment, &ops->target.addr, &ops->target.name); + comment__symbol(ops->source.raw, comment + 1, &ops->source.addr, &ops->source.name); + comment__symbol(ops->target.raw, comment + 1, &ops->target.addr, &ops->target.name); return 0; @@ -481,7 +483,7 @@ static int dec__parse(struct arch *arch __maybe_unused, struct ins_operands *ops return 0; comment = ltrim(comment); - comment__symbol(ops->target.raw, comment, &ops->target.addr, &ops->target.name); + comment__symbol(ops->target.raw, comment + 1, &ops->target.addr, &ops->target.name); return 0; } -- 2.13.4 From 1586919830939615514@xxx Sat Dec 16 06:11:24 +0000 2017 X-GM-THRID: 1585589407119938428 X-Gmail-Labels: Inbox,Category Forums