Skip to content

Commit

Permalink
selftest: Print stderr output upon llvm-mc failure
Browse files Browse the repository at this point in the history
Without stderr from `llvm-mc`, it's difficult to debug the issue.
This commit modifies the call to `llvm-mc` so that the error output
is printed is an exception is thrown while running `llvm-mc`.
  • Loading branch information
hanno-becker committed Dec 11, 2024
1 parent e6ec7ec commit 38079f5
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions slothy/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1212,10 +1212,7 @@ def assemble(source, arch, attr, log, symbol=None, preprocessor=None, include_pa
log.debug(f"Calling LLVM MC assmelber on the following code")
log.debug(code)

### FOR DEBUGGING ONLY
###
### Remove once things work ...
args = [f"--arch={arch}", "--assemble", "--show-encoding"]
args = [f"--arch={arch}", "--assemble", "--filetype=obj"]
if attr is not None:
args.append(f"--mattr={attr}")
try:
Expand All @@ -1224,15 +1221,8 @@ def assemble(source, arch, attr, log, symbol=None, preprocessor=None, include_pa
except subprocess.CalledProcessError as exc:
log.error("llvm-mc failed to handle the following code")
log.error(code)
raise LLVM_Mc_Error from exc

args = [f"--arch={arch}", "--assemble", "--filetype=obj"]
if attr is not None:
args.append(f"--mattr={attr}")
try:
r = subprocess.run(["llvm-mc"] + args,
input=code.encode(), capture_output=True, check=True)
except subprocess.CalledProcessError as exc:
log.error("Output from llvm-mc")
log.error(exc.stderr.decode())
raise LLVM_Mc_Error from exc

# TODO: If there are relocations remaining, we should fail at this point
Expand Down

0 comments on commit 38079f5

Please sign in to comment.