Open KittyMac opened 4 years ago
ok, got this working.
What I did was added another command ("exec") and all it does is execve() without forking, thus leaving all of the stdin/stdout/stderr in place for lldb to run. Not sure what kind of processing corral needs to after running the command (nothing I assume?).
Snippet from the apply() in CmdRun:
// if we use the exec option, replace this process with the run command
// allows for use of things like corral run -- lldb ponyc
if exec then
let cargs = Array[Pointer[U8] tag](32)
for a in args.values() do
cargs.push(a.cstring())
end
cargs.push(Pointer[U8])
let cvars = Array[Pointer[U8] tag](32)
for a in vars.values() do
cvars.push(a.cstring())
end
cvars.push(Pointer[U8])
@execve[I32](prog.path.path.cstring(), cargs.cpointer(), cvars.cpointer())
end
let a = Action(prog, recover args.slice(1) end, vars)
if not ctx.nothing then
Runner.run(a, {(result: ActionResult) =>
result.print_to(ctx.env.out)
if result.exit_code != 0 then
ctx.env.exitcode(result.exit_code)
end
})
end
@cquinn do you have any feedback?
one more noodle I missed.
corral exec -- lldb ponyc -- -p $(libdir)/osx/ --pic -b StarbaseOrionCore -o $(builddir)
By the time it gets to that @execve() mentioned above, the second "--" needed by lldb has been dropped from the args list. Looking as to why...
for the second (and any more) "--" being ignored corral is not at fault. The answer lies in command_parser.pony, _parse_command()
let token = try tokens.shift()? else "" end
if token == "--" then
opt_stop = true
The above code eats all "--" option stops in the command line. I am unsure of the standard behind "--", but it seems logical to me that it should only swallow the first option stop and then leave the rest of the arguments unaltered.
let token = try tokens.shift()? else "" end
if (token == "--") and (opt_stop == false) then
opt_stop = true
The above patch works for the issue described here.
This sounds good to me.
@cquinn i did not make a PR. Would you like me to (both for the corral change and the ponyc/command_parser change)?
@KittyMac can you open a PR for these changes? it would be greatly appreciated.
With stable it was possible for me to debug ponyc while invoking it from the stable env.
With corral this doesn't seem to be possible:
I don't know if there is a work-around I am missing? If not, I will probably dig into fixing this tomorrow as this is a showstopper for me.