Author Topic: Dirty CDB workaround to run in the right directory - alternatives?  (Read 4525 times)

Offline etheranger

  • Single posting newcomer
  • *
  • Posts: 4
Hi all, looking for some input on a C::B bugfix:

I was getting errors debugging one of my projects with CDB due to the project not running in the right working directory.

I had a look in the debugger plugin and thought I could fix it by just launching CDB itself in the working dir and letting the child process inherit that, but that in turn breaks relative paths in source / symbol dirs. Clearly the right thing to be doing is getting CDB to launch its child in the right working dir.
Unfortunately, I can't see any command line options to specify one, or alternatively to start the debugger without an initial process so that I can avoid the .kill in my workaround.

So my suggestion is:
  • Create the process normally in the default directory.
  • If there's an alternate working directory set, kill the process before it actually begins with .kill
  • Set the new dir with .createdir foo
  • Recreate the process in foo with .create bar

I've implemented the above (in the parts wrapped in #ifdef ENABLE_WORKINGDIR_WORKAROUND) in
trunk patch 3118 https://developer.berlios.de/patch/index.php?func=detailpatch&patch_id=3118&group_id=5358 and
debugger branch patch 3122 https://developer.berlios.de/patch/index.php?func=detailpatch&patch_id=3122&group_id=5358.

It's not exactly elegant, but the only other options I see are:
  • I've missed a command line option to do what I described above - It seems odd to be able to CD for the second process, but not the first one.
  • Launch CDB in the right working dir and convert all relative paths to absolute before passing them in. - I'm not familiar enough with the codebase to know if this is feasible, and I'm worried about the potential size of the command line.

Thoughts?