import lldb


def make_absolute_name(root: str, name: str) -> str:
    return '.'.join([root, name])


def register_lldb_commands(debugger: lldb.SBDebugger, cmd_map: dict[str, str]):
    for func, cmd in cmd_map.items():
        debugger.HandleCommand('command script add -f {func} {cmd}'.format(func=func, cmd=cmd))


def str_to_bool(val: str) -> bool:
    val = val.strip().lower()
    if val in {"y", "yes", "t", "true", "on", "1"}:
        return True
    if val in {"n", "no", "f", "false", "off", "0"}:
        return False
    raise ValueError(f"invalid truth value '{val}'")
