Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow use of lldb for corral run target #82

Open
KittyMac opened this issue Feb 12, 2020 · 8 comments
Open

Allow use of lldb for corral run target #82

KittyMac opened this issue Feb 12, 2020 · 8 comments
Labels
enhancement New feature or request triggers release Major issue that when fixed, results in an "emergency" release

Comments

@KittyMac
Copy link
Contributor

With stable it was possible for me to debug ponyc while invoking it from the stable env.

stable env lldb ponyc -- -p ./lib/osx/  --pic 

With corral this doesn't seem to be possible:

beast:pony.bzip2 rjbowli$ corral run -- lldb ponyc
run: lldb ponyc
  exit: 0
  out: (lldb) target create "ponyc"
Current executable set to 'ponyc' (x86_64).

  err: 
beast:pony.bzip2 rjbowli$ 

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.

@KittyMac
Copy link
Contributor Author

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

@SeanTAllen
Copy link
Member

@cquinn do you have any feedback?

@KittyMac
Copy link
Contributor Author

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...

@KittyMac
Copy link
Contributor Author

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.

@cquinn
Copy link
Contributor

cquinn commented Feb 12, 2020

This sounds good to me.

@KittyMac
Copy link
Contributor Author

@cquinn i did not make a PR. Would you like me to (both for the corral change and the ponyc/command_parser change)?

@SeanTAllen
Copy link
Member

@KittyMac can you open a PR for these changes? it would be greatly appreciated.

@SeanTAllen SeanTAllen added enhancement New feature or request triggers release Major issue that when fixed, results in an "emergency" release labels May 3, 2020
@KittyMac
Copy link
Contributor Author

KittyMac commented May 6, 2020

#104

ponylang/ponyc#3541

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request triggers release Major issue that when fixed, results in an "emergency" release
Projects
None yet
Development

No branches or pull requests

3 participants