diff options
author | Joel Brobecker <brobecker@gnat.com> | 2013-10-01 09:21:52 +0000 |
---|---|---|
committer | Joel Brobecker <brobecker@gnat.com> | 2013-10-01 09:21:52 +0000 |
commit | 0aebdefa32dd85acb39c05c5c1039bfe4304148f (patch) | |
tree | 9e071231587f15ecc36eb7f778749f1a96e9a92f | |
parent | 1c8e84b0827ace271c460abcc13df9414304cc09 (diff) | |
download | gdb-0aebdefa32dd85acb39c05c5c1039bfe4304148f.zip gdb-0aebdefa32dd85acb39c05c5c1039bfe4304148f.tar.gz gdb-0aebdefa32dd85acb39c05c5c1039bfe4304148f.tar.bz2 |
[ELinOS] Best effort to load system libraries in case of incomplete env
So far elinos.py was assuming that the whole ELinOS environment was
around to find the system libraries; if some environment variables
were missing, the script would just abort.
This was a bit extreme. It is possible to do better than that: to get
the core system libraries, one doesn't need to have a full environment
but just the path to the CDK. The path to kernel project is only
needed for the optional Xenomai libs.
gdb/ChangeLog:
* system-gdbinit/elinos.py (get_elinos_environment): Return an
incomplete dictionnary instead of None in case of missing
environment variables.
(elinos_init): in case of an incomplete environment, best
effort to load system libraries instead of abort.
-rw-r--r-- | gdb/ChangeLog | 9 | ||||
-rw-r--r-- | gdb/system-gdbinit/elinos.py | 36 |
2 files changed, 33 insertions, 12 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 15ca4f2..44229b0 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,12 @@ +2013-10-01 Jerome Guitton <guitton@adacore.com> + + Checked in by Joel Brobecker <brobecker@adacore.com> + * system-gdbinit/elinos.py (get_elinos_environment): Return an + incomplete dictionnary instead of None in case of missing + environment variables. + (elinos_init): in case of an incomplete environment, best + effort to load system libraries instead of abort. + 2013-10-01 Joel Brobecker <brobecker@adacore.com> * ada-lang.c (ada_has_this_exception_support): Ignore diff --git a/gdb/system-gdbinit/elinos.py b/gdb/system-gdbinit/elinos.py index 08c5b0f..581904a 100644 --- a/gdb/system-gdbinit/elinos.py +++ b/gdb/system-gdbinit/elinos.py @@ -35,9 +35,8 @@ def get_elinos_environment(): * A list of Xenomai install prefixes (which could be empty, if the ELinOS project does not include Xenomai) at key 'xenomai'. - If one of these cannot be found, it is then assumed that the ELinOS - environment is not properly set up. Return None in such a case, - and print a warning. + If one of these cannot be found, print a warning; the corresponding + value in the returned dictionary will be None. """ result = {} for key in ("project", "cdk", "target"): @@ -46,9 +45,13 @@ def get_elinos_environment(): result[key] = os.environ[var] else: warn("%s not set" % var) - return None + result[key] = None + + if result["project"] is not None: + result["xenomai"] = glob.glob(result["project"] + "/xenomai-[0-9.]*") + else: + result["xenomai"] = [] - result["xenomai"] = glob.glob(result["project"] + "/xenomai-[0-9.]*") return result @@ -56,22 +59,31 @@ def elinos_init(): """Initialize debugger environment for ELinOS. Let the debugger know where to find the ELinOS libraries on host. This - assumes that an ELinOS environment is properly set up. If not, abort - with a warning. + assumes that an ELinOS environment is properly set up. If some environment + variables are missing, warn about which library may be missing. """ elinos_env = get_elinos_environment() - if elinos_env is None: + solib_dirs = [] + + # System libraries + if None in (elinos_env[key] for key in ("cdk", "target")): warn("ELinOS system libraries will not be loaded") else: solib_prefix = "%s/%s" % (elinos_env["cdk"], elinos_env["target"]) + solib_dirs += ["%s/%s" % (solib_prefix, "lib")] + gdb.execute("set solib-absolute-prefix %s" % solib_prefix) - solib_dirs = [] + # Xenomai libraries. Those are optional, so have a lighter warning + # if they cannot be located. + if elinos_env["project"] is None: + warn("Xenomai libraries may not be loaded") + else: for dir in elinos_env['xenomai']: - solib_dirs += ["%s/%s" % (dir, "xenomai-build/usr/realtime/lib")] - solib_dirs += ["%s/%s" % (solib_prefix, "lib")] + solib_dirs += ["%s/%s" + % (dir, "xenomai-build/usr/realtime/lib")] - gdb.execute("set solib-absolute-prefix %s" % solib_prefix) + if len(solib_dirs) != 0: gdb.execute("set solib-search-path %s" % ":".join(solib_dirs)) |