Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to start debugging from application? [modified]

How to start debugging from application? [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
debuggingquestionc++visual-studiotools
7 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rrrado
    wrote on last edited by
    #1

    My application (32 bit) starts next process instance of itself. In new process I need to start debugging so I'm using __asm int 3; It worked good in WinXP/VS2008, it stopped the app and gave me selection whether start new VS instance or use existing VS instance to debug. I've switched to Win 7 64 bit and it does not work anymore. It offers nothing, app just hangs for some time, then exits, I cannot even attach debugger to the process manually. How can I solve this? Thank you. In VS options, the "Jst-in-time" I have all options active (managed,native,script)

    modified on Friday, January 21, 2011 5:46 AM

    A 1 Reply Last reply
    0
    • R rrrado

      My application (32 bit) starts next process instance of itself. In new process I need to start debugging so I'm using __asm int 3; It worked good in WinXP/VS2008, it stopped the app and gave me selection whether start new VS instance or use existing VS instance to debug. I've switched to Win 7 64 bit and it does not work anymore. It offers nothing, app just hangs for some time, then exits, I cannot even attach debugger to the process manually. How can I solve this? Thank you. In VS options, the "Jst-in-time" I have all options active (managed,native,script)

      modified on Friday, January 21, 2011 5:46 AM

      A Offline
      A Offline
      Andrew Brock
      wrote on last edited by
      #2

      try

      #include "CrtDbg.h"
      //code ...
      _CrtDbgBreak();

      R 1 Reply Last reply
      0
      • A Andrew Brock

        try

        #include "CrtDbg.h"
        //code ...
        _CrtDbgBreak();

        R Offline
        R Offline
        rrrado
        wrote on last edited by
        #3

        the same result :(

        A 1 Reply Last reply
        0
        • R rrrado

          the same result :(

          A Offline
          A Offline
          Andrew Brock
          wrote on last edited by
          #4

          _CrtDbgBreak() is a valid function under Win64. Perhaps it expects a debugger to be attached. Perhaps you could use something like:

          while (!IsDebuggerPresent()) {
          Sleep(1000);
          }

          It is quite a hack up, but if it is just for testing it doesn't really matter.

          R 1 Reply Last reply
          0
          • A Andrew Brock

            _CrtDbgBreak() is a valid function under Win64. Perhaps it expects a debugger to be attached. Perhaps you could use something like:

            while (!IsDebuggerPresent()) {
            Sleep(1000);
            }

            It is quite a hack up, but if it is just for testing it doesn't really matter.

            R Offline
            R Offline
            rrrado
            wrote on last edited by
            #5

            Thank you for tip.

            while (!IsDebuggerPresent()) {
            Sleep(1000);
            }
            __asm int 3;

            works, but now I have to attach debugger to correct process manually :( It would me more convenient if it would work like before so other ideas are still welcome :)

            A 1 Reply Last reply
            0
            • R rrrado

              Thank you for tip.

              while (!IsDebuggerPresent()) {
              Sleep(1000);
              }
              __asm int 3;

              works, but now I have to attach debugger to correct process manually :( It would me more convenient if it would work like before so other ideas are still welcome :)

              A Offline
              A Offline
              Andrew Brock
              wrote on last edited by
              #6

              Perhaps it is something wrong with your JIT settings. I just ran

              #include <Windows.h>
              #include <CrtDbg.h>

              int main() {
              OutputDebugString(TEXT("Hello\n"));
              _CrtDbgBreak();
              OutputDebugString(TEXT("World\n"));
              return 0;
              }

              Compiled in debug mode on VS 2008. It came up with the crashed message, 1 of the options was to debug the program. This gave me an idea, if _CrtDbgBreak() doesn't work for you, just crash you program and attach the JIT then. Once attached you can just drag the instruction pointer (the yellow arrow to the left of the code) to the next line and hit continue. Something simple to crash your program would be

              char *p = NULL;
              *p = 0; //Write 0 to an invalid address

              R 1 Reply Last reply
              0
              • A Andrew Brock

                Perhaps it is something wrong with your JIT settings. I just ran

                #include <Windows.h>
                #include <CrtDbg.h>

                int main() {
                OutputDebugString(TEXT("Hello\n"));
                _CrtDbgBreak();
                OutputDebugString(TEXT("World\n"));
                return 0;
                }

                Compiled in debug mode on VS 2008. It came up with the crashed message, 1 of the options was to debug the program. This gave me an idea, if _CrtDbgBreak() doesn't work for you, just crash you program and attach the JIT then. Once attached you can just drag the instruction pointer (the yellow arrow to the left of the code) to the next line and hit continue. Something simple to crash your program would be

                char *p = NULL;
                *p = 0; //Write 0 to an invalid address

                R Offline
                R Offline
                rrrado
                wrote on last edited by
                #7

                Andrew Brock wrote:

                char *p = NULL; *p = 0; //Write 0 to an invalid address

                also this does not work. It does nothing, but after some time standard windows crashed program dialog opens and offers me to send crash data to microsoft.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups