From d1fe92f375b088ff61369d35b51673b5d524c39c Mon Sep 17 00:00:00 2001 From: David Pursell Date: Mon, 5 Oct 2015 15:36:28 -0700 Subject: [PATCH] gdbclient.py: set PWD when querying makefiles. Python's subprocess.check_output() cwd argument does not change the PWD environmental variable, which is what dumpvar.mk uses to turn relative paths into absolute paths. This led to incorrect symbol paths when gdbclient was not run from the root directory. This CL fixes the bug by manually setting PWD before calling the makefile. It's possible that dumpvar.mk should be using a different method to get the current directory, but I was scared to change any core build logic and this approach seems to work just fine. Change-Id: Ibe3db0bef6694934c512918f7562029313b1deae --- scripts/gdbclient.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/gdbclient.py b/scripts/gdbclient.py index 811d564e7..9d029efa7 100755 --- a/scripts/gdbclient.py +++ b/scripts/gdbclient.py @@ -65,7 +65,12 @@ def dump_var(root, variable): "{}/build/core/config.mk".format(root), "dumpvar-{}".format(variable)] + # subprocess cwd argument does not change the PWD shell variable, but + # dumpvar.mk uses PWD to create an absolute path, so we need to set it. + saved_pwd = os.environ['PWD'] + os.environ['PWD'] = root make_output = subprocess.check_output(make_args, cwd=root) + os.environ['PWD'] = saved_pwd return make_output.splitlines()[0]