[NFC][LLVM][CodeGen] Move LiveDebugVariables.h into llvm/include/llvm/CodeGen (#88374)
[llvm-project.git] / lldb / packages / Python / lldbsuite / test / lldbplatform.py
blobbdde973cb64502793de47a18946365b1c4a8ef1c
1 """ This module represents an abstraction of an lldb target / host platform. """
3 # System modules
4 import itertools
6 # LLDB modules
7 import lldb
10 windows,
11 linux,
12 macosx,
13 darwin,
14 ios,
15 tvos,
16 watchos,
17 bridgeos,
18 darwin_all,
19 darwin_embedded,
20 darwin_simulator,
21 freebsd,
22 netbsd,
23 bsd_all,
24 android,
25 ) = range(15)
27 __darwin_embedded = ["ios", "tvos", "watchos", "bridgeos"]
28 __darwin_simulators = ["iphonesimulator", "watchsimulator", "appletvsimulator"]
30 __name_lookup = {
31 windows: ["windows"],
32 linux: ["linux"],
33 macosx: ["macosx"],
34 darwin: ["darwin"],
35 ios: ["ios", "iphonesimulator"],
36 tvos: ["tvos", "appletvsimulator"],
37 watchos: ["watchos", "watchsimulator"],
38 bridgeos: ["bridgeos"],
39 darwin_all: ["macosx", "darwin"] + __darwin_embedded + __darwin_simulators,
40 darwin_embedded: __darwin_embedded + __darwin_simulators,
41 darwin_simulator: __darwin_simulators,
42 freebsd: ["freebsd"],
43 netbsd: ["netbsd"],
44 bsd_all: ["freebsd", "netbsd"],
45 android: ["android"],
49 def translate(values):
50 if isinstance(values, int):
51 # This is a value from the platform enumeration, translate it.
52 return __name_lookup[values]
53 elif isinstance(values, str):
54 # This is a raw string, return it.
55 return [values]
56 elif hasattr(values, "__iter__"):
57 # This is an iterable, convert each item.
58 result = [translate(x) for x in values]
59 result = list(itertools.chain(*result))
60 return result
61 return values