From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758243AbcFAIkL (ORCPT ); Wed, 1 Jun 2016 04:40:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41403 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754028AbcFAIkG (ORCPT ); Wed, 1 Jun 2016 04:40:06 -0400 Date: Wed, 1 Jun 2016 10:40:01 +0200 From: Jiri Olsa To: He Kuang Cc: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, alexander.shishkin@linux.intel.com, wangnan0@huawei.com, jpoimboe@redhat.com, ak@linux.intel.com, eranian@google.com, namhyung@kernel.org, adrian.hunter@intel.com, sukadev@linux.vnet.ibm.com, masami.hiramatsu.pt@hitachi.com, tumanova@linux.vnet.ibm.com, kan.liang@intel.com, penberg@kernel.org, dsahern@gmail.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v7 10/14] perf tools: Check the target platform before assigning unwind methods Message-ID: <20160601084001.GE13738@krava> References: <1464693552-104294-1-git-send-email-hekuang@huawei.com> <1464693552-104294-11-git-send-email-hekuang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1464693552-104294-11-git-send-email-hekuang@huawei.com> User-Agent: Mutt/1.6.1 (2016-04-27) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 01 Jun 2016 08:40:05 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); > + > + 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; why do you need to check for thread->unwind_libunwind_ops != NULL? it's all set at this point right? jirka