sim: allow the assert configure option everywhere
[deliverable/binutils-gdb.git] / gdb / system-gdbinit / elinos.py
CommitLineData
618f726f 1# Copyright (C) 2011-2016 Free Software Foundation, Inc.
776af39e
JB
2
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 3 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16"""Configure GDB using the ELinOS environment."""
17
18import os
19import glob
20import gdb
21
22
23def warn(msg):
24 print "warning: %s" % msg
25
26
27def get_elinos_environment():
28 """Return the ELinOS environment.
29
30 If the ELinOS environment is properly set up, return a dictionary
31 which contains:
32 * The path to the ELinOS project at key 'project';
33 * The path to the ELinOS CDK at key 'cdk';
34 * The ELinOS target name at key 'target' (Eg. 'i486-linux');
35 * A list of Xenomai install prefixes (which could be empty, if
36 the ELinOS project does not include Xenomai) at key 'xenomai'.
37
0aebdefa
JB
38 If one of these cannot be found, print a warning; the corresponding
39 value in the returned dictionary will be None.
776af39e
JB
40 """
41 result = {}
42 for key in ("project", "cdk", "target"):
43 var = "ELINOS_" + key.upper()
44 if var in os.environ:
45 result[key] = os.environ[var]
46 else:
47 warn("%s not set" % var)
0aebdefa
JB
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"] = []
776af39e 54
776af39e
JB
55 return result
56
57
58def elinos_init():
59 """Initialize debugger environment for ELinOS.
60
61 Let the debugger know where to find the ELinOS libraries on host. This
0aebdefa
JB
62 assumes that an ELinOS environment is properly set up. If some environment
63 variables are missing, warn about which library may be missing.
776af39e
JB
64 """
65 elinos_env = get_elinos_environment()
66
0aebdefa
JB
67 solib_dirs = []
68
69 # System libraries
70 if None in (elinos_env[key] for key in ("cdk", "target")):
776af39e
JB
71 warn("ELinOS system libraries will not be loaded")
72 else:
73 solib_prefix = "%s/%s" % (elinos_env["cdk"], elinos_env["target"])
0aebdefa
JB
74 solib_dirs += ["%s/%s" % (solib_prefix, "lib")]
75 gdb.execute("set solib-absolute-prefix %s" % solib_prefix)
776af39e 76
0aebdefa
JB
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:
776af39e 82 for dir in elinos_env['xenomai']:
0aebdefa
JB
83 solib_dirs += ["%s/%s"
84 % (dir, "xenomai-build/usr/realtime/lib")]
776af39e 85
0aebdefa 86 if len(solib_dirs) != 0:
776af39e
JB
87 gdb.execute("set solib-search-path %s" % ":".join(solib_dirs))
88
89
90if __name__ == "__main__":
91 elinos_init()
This page took 0.323956 seconds and 4 git commands to generate.