()
| 123 | |
| 124 | |
| 125 | def cli() -> None: |
| 126 | import argparse |
| 127 | |
| 128 | parser = argparse.ArgumentParser( |
| 129 | description="Dump object file information using build tools" |
| 130 | ) |
| 131 | |
| 132 | parser.add_argument( |
| 133 | "build_path", |
| 134 | type=Path, |
| 135 | nargs="?", |
| 136 | help="Path to build directory containing build info JSON file", |
| 137 | ) |
| 138 | |
| 139 | parser.add_argument( |
| 140 | "--symbols", action="store_true", help="Dump symbol table using nm" |
| 141 | ) |
| 142 | parser.add_argument( |
| 143 | "--disassemble", action="store_true", help="Dump disassembly using objdump" |
| 144 | ) |
| 145 | |
| 146 | args = parser.parse_args() |
| 147 | build_path = args.build_path |
| 148 | symbols = args.symbols |
| 149 | disassemble = args.disassemble |
| 150 | |
| 151 | # Check if object file was provided and exists |
| 152 | if build_path is None: |
| 153 | build_path = _prompt_build() |
| 154 | else: |
| 155 | if not _check_build(build_path): |
| 156 | print("Error: Invalid build directory", file=sys.stderr) |
| 157 | sys.exit(1) |
| 158 | |
| 159 | assert build_path is not None |
| 160 | assert build_path |
| 161 | |
| 162 | build_info_path = build_path / "build_info.json" |
| 163 | assert build_info_path.exists(), f"File not found: {build_info_path}" |
| 164 | |
| 165 | tools = load_tools(build_info_path) |
| 166 | |
| 167 | if not symbols and not disassemble: |
| 168 | while True: |
| 169 | print( |
| 170 | "Error: Please specify at least one action to perform", file=sys.stderr |
| 171 | ) |
| 172 | action = input( |
| 173 | "Enter 's' to dump symbols, 'd' to disassemble, or 'q' to quit: " |
| 174 | ) |
| 175 | if action == "s": |
| 176 | symbols = True |
| 177 | break |
| 178 | elif action == "d": |
| 179 | disassemble = True |
| 180 | break |
| 181 | elif action == "q": |
| 182 | sys.exit(0) |
no test coverage detected