Skip to content

Commit 0aebdef

Browse files
author
Joel Brobecker
committed
[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.
1 parent 1c8e84b commit 0aebdef

File tree

2 files changed

+33
-12
lines changed

2 files changed

+33
-12
lines changed

gdb/ChangeLog

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
2013-10-01 Jerome Guitton <[email protected]>
2+
3+
Checked in by Joel Brobecker <[email protected]>
4+
* system-gdbinit/elinos.py (get_elinos_environment): Return an
5+
incomplete dictionnary instead of None in case of missing
6+
environment variables.
7+
(elinos_init): in case of an incomplete environment, best
8+
effort to load system libraries instead of abort.
9+
110
2013-10-01 Joel Brobecker <[email protected]>
211

312
* ada-lang.c (ada_has_this_exception_support): Ignore

gdb/system-gdbinit/elinos.py

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ def get_elinos_environment():
3535
* A list of Xenomai install prefixes (which could be empty, if
3636
the ELinOS project does not include Xenomai) at key 'xenomai'.
3737
38-
If one of these cannot be found, it is then assumed that the ELinOS
39-
environment is not properly set up. Return None in such a case,
40-
and print a warning.
38+
If one of these cannot be found, print a warning; the corresponding
39+
value in the returned dictionary will be None.
4140
"""
4241
result = {}
4342
for key in ("project", "cdk", "target"):
@@ -46,32 +45,45 @@ def get_elinos_environment():
4645
result[key] = os.environ[var]
4746
else:
4847
warn("%s not set" % var)
49-
return None
48+
result[key] = None
49+
50+
if result["project"] is not None:
51+
result["xenomai"] = glob.glob(result["project"] + "/xenomai-[0-9.]*")
52+
else:
53+
result["xenomai"] = []
5054

51-
result["xenomai"] = glob.glob(result["project"] + "/xenomai-[0-9.]*")
5255
return result
5356

5457

5558
def elinos_init():
5659
"""Initialize debugger environment for ELinOS.
5760
5861
Let the debugger know where to find the ELinOS libraries on host. This
59-
assumes that an ELinOS environment is properly set up. If not, abort
60-
with a warning.
62+
assumes that an ELinOS environment is properly set up. If some environment
63+
variables are missing, warn about which library may be missing.
6164
"""
6265
elinos_env = get_elinos_environment()
6366

64-
if elinos_env is None:
67+
solib_dirs = []
68+
69+
# System libraries
70+
if None in (elinos_env[key] for key in ("cdk", "target")):
6571
warn("ELinOS system libraries will not be loaded")
6672
else:
6773
solib_prefix = "%s/%s" % (elinos_env["cdk"], elinos_env["target"])
74+
solib_dirs += ["%s/%s" % (solib_prefix, "lib")]
75+
gdb.execute("set solib-absolute-prefix %s" % solib_prefix)
6876

69-
solib_dirs = []
77+
# Xenomai libraries. Those are optional, so have a lighter warning
78+
# if they cannot be located.
79+
if elinos_env["project"] is None:
80+
warn("Xenomai libraries may not be loaded")
81+
else:
7082
for dir in elinos_env['xenomai']:
71-
solib_dirs += ["%s/%s" % (dir, "xenomai-build/usr/realtime/lib")]
72-
solib_dirs += ["%s/%s" % (solib_prefix, "lib")]
83+
solib_dirs += ["%s/%s"
84+
% (dir, "xenomai-build/usr/realtime/lib")]
7385

74-
gdb.execute("set solib-absolute-prefix %s" % solib_prefix)
86+
if len(solib_dirs) != 0:
7587
gdb.execute("set solib-search-path %s" % ":".join(solib_dirs))
7688

7789

0 commit comments

Comments
 (0)