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 trace a program?

How to trace a program?

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestionalgorithmsdebugging
3 Posts 3 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.
  • G Offline
    G Offline
    GwapoKho
    wrote on last edited by
    #1

    Every time I see a program I really want to know how it works. For example

    for(x=0; x<=2; x++)

    tracing...

    x=0 0<=2 TRUE
    x=1 1<=2 TRUE
    x=2 2<=2 TRUE
    x=3 3<=2 FALSE

    There are some programs that I find it difficult to trace and how can I trace it even if it is hard to trace what I mean is how to determine the flow of the program? I just want to understand the algorithm of the program created by me and by others.

    J S 2 Replies Last reply
    0
    • G GwapoKho

      Every time I see a program I really want to know how it works. For example

      for(x=0; x<=2; x++)

      tracing...

      x=0 0<=2 TRUE
      x=1 1<=2 TRUE
      x=2 2<=2 TRUE
      x=3 3<=2 FALSE

      There are some programs that I find it difficult to trace and how can I trace it even if it is hard to trace what I mean is how to determine the flow of the program? I just want to understand the algorithm of the program created by me and by others.

      J Offline
      J Offline
      jeron1
      wrote on last edited by
      #2

      Step through the code using the debugger (VS?), or write to the output window of the debugger (eg. OutputDebugString()), or write to a log file? There are probably other ways as well.

      "the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst

      1 Reply Last reply
      0
      • G GwapoKho

        Every time I see a program I really want to know how it works. For example

        for(x=0; x<=2; x++)

        tracing...

        x=0 0<=2 TRUE
        x=1 1<=2 TRUE
        x=2 2<=2 TRUE
        x=3 3<=2 FALSE

        There are some programs that I find it difficult to trace and how can I trace it even if it is hard to trace what I mean is how to determine the flow of the program? I just want to understand the algorithm of the program created by me and by others.

        S Offline
        S Offline
        Stefan_Lang
        wrote on last edited by
        #3

        Don't trace. It's very hard to estimate the amount of information needed whithout flooding the output with pointless redundand information. Also the printed information is difficult to associate with the actual control flow, if the traced function can be called from different points in your code.

        Judo Sarabia wrote:

        how to determine the flow of the program?

        Use a debugger, step through the code, and analyze the state of your program at your pace. You can check the call stack whenever you like to determine how you arrived at the function, and what happened earlier, or where the function arguments came from.

        GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)

        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