Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Debugging delay
QtWS25 Last Chance

Debugging delay

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 1.4k Views
  • 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.
  • G Offline
    G Offline
    gaminn
    wrote on last edited by
    #1

    Hello,
    I have a simple application.

    @int main(int argc, char *argv[])
    {
    Sleep(10); // <windows.h> sleep
    return 0;
    }@

    I add breakpoints. They are hit/not hit depending on its position and sleep delay:

    1. On line 2 - never stops
    2. On line 4 - stops when sleep is at least 50 ms. When Sleep(10), doesn't stop.

    That means, I'm not able to debug my applications for first 50 ms. Why and how to fix it better than adding delay at the beggining of my application?

    Qt Creator 2.4.1
    Qt 4.8.0
    MinGW 4.4

    1 Reply Last reply
    0
    • JeroentjehomeJ Offline
      JeroentjehomeJ Offline
      Jeroentjehome
      wrote on last edited by
      #2

      Hi,
      Your application seems a bit strange to begin with. The optimizer will probably remove all your code because nothing is done! Then the debugger doesn't hold a PC pointer value to stop at, so it will not stop at all.
      First try to add some lines of code and place breakpoint on them. When they don't get hit, then you have a problem.

      Greetz, Jeroen

      1 Reply Last reply
      0
      • M Offline
        M Offline
        MuldeR
        wrote on last edited by
        #3

        I think the optimizer can not optimize the Sleep() away, because it cannot know which side-effects that call has! It might be able to optimize away an inline function that really has no side-effects. But Sleep() is a system call (Win32 API) where the source code (implementation details) are not publicly available and may even change with future Windows versions. Especially the compiler would not do this kind of optimizations in a DEBUG build, where optimizations are disabled (or at least reduced to a minimum).

        It's pretty strange that the debugger will only catch the break point when the Sleep() is long enough! My theory: The IDE first starts the process, then attaches the debugger. When breakpoint is reached (triggered) before a debugger is attached to the process, nothing will happen!

        Definitely can not reproduce such behavior with MSVC, breaks as expected:
        http://i.imgur.com/K51rDDL.png

        What IDE do you use?

        My OpenSource software at: http://muldersoft.com/

        Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

        Go visit the coop: http://youtu.be/Jay...

        1 Reply Last reply
        0
        • G Offline
          G Offline
          gaminn
          wrote on last edited by
          #4

          I use Qt Creator 2.4.1, Qt 4.8.0, MinGW 4.4, Windows 7 32 bit.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved