From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1424278AbcFHKJL (ORCPT ); Wed, 8 Jun 2016 06:09:11 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:35365 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161760AbcFHKJJ (ORCPT ); Wed, 8 Jun 2016 06:09:09 -0400 Subject: Re: [PATCH] scripts/gdb: Add automatic path expansion when loading modules To: Jan Kiszka References: <1465334764-11829-1-git-send-email-n.borisov.lkml@gmail.com> <5757E6DD.8030705@siemens.com> Cc: linux-kernel@vger.kernel.org, Kieran Bingham From: Nikolay Borisov Message-ID: <5757EEC1.6000309@gmail.com> Date: Wed, 8 Jun 2016 13:09:05 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <5757E6DD.8030705@siemens.com> Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/08/2016 12:35 PM, Jan Kiszka wrote: > On 2016-06-07 23:26, Nikolay Borisov wrote: >> Python doesn't do automatic expansion of paths. In case one passes >> path of the from ~/foo/bar the gdb scripts won't automatically expand >> that and as a result the symbols files won't be loaded. Fix this >> by explicitly expanding all paths which begin with "~" >> >> Signed-off-by: Nikolay Borisov >> --- >> scripts/gdb/linux/symbols.py | 7 +++++++ >> 1 file changed, 7 insertions(+) >> >> diff --git a/scripts/gdb/linux/symbols.py b/scripts/gdb/linux/symbols.py >> index 9a0f8923f67c..2f5b2bee8c34 100644 >> --- a/scripts/gdb/linux/symbols.py >> +++ b/scripts/gdb/linux/symbols.py >> @@ -81,6 +81,12 @@ lx-symbols command.""" >> self.module_files.append(root + "/" + name) >> self.module_files_updated = True >> >> + def __expand_homedir(self): >> + for index, path in enumerate(self.module_paths): >> + if path.startswith("~"): >> + self.module_paths[index] = os.path.expanduser(path) >> + >> + >> def _get_module_file(self, module_name): >> module_pattern = ".*/{0}\.ko$".format( >> module_name.replace("_", r"[_\-]")) >> @@ -160,6 +166,7 @@ lx-symbols command.""" >> self.module_files = [] >> self.module_files_updated = False >> >> + self.__expand_homedir() >> self.load_all_symbols() >> >> if hasattr(gdb, 'Breakpoint'): >> > > Valid point, but let's expand unconditionally in invoke when building > self.module_paths. > > I'm no Python expert, but my feeling tells me that there is even a more > compact way to do loop. Does this work? > > module_paths = [expanduser(p) for p in arg.spilt()] module_paths = [os.path.expanduser(p) for p in arg.spilt()] does work. I'm no python expert either, but list comprehensions is more idiomatic indeed. I will cook up a patch tonight and resend, unless you want to do it. > > Jan >