crosire / blink

A tool which allows you to edit source code of any MSVC C++ project live at runtime
BSD 2-Clause "Simplified" License
1.09k stars 81 forks source link

Troubleshooting target program crash #16

Open martty opened 5 years ago

martty commented 5 years ago

Hey, thanks for this great library! I am having trouble making it work though. Here is what I tried:

using std::cout; using std::endl; void fn() { cout << "Hello World" << endl; }


 - compile test.cpp in a VS console with `cl.exe /Z7 /Od /MDd /nologo /EHsc /std:c++latest test.cpp`
 - cd back to blink root
 - launch blink with test.exe (`bin\x64\Debug\blink.exe target\test.exe`) in VS console
output: 
Launching in target application ...
  Entry point was written to address 000000013F1A0000
Reading PE import directory ...
Reading PE debug info directory ...
  Found program debug database: C:\dev\blink\target\test.pdb
  Found source file: c:\dev\blink\target\test.cpp
Starting compiler process ...
  Started process with PID 31796
Starting file system watcher for 'c:\dev\blink\target' ...
  - change output string in test.cpp to something else & save
output:
Detected modification to: c:\dev\blink\target\test.cpp
Finished compiling "c:\dev\blink\target\test.obj" with code 0.
Successfully linked object file into executable image.
Detected modification to: c:\dev\blink\target\test.cpp
The target application has exited with code 3221225501.
  - the test.exe program crashes

  - the additional change in blink was that I disabled commandline detection from the .obj file, as that didn't work, so the commandline used to build is the built-in (as described in #13)
crosire commented 5 years ago

Use /ZI instead of /Z7 for command-line detection. I'll look into the crash, seems to be some CRT state getting corrupted.

Trass3r commented 5 years ago

Is /ZI required or could the implied /FC be enough?

crosire commented 5 years ago

/FC has no impact on the debug data stored in the object files (it only affects display in the command-line output), and that's what blink needs to determine the compiler command-line. So for that to work /ZI is required.