From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757973AbcFAKFY (ORCPT ); Wed, 1 Jun 2016 06:05:24 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:18599 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757911AbcFAKFW (ORCPT ); Wed, 1 Jun 2016 06:05:22 -0400 Subject: Re: [PATCH v7 10/14] perf tools: Check the target platform before assigning unwind methods To: Jiri Olsa References: <1464693552-104294-1-git-send-email-hekuang@huawei.com> <1464693552-104294-11-git-send-email-hekuang@huawei.com> <20160601084039.GH13738@krava> CC: , , , , , , , , , , , , , , , , From: Hekuang Message-ID: <574EB2AA.3060908@huawei.com> Date: Wed, 1 Jun 2016 18:02:18 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <20160601084039.GH13738@krava> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.110.55.166] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090202.574EB2BD.002A,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 5d45bf3d70a01ee86cd75ff60095e939 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 2016/6/1 16:40, Jiri Olsa 写道: > On Tue, May 31, 2016 at 11:19:08AM +0000, He Kuang wrote: > > SNIP > >> -int unwind__prepare_access(struct thread *thread) >> +int unwind__prepare_access(struct thread *thread, struct map *map) >> { >> - unwind__register_ops(thread, local_unwind_libunwind_ops); >> + const char *arch; >> + enum dso_type dso_type; >> + struct unwind_libunwind_ops *ops = local_unwind_libunwind_ops; >> >> - return thread->unwind_libunwind_ops->prepare_access(thread); >> + if (!thread->mg->machine->env) >> + return 0; >> + >> + dso_type = dso__type(map->dso, thread->mg->machine); >> + if (dso_type == DSO__TYPE_UNKNOWN) >> + return 0; >> + >> + if (thread->addr_space) >> + pr_debug("unwind: thread map already set, 64bit is %d, dso=%s\n", >> + dso_type == DSO__TYPE_64BIT, map->dso->name); > should we leave once the address space is set? resseting it over > again seems like memory leak unless I'm missing something... > > also this check should be probably the first thing we do in here Sure, I must miss the return statement here. > thanks, > jirka > >> + >> + arch = normalize_arch(thread->mg->machine->env->arch); >> + pr_debug("unwind: target platform=%s\n", arch); >> + >> + unwind__register_ops(thread, ops); >> + >> + if (thread->unwind_libunwind_ops) >> + return thread->unwind_libunwind_ops->prepare_access(thread); >> + else >> + return 0; >> } > SNIP >