|
| 1 | +#!/usr/bin/env python3 |
| 2 | +""" |
| 3 | +Symbolication Tool for ravynOS Crash Analysis |
| 4 | +
|
| 5 | +This tool maps crash addresses to symbols in compiled binaries, helping identify |
| 6 | +the exact function and instruction where a crash occurred. |
| 7 | +
|
| 8 | +Usage: |
| 9 | + ./symbolicate.py <binary_path> <address> [<address2> ...] |
| 10 | + ./symbolicate.py <binary_path> --rip <address> --rax <address> |
| 11 | + ./symbolicate.py <binary_path> --stack-trace <addr1>,<addr2>,<addr3> |
| 12 | +
|
| 13 | +Examples: |
| 14 | + ./symbolicate.py /path/to/launchd 0x1d9660 |
| 15 | + ./symbolicate.py /path/to/dyld 0x00000001154ad2eb |
| 16 | + ./symbolicate.py /path/to/dyld --rip 0x1d9660 --rax 0x8010000000000007 |
| 17 | + ./symbolicate.py /path/to/dyld --stack-trace 0x1d9660,0x1d9700,0x1d9750 |
| 18 | +""" |
| 19 | + |
| 20 | +import sys |
| 21 | +import os |
| 22 | +import subprocess |
| 23 | +import re |
| 24 | +import argparse |
| 25 | +from dataclasses import dataclass |
| 26 | +from typing import List, Optional, Dict, Tuple |
| 27 | +import json |
| 28 | + |
| 29 | +@dataclass |
| 30 | +class Symbol: |
| 31 | + """Represents a symbol in the binary""" |
| 32 | + address: int |
| 33 | + size: int |
| 34 | + name: str |
| 35 | + section: str |
| 36 | + is_function: bool |
| 37 | + |
| 38 | + def contains(self, addr: int) -> bool: |
| 39 | + """Check if address falls within this symbol's range""" |
| 40 | + return self.address <= addr < (self.address + self.size) |
| 41 | + |
| 42 | + def offset(self, addr: int) -> int: |
| 43 | + """Get offset from symbol start to given address""" |
| 44 | + return addr - self.address |
| 45 | + |
| 46 | + def __repr__(self) -> str: |
| 47 | + offset_str = f"+0x{self.offset(addr):x}" if hasattr(self, 'addr') else "" |
| 48 | + return f"{self.name} ({self.section}) @ 0x{self.address:x}" |
| 49 | + |
| 50 | + |
| 51 | +@dataclass |
| 52 | +class SymbolicationResult: |
| 53 | + """Result of symbolication for a single address""" |
| 54 | + address: int |
| 55 | + symbol: Optional[Symbol] |
| 56 | + context: Optional[str] # e.g., "first instruction", "middle of function" |
| 57 | + |
| 58 | + def __str__(self) -> str: |
| 59 | + if not self.symbol: |
| 60 | + return f"0x{self.address:x} - Unknown symbol" |
| 61 | + |
| 62 | + offset = self.offset() |
| 63 | + if offset == 0: |
| 64 | + offset_str = " (entry point)" |
| 65 | + else: |
| 66 | + offset_str = f" +0x{offset:x}" |
| 67 | + |
| 68 | + return f"0x{self.address:x} -> {self.symbol.name}{offset_str} ({self.symbol.section})" |
| 69 | + |
| 70 | + def offset(self) -> int: |
| 71 | + if self.symbol: |
| 72 | + return self.symbol.offset(self.address) |
| 73 | + return 0 |
| 74 | + |
| 75 | + |
| 76 | +class Symbolizer: |
| 77 | + """Main symbolication engine""" |
| 78 | + |
| 79 | + def __init__(self, binary_path: str, verbose: bool = False): |
| 80 | + self.binary_path = binary_path |
| 81 | + self.verbose = verbose |
| 82 | + self.symbols: List[Symbol] = [] |
| 83 | + self._symbol_map: Dict[int, Symbol] = {} |
| 84 | + |
| 85 | + if not os.path.exists(binary_path): |
| 86 | + raise FileNotFoundError(f"Binary not found: {binary_path}") |
| 87 | + |
| 88 | + self._load_symbols() |
| 89 | + |
| 90 | + def _find_otool(self) -> Optional[str]: |
| 91 | + """Find otool in common locations""" |
| 92 | + possible_paths = [ |
| 93 | + 'otool', |
| 94 | + '/usr/bin/otool', |
| 95 | + '/usr/local/bin/otool', |
| 96 | + '/nest/build/Developer/Toolchains/Default.xctoolchain/usr/bin/otool', |
| 97 | + ] |
| 98 | + |
| 99 | + for path in possible_paths: |
| 100 | + try: |
| 101 | + result = subprocess.run([path, '-h', '--version'], |
| 102 | + capture_output=True, timeout=2) |
| 103 | + if result.returncode == 0: |
| 104 | + return path |
| 105 | + except: |
| 106 | + pass |
| 107 | + |
| 108 | + return None |
| 109 | + |
| 110 | + def _load_symbols(self): |
| 111 | + """Load symbols from the binary using nm or otool""" |
| 112 | + try: |
| 113 | + # First, check if this is a Mach-O binary (ravynOS/macOS) |
| 114 | + if self._is_macho_binary(): |
| 115 | + self._load_symbols_from_macho() |
| 116 | + else: |
| 117 | + # Fall back to ELF (nm) |
| 118 | + self._load_symbols_from_elf() |
| 119 | + |
| 120 | + except FileNotFoundError: |
| 121 | + raise RuntimeError("Symbol tools not found. Install binutils and/or otool.") |
| 122 | + except subprocess.TimeoutExpired: |
| 123 | + raise RuntimeError("Symbol loading timed out") |
| 124 | + |
| 125 | + if self.verbose: |
| 126 | + print(f"Loaded {len(self.symbols)} symbols", file=sys.stderr) |
| 127 | + |
| 128 | + def _is_macho_binary(self) -> bool: |
| 129 | + """Check if binary is Mach-O format""" |
| 130 | + try: |
| 131 | + result = subprocess.run( |
| 132 | + ['file', self.binary_path], |
| 133 | + capture_output=True, |
| 134 | + text=True, |
| 135 | + timeout=10 |
| 136 | + ) |
| 137 | + return 'Mach-O' in result.stdout |
| 138 | + except: |
| 139 | + return False |
| 140 | + |
| 141 | + def _load_symbols_from_elf(self): |
| 142 | + """Load symbols from ELF binary using nm""" |
| 143 | + result = subprocess.run( |
| 144 | + ['nm', '-nSt', self.binary_path], |
| 145 | + capture_output=True, |
| 146 | + text=True, |
| 147 | + timeout=30 |
| 148 | + ) |
| 149 | + |
| 150 | + if result.returncode != 0: |
| 151 | + if self.verbose: |
| 152 | + print(f"Warning: nm failed: {result.stderr}", file=sys.stderr) |
| 153 | + return |
| 154 | + |
| 155 | + self._parse_nm_output(result.stdout) |
| 156 | + |
| 157 | + def _load_symbols_from_macho(self): |
| 158 | + """Load symbols from Mach-O binary using otool""" |
| 159 | + # Find otool |
| 160 | + otool_path = self._find_otool() |
| 161 | + if not otool_path: |
| 162 | + if self.verbose: |
| 163 | + print(f"Warning: otool not found", file=sys.stderr) |
| 164 | + return |
| 165 | + |
| 166 | + # Get disassembly with symbols |
| 167 | + result = subprocess.run( |
| 168 | + [otool_path, '-tv', self.binary_path], |
| 169 | + capture_output=True, |
| 170 | + text=True, |
| 171 | + timeout=30 |
| 172 | + ) |
| 173 | + |
| 174 | + if result.returncode != 0: |
| 175 | + if self.verbose: |
| 176 | + print(f"Warning: otool -tv failed: {result.stderr}", file=sys.stderr) |
| 177 | + return |
| 178 | + |
| 179 | + self._parse_otool_output(result.stdout) |
| 180 | + |
| 181 | + def _parse_nm_output(self, output: str): |
| 182 | + """Parse nm output in format: address size type section name""" |
| 183 | + # Format from 'nm -nSt': address size type section name |
| 184 | + pattern = r'^([0-9a-f]+)\s+([0-9a-f]+)\s+(.)\s+(\S+)\s+(.+)$' |
| 185 | + |
| 186 | + for line in output.strip().split('\n'): |
| 187 | + if not line.strip(): |
| 188 | + continue |
| 189 | + |
| 190 | + match = re.match(pattern, line) |
| 191 | + if not match: |
| 192 | + continue |
| 193 | + |
| 194 | + addr_str, size_str, sym_type, section, name = match.groups() |
| 195 | + |
| 196 | + try: |
| 197 | + address = int(addr_str, 16) |
| 198 | + size = int(size_str, 16) |
| 199 | + is_function = sym_type in 'tT' # lowercase = local, uppercase = global |
| 200 | + |
| 201 | + symbol = Symbol( |
| 202 | + address=address, |
| 203 | + size=size, |
| 204 | + name=name, |
| 205 | + section=section, |
| 206 | + is_function=is_function |
| 207 | + ) |
| 208 | + |
| 209 | + self.symbols.append(symbol) |
| 210 | + if address not in self._symbol_map: |
| 211 | + self._symbol_map[address] = symbol |
| 212 | + |
| 213 | + except (ValueError, IndexError) as e: |
| 214 | + if self.verbose: |
| 215 | + print(f"Warning: Failed to parse symbol line: {line}", file=sys.stderr) |
| 216 | + |
| 217 | + # Sort symbols by address for binary search |
| 218 | + self.symbols.sort(key=lambda s: s.address) |
| 219 | + |
| 220 | + def _parse_otool_output(self, output: str): |
| 221 | + """Parse otool -tv output for Mach-O binaries |
| 222 | +
|
| 223 | + Format example: |
| 224 | + _main: |
| 225 | + 0000000100000be0 pushq %rbp |
| 226 | +
|
| 227 | + Or with actual symbol names at the start |
| 228 | + """ |
| 229 | + current_symbol = None |
| 230 | + current_address = None |
| 231 | + max_instruction_address = None |
| 232 | + |
| 233 | + for line in output.strip().split('\n'): |
| 234 | + line = line.strip() |
| 235 | + if not line: |
| 236 | + continue |
| 237 | + |
| 238 | + # Check for symbol name (function definition) |
| 239 | + # Format: _functionname: or functionname: |
| 240 | + if line.endswith(':') and not line[0].isdigit(): |
| 241 | + symbol_name = line[:-1] |
| 242 | + current_symbol = symbol_name |
| 243 | + current_address = None |
| 244 | + continue |
| 245 | + |
| 246 | + # Parse instruction lines to get addresses |
| 247 | + # Format: 0000000100000be0 pushq %rbp |
| 248 | + parts = line.split() |
| 249 | + if len(parts) >= 2 and all(c in '0123456789abcdef' for c in parts[0]): |
| 250 | + try: |
| 251 | + address = int(parts[0], 16) |
| 252 | + if max_instruction_address is None or address > max_instruction_address: |
| 253 | + max_instruction_address = address |
| 254 | + |
| 255 | + if current_symbol and current_address is None: |
| 256 | + # This is the first instruction of a symbol |
| 257 | + current_address = address |
| 258 | + |
| 259 | + # Create symbol entry |
| 260 | + symbol = Symbol( |
| 261 | + address=address, |
| 262 | + size=0, # We don't know the size from otool -tv alone |
| 263 | + name=current_symbol, |
| 264 | + section='__text', # Usually in text section |
| 265 | + is_function=True |
| 266 | + ) |
| 267 | + |
| 268 | + self.symbols.append(symbol) |
| 269 | + if address not in self._symbol_map: |
| 270 | + self._symbol_map[address] = symbol |
| 271 | + |
| 272 | + current_symbol = None |
| 273 | + |
| 274 | + except (ValueError, IndexError): |
| 275 | + pass |
| 276 | + |
| 277 | + # Sort symbols and infer synthetic sizes so range lookups work for Mach-O. |
| 278 | + self.symbols.sort(key=lambda s: s.address) |
| 279 | + for i in range(len(self.symbols) - 1): |
| 280 | + next_addr = self.symbols[i + 1].address |
| 281 | + curr_addr = self.symbols[i].address |
| 282 | + inferred = max(1, next_addr - curr_addr) |
| 283 | + if self.symbols[i].size == 0: |
| 284 | + self.symbols[i].size = inferred |
| 285 | + |
| 286 | + # Keep the final symbol searchable for nearby addresses. |
| 287 | + if self.symbols and self.symbols[-1].size == 0: |
| 288 | + if max_instruction_address is not None and max_instruction_address >= self.symbols[-1].address: |
| 289 | + self.symbols[-1].size = (max_instruction_address - self.symbols[-1].address) + 1 |
| 290 | + else: |
| 291 | + self.symbols[-1].size = 1 |
| 292 | + |
| 293 | + def symbolicate(self, address: int) -> SymbolicationResult: |
| 294 | + """Find the symbol containing the given address""" |
| 295 | + |
| 296 | + # Quick lookup if exact address exists |
| 297 | + if address in self._symbol_map: |
| 298 | + return SymbolicationResult( |
| 299 | + address=address, |
| 300 | + symbol=self._symbol_map[address], |
| 301 | + context="entry point" |
| 302 | + ) |
| 303 | + |
| 304 | + # Binary search for containing symbol |
| 305 | + symbol = self._find_containing_symbol(address) |
| 306 | + |
| 307 | + if symbol: |
| 308 | + context = None |
| 309 | + offset = symbol.offset(address) |
| 310 | + |
| 311 | + # Provide context based on offset |
| 312 | + if offset == 0: |
| 313 | + context = "entry point" |
| 314 | + elif offset < 32: # Typical prologue size |
| 315 | + context = "in prologue" |
| 316 | + elif offset == symbol.size - 1: |
| 317 | + context = "at exit" |
| 318 | + |
| 319 | + return SymbolicationResult( |
| 320 | + address=address, |
| 321 | + symbol=symbol, |
| 322 | + context=context |
| 323 | + ) |
| 324 | + |
| 325 | + return SymbolicationResult(address=address, symbol=None, context=None) |
| 326 | + |
| 327 | + def _find_containing_symbol(self, address: int) -> Optional[Symbol]: |
| 328 | + """Binary search to find symbol containing address""" |
| 329 | + left, right = 0, len(self.symbols) - 1 |
| 330 | + |
| 331 | + while left <= right: |
| 332 | + mid = (left + right) // 2 |
| 333 | + symbol = self.symbols[mid] |
| 334 | + |
| 335 | + if symbol.contains(address): |
| 336 | + return symbol |
| 337 | + elif symbol.address > address: |
| 338 | + right = mid - 1 |
| 339 | + else: |
| 340 | + left = mid + 1 |
| 341 | + |
| 342 | + # Check the symbol just before the address |
| 343 | + if right >= 0 and right < len(self.symbols): |
| 344 | + symbol = self.symbols[right] |
| 345 | + if symbol.contains(address): |
| 346 | + return symbol |
| 347 | + |
| 348 | + return None |
| 349 | + |
| 350 | + def symbolicate_multiple(self, addresses: List[int]) -> List[SymbolicationResult]: |
| 351 | + """Symbolicate multiple addresses""" |
| 352 | + return [self.symbolicate(addr) for addr in addresses] |
| 353 | + |
| 354 | + def find_symbol_by_name(self, name: str, exact: bool = False) -> List[Symbol]: |
| 355 | + """Find symbols by name (substring or exact match)""" |
| 356 | + results = [] |
| 357 | + for symbol in self.symbols: |
| 358 | + if exact: |
| 359 | + if symbol.name == name: |
| 360 | + results.append(symbol) |
| 361 | + else: |
| 362 | + if name.lower() in symbol.name.lower(): |
| 363 | + results.append(symbol) |
| 364 | + return results |
| 365 | + |
| 366 | + def get_context_around_address(self, address: int, before: int = 5, after: int = 5) -> List[Symbol]: |
| 367 | + """Get symbols around a given address""" |
| 368 | + idx = self._find_symbol_index(address) |
| 369 | + if idx is None: |
| 370 | + return [] |
| 371 | + |
| 372 | + start = max(0, idx - before) |
| 373 | + end = min(len(self.symbols), idx + after + 1) |
| 374 | + return self.symbols[start:end] |
| 375 | + |
| 376 | + def _find_symbol_index(self, address: int) -> Optional[int]: |
| 377 | + """Find the index of a symbol containing or near the address""" |
| 378 | + left, right = 0, len(self.symbols) - 1 |
| 379 | + |
| 380 | + while left <= right: |
| 381 | + mid = (left + right) // 2 |
| 382 | + symbol = self.symbols[mid] |
| 383 | + |
| 384 | + if symbol.contains(address): |
| 385 | + return mid |
| 386 | + elif symbol.address > address: |
| 387 | + right = mid - 1 |
| 388 | + else: |
| 389 | + left = mid + 1 |
| 390 | + |
| 391 | + return right if right >= 0 else None |
| 392 | + |
| 393 | + |
| 394 | +def parse_hex_address(addr_str: str) -> int: |
| 395 | + """Parse address string (with or without 0x prefix)""" |
| 396 | + addr_str = addr_str.strip() |
| 397 | + if addr_str.startswith(('0x', '0X')): |
| 398 | + return int(addr_str, 16) |
| 399 | + return int(addr_str, 16) |
| 400 | + |
| 401 | + |
| 402 | +def format_hex_address(addr: int) -> str: |
| 403 | + """Format address as hex string""" |
| 404 | + return f"0x{addr:x}" |
| 405 | + |
| 406 | + |
| 407 | +def normalize_code_address(raw_addr: int, slide: int) -> int: |
| 408 | + """Normalize a runtime code address to a file-relative address using slide.""" |
| 409 | + if slide < 0: |
| 410 | + raise ValueError("slide must be non-negative") |
| 411 | + if raw_addr < slide: |
| 412 | + raise ValueError(f"address {format_hex_address(raw_addr)} is smaller than slide {format_hex_address(slide)}") |
| 413 | + return raw_addr - slide |
| 414 | + |
| 415 | + |
| 416 | +def main(): |
| 417 | + parser = argparse.ArgumentParser( |
| 418 | + description='Symbolicate crash addresses in ravynOS binaries', |
| 419 | + formatter_class=argparse.RawDescriptionHelpFormatter, |
| 420 | + epilog=''' |
| 421 | +Examples: |
| 422 | + %(prog)s /path/to/launchd 0x1d9660 |
| 423 | + %(prog)s /path/to/dyld 0x1d9660 0x1d9700 0x1d9750 |
| 424 | + %(prog)s /path/to/dyld --rip 0x1d9660 |
| 425 | + %(prog)s /path/to/dyld --stack-trace 0x1d9660,0x1d9700,0x1d9750 |
| 426 | + %(prog)s /path/to/dyld --search syscall |
| 427 | + ''' |
| 428 | + ) |
| 429 | + |
| 430 | + parser.add_argument('binary', help='Path to the binary to symbolicate') |
| 431 | + parser.add_argument('addresses', nargs='*', help='Addresses to symbolicate') |
| 432 | + parser.add_argument('--rip', type=str, help='RIP register value (crashed instruction pointer)') |
| 433 | + parser.add_argument('--rax', type=str, help='RAX register value (for context)') |
| 434 | + parser.add_argument('--stack-trace', type=str, help='Stack trace addresses (comma-separated)') |
| 435 | + parser.add_argument('--slide', type=str, help='ASLR slide to subtract from code addresses (e.g. 0x11526d000)') |
| 436 | + parser.add_argument('--search', type=str, help='Search for symbol by name') |
| 437 | + parser.add_argument('--context', type=int, default=5, help='Symbols to show around address (default: 5)') |
| 438 | + parser.add_argument('--json', action='store_true', help='Output as JSON') |
| 439 | + parser.add_argument('-v', '--verbose', action='store_true', help='Verbose output') |
| 440 | + |
| 441 | + args = parser.parse_args() |
| 442 | + |
| 443 | + try: |
| 444 | + slide = parse_hex_address(args.slide) if args.slide else 0 |
| 445 | + |
| 446 | + # Initialize symbolizer |
| 447 | + symbolizer = Symbolizer(args.binary, verbose=args.verbose) |
| 448 | + |
| 449 | + # Handle search mode |
| 450 | + if args.search: |
| 451 | + print(f"\nSearching for symbols matching: {args.search}") |
| 452 | + results = symbolizer.find_symbol_by_name(args.search) |
| 453 | + if results: |
| 454 | + for symbol in results: |
| 455 | + print(f" 0x{symbol.address:x} {symbol.name} ({symbol.section}) size=0x{symbol.size:x}") |
| 456 | + else: |
| 457 | + print(" No symbols found") |
| 458 | + return 0 |
| 459 | + |
| 460 | + # Collect addresses to symbolicate |
| 461 | + addresses_to_symbolicate = [] |
| 462 | + |
| 463 | + # Add RIP if provided |
| 464 | + if args.rip: |
| 465 | + try: |
| 466 | + raw_rip = parse_hex_address(args.rip) |
| 467 | + normalized_rip = normalize_code_address(raw_rip, slide) |
| 468 | + addresses_to_symbolicate.append(normalized_rip) |
| 469 | + if slide: |
| 470 | + print(f"RIP: {args.rip} -> {format_hex_address(normalized_rip)} (slide={format_hex_address(slide)})") |
| 471 | + else: |
| 472 | + print(f"RIP: {args.rip}") |
| 473 | + except ValueError: |
| 474 | + print(f"Error: Invalid RIP address: {args.rip}", file=sys.stderr) |
| 475 | + return 1 |
| 476 | + |
| 477 | + # Add RAX if provided (for reference) |
| 478 | + if args.rax: |
| 479 | + try: |
| 480 | + rax_addr = parse_hex_address(args.rax) |
| 481 | + print(f"RAX: {args.rax} (invalid pointer marker)") |
| 482 | + except ValueError: |
| 483 | + print(f"Error: Invalid RAX address: {args.rax}", file=sys.stderr) |
| 484 | + |
| 485 | + # Add stack trace addresses |
| 486 | + if args.stack_trace: |
| 487 | + try: |
| 488 | + for addr_str in args.stack_trace.split(','): |
| 489 | + raw_addr = parse_hex_address(addr_str.strip()) |
| 490 | + addresses_to_symbolicate.append(normalize_code_address(raw_addr, slide)) |
| 491 | + except ValueError as e: |
| 492 | + print(f"Error: Invalid stack trace address: {e}", file=sys.stderr) |
| 493 | + return 1 |
| 494 | + |
| 495 | + # Add positional arguments |
| 496 | + for addr_str in args.addresses: |
| 497 | + try: |
| 498 | + raw_addr = parse_hex_address(addr_str) |
| 499 | + addresses_to_symbolicate.append(normalize_code_address(raw_addr, slide)) |
| 500 | + except ValueError: |
| 501 | + print(f"Error: Invalid address: {addr_str}", file=sys.stderr) |
| 502 | + return 1 |
| 503 | + |
| 504 | + if not addresses_to_symbolicate: |
| 505 | + parser.print_help() |
| 506 | + return 1 |
| 507 | + |
| 508 | + # Symbolicate |
| 509 | + results = symbolizer.symbolicate_multiple(addresses_to_symbolicate) |
| 510 | + |
| 511 | + if args.json: |
| 512 | + # JSON output |
| 513 | + json_results = [] |
| 514 | + for result in results: |
| 515 | + json_obj = { |
| 516 | + 'address': format_hex_address(result.address), |
| 517 | + 'symbol': result.symbol.name if result.symbol else None, |
| 518 | + 'section': result.symbol.section if result.symbol else None, |
| 519 | + 'offset': f"0x{result.offset():x}" if result.symbol else None, |
| 520 | + 'context': result.context |
| 521 | + } |
| 522 | + json_results.append(json_obj) |
| 523 | + print(json.dumps(json_results, indent=2)) |
| 524 | + else: |
| 525 | + # Human-readable output |
| 526 | + print("\n=== Symbolication Results ===\n") |
| 527 | + |
| 528 | + for i, result in enumerate(results): |
| 529 | + print(f"{i+1}. {result}") |
| 530 | + |
| 531 | + # Show context |
| 532 | + if result.symbol: |
| 533 | + print(f" Size: 0x{result.symbol.size:x} bytes") |
| 534 | + print(f" Offset: 0x{result.offset():x}") |
| 535 | + if result.context: |
| 536 | + print(f" Context: {result.context}") |
| 537 | + |
| 538 | + # Show nearby symbols |
| 539 | + if args.context > 0: |
| 540 | + context_symbols = symbolizer.get_context_around_address( |
| 541 | + result.address, |
| 542 | + before=args.context, |
| 543 | + after=args.context |
| 544 | + ) |
| 545 | + print(f" Nearby symbols:") |
| 546 | + for nearby in context_symbols: |
| 547 | + marker = " <--" if nearby == result.symbol else "" |
| 548 | + print(f" 0x{nearby.address:x} {nearby.name}{marker}") |
| 549 | + |
| 550 | + print() |
| 551 | + |
| 552 | + return 0 |
| 553 | + |
| 554 | + except FileNotFoundError as e: |
| 555 | + print(f"Error: {e}", file=sys.stderr) |
| 556 | + return 1 |
| 557 | + except RuntimeError as e: |
| 558 | + print(f"Error: {e}", file=sys.stderr) |
| 559 | + return 1 |
| 560 | + except Exception as e: |
| 561 | + print(f"Unexpected error: {e}", file=sys.stderr) |
| 562 | + if args.verbose: |
| 563 | + import traceback |
| 564 | + traceback.print_exc() |
| 565 | + return 1 |
| 566 | + |
| 567 | + |
| 568 | +if __name__ == '__main__': |
| 569 | + sys.exit(main()) |
| 570 | + |
| 571 | + |
| 572 | + |
| 573 | + |
| 574 | + |
| 575 | + |
| 576 | + |
| 577 | + |
0 commit comments