diff --git a/artiq/compiler/embedding.py b/artiq/compiler/embedding.py index 141d9eca1..199c98f0b 100644 --- a/artiq/compiler/embedding.py +++ b/artiq/compiler/embedding.py @@ -33,6 +33,10 @@ class ObjectMap: def retrieve(self, obj_key): return self.forward_map[obj_key] + def has_rpc(self): + return any(filter(lambda x: inspect.isfunction(x) or inspect.ismethod(x), + self.forward_map.values())) + class ASTSynthesizer: def __init__(self, type_map, value_map, quote_function=None, expanded_from=None): self.source = "" diff --git a/artiq/compiler/targets.py b/artiq/compiler/targets.py index 1ed440236..3d9db3a05 100644 --- a/artiq/compiler/targets.py +++ b/artiq/compiler/targets.py @@ -145,6 +145,8 @@ class Target: backtrace = [] for function_name, location, address in zip(lines[::2], lines[1::2], addresses): filename, line = location.rsplit(":", 1) + if filename == '??': + continue # can't get column out of addr2line D: backtrace.append((filename, int(line), -1, function_name, address)) return backtrace diff --git a/artiq/frontend/artiq_compile.py b/artiq/frontend/artiq_compile.py index c47360c51..9262edcb3 100755 --- a/artiq/frontend/artiq_compile.py +++ b/artiq/frontend/artiq_compile.py @@ -45,29 +45,27 @@ def main(): arguments = parse_arguments(args.arguments) exp_inst = exp(dmgr, pdb, **arguments) - if (not hasattr(exp.run, "k_function_info") - or not exp.run.k_function_info): + if not hasattr(exp.run, "artiq_embedded"): raise ValueError("Experiment entry point must be a kernel") - core_name = exp.run.k_function_info.core_name + core_name = exp.run.artiq_embedded.core_name core = getattr(exp_inst, core_name) - binary, rpc_map, _ = core.compile(exp.run.k_function_info.k_function, - [exp_inst], {}, - with_attr_writeback=False) + object_map, kernel_library, symbolizer = \ + core.compile(exp.run, [exp_inst], {}, + with_attr_writeback=False) finally: dmgr.close_devices() - if rpc_map: + if object_map.has_rpc(): raise ValueError("Experiment must not use RPC") output = args.output if output is None: - output = args.file - if output.endswith(".py"): - output = output[:-3] - output += ".elf" + basename, ext = os.path.splitext(args.file) + output = "{}.elf".format(basename) + with open(output, "wb") as f: - f.write(binary) + f.write(kernel_library) if __name__ == "__main__": main() diff --git a/artiq/frontend/artiq_coretool.py b/artiq/frontend/artiq_coretool.py index 10bed76a9..92af19734 100755 --- a/artiq/frontend/artiq_coretool.py +++ b/artiq/frontend/artiq_coretool.py @@ -13,7 +13,7 @@ def to_bytes(string): def get_argparser(): parser = argparse.ArgumentParser(description="ARTIQ core device " "remote access tool") - parser.add_argument("--ddb", default="ddb.pyon", + parser.add_argument("-d", "--ddb", default="ddb.pyon", help="device database file") subparsers = parser.add_subparsers(dest="action") diff --git a/artiq/frontend/artiq_run.py b/artiq/frontend/artiq_run.py index 06595746c..069a3358c 100755 --- a/artiq/frontend/artiq_run.py +++ b/artiq/frontend/artiq_run.py @@ -13,7 +13,8 @@ from artiq.language.environment import EnvExperiment from artiq.protocols.file_db import FlatFileDB from artiq.master.worker_db import DeviceManager, ResultDB from artiq.tools import * - +from artiq.compiler.embedding import ObjectMap +from artiq.compiler.targets import OR1KTarget logger = logging.getLogger(__name__) @@ -25,9 +26,13 @@ class ELFRunner(EnvExperiment): def run(self): with open(self.file, "rb") as f: - self.core.comm.load(f.read()) - self.core.comm.run("run") - self.core.comm.serve(dict(), dict()) + kernel_library = f.read() + + target = OR1KTarget() + self.core.comm.load(kernel_library) + self.core.comm.run() + self.core.comm.serve(ObjectMap(), + lambda addresses: target.symbolize(kernel_library, addresses)) class SimpleParamLogger: diff --git a/artiq/language/core.py b/artiq/language/core.py index e83c30de4..1a931d2d9 100644 --- a/artiq/language/core.py +++ b/artiq/language/core.py @@ -182,7 +182,7 @@ def kernel(arg): def inner_decorator(function): @wraps(function) def run_on_core(self, *k_args, **k_kwargs): - return getattr(self, arg).run(function, ((self,) + k_args), k_kwargs) + return getattr(self, arg).run(run_on_core, ((self,) + k_args), k_kwargs) run_on_core.artiq_embedded = _ARTIQEmbeddedInfo( core_name=arg, function=function, syscall=None) return run_on_core