|
35 | 35 | from commands.settings import SettingsCommand |
36 | 36 | from commands.xinfo import XinfoCommand |
37 | 37 | from common.state import LLEFState |
| 38 | +from common.util import lldb_version_to_clang, parse_apple_clang_version_string, parse_llvm_version_string |
38 | 39 | from handlers.stop_hook import StopHookHandler |
39 | 40 |
|
40 | 41 |
|
@@ -69,8 +70,19 @@ def __lldb_init_module(debugger: SBDebugger, _: dict[Any, Any]) -> None: |
69 | 70 |
|
70 | 71 | LLEFState.platform = platform.system() |
71 | 72 | if LLEFState.platform == "Darwin": |
72 | | - # Getting Clang version (e.g. lldb-1600.0.36.3) |
73 | | - LLEFState.version = [int(x) for x in debugger.GetVersionString().split()[0].split("-")[1].split(".")] |
| 73 | + # On Darwin, we have two possibilities: |
| 74 | + # - LLDB shipped with Apple Clang |
| 75 | + # - LLDB built from the LLVM sources |
| 76 | + # Those have different versioning schemes, and they need to be normalized to the Apple Clang version |
| 77 | + # to adhere to the assumptions taken in other places regarding LLDB on Darwin. |
| 78 | + if version := parse_apple_clang_version_string(debugger.GetVersionString()): |
| 79 | + LLEFState.version = version |
| 80 | + elif version := parse_llvm_version_string(debugger.GetVersionString()): |
| 81 | + LLEFState.version = lldb_version_to_clang(version) |
| 82 | + else: |
| 83 | + raise ValueError(f"Unable to parse LLDB version string: {debugger.GetVersionString()}") |
74 | 84 | else: |
75 | | - # Getting LLDB version (e.g. lldb version 16.0.0) |
76 | | - LLEFState.version = [int(x) for x in debugger.GetVersionString().split("version")[1].split()[0].split(".")] |
| 85 | + if version := parse_llvm_version_string(debugger.GetVersionString()): |
| 86 | + LLEFState.version = version |
| 87 | + else: |
| 88 | + raise ValueError(f"Unable to parse LLDB version string: {debugger.GetVersionString()}") |
0 commit comments