2

I have a Makefile-powered project in Visual Studio 2010 (uses NAnt, in fact, but that's beside the point).

The output of the build process is a .elf file, and I have a separate, non-VStudio debugger which can be run on that .elf file to debug it.

Building works fine, but when I click the 'debug' button (little green triangle), VStudio fails with "Unable to start program 'XXX.elf'. The specified file is an unrecognized or unsupported binary format"

I'm guessing VStudio is just trying to 'run' the .elf as though it were an .exe, and failing.

What I really want VStudio to do is run "my_debugger.exe XXX.elf" when I press the debug button.

I have tried adding a file association with .elf=>my_debugger.exe I have updated PATHEXT appropriately as well, and run VStudio under those changes. Still no luck.

Isn't there somewhere in VStudio where you can specify a custom debug command? I thought there was, but can't find it.

I could just have the build process output a .bat file or something I guess, but this seems silly.

jwd
  • 10,837
  • 3
  • 43
  • 67

2 Answers2

1

As Jim mentioned you can specify which app to start on run in the project settings (Command field). If you place a debugger there you can pass down your executable as an argument to the debugger being launched (Command Arguments field). This way you can launch the debugger which in turn will launch your executable if the debugger expects any commandline arguments.

MinGW on Windows example:

  1. Command: gdb.exe; Command Arguments: Path\ToMyApp\whatever.exe

    will start gdb.exe, gdb.exe will open whatever.exe, parse the debug info and wait for debug instructions.

  2. Command: msys.exe; Command Arguments: gdb.exe Path\ToMyApp\whatever.exe

    will start msys.exe, msys.exe will execute "gdb.exe Path\ToMyApp\whatever.exe"

Community
  • 1
  • 1
  • Yes, but this leaves Visual studio in the state thinking it is debugging `gdb.exe` or similar. As before, it is a kinda-workaround, but awkward. Thanks for the more detailed explanation, though. – jwd Nov 19 '12 at 21:48
0

Look at the project properties. Do you have a Debug tab which has a Start Action section giving three choices? Those choices would be: ( ) Start project, (x) Start external program: ... ( ) Start browser with URL.

You can also set the command line arguments and working directory.

Cf. How to: Change the Start Action for Application Debugging

Jim Flood
  • 8,144
  • 3
  • 36
  • 48
  • This allows you to set what command should be run to launch your app, which will subsequently be debugged. I want to specify what *debugger* to run. Doing it your way does kinda suffice for my purposes though - it lets me run an arbitrary command; VStudio just thinks that it wants to debug the debugger ): – jwd Jan 12 '11 at 19:23
  • Oh, I see what you mean now. I don't have the answer. I found this question which is not what you are asking, but it leads to a bunch of other stack overflow questions and answers, and somewhere in there may be some clues: http://stackoverflow.com/questions/197171/how-to-set-visual-studio-as-the-default-post-mortem-debugger – Jim Flood Jan 12 '11 at 20:51