3.6 Using an integrated debugger: Stepping

주홍영·2022년 3월 11일
0

Learncpp.com

목록 보기
43/199

https://www.learncpp.com/cpp-tutorial/using-an-integrated-debugger-stepping/

이번 섹터에서 디버깅에 활용되는 중요한 기능 중 하나인
stepping에 대해서 알아본다
나의 경우 Visual Studio를 IDE로 활용하기 때문에
VS 기준으로 작성한다

Stepping

Stepping is the name for a set of related debugger features that let us execute (step through) our code statement by statement.
말그대로 statement를 하나씩 실행시키는 것이다
세부적인 기능으로 모든 세부적인 step을 따라가는 경우가 있고
큰 분기는 건너뛰는 기능이 있다 이를 step into 와 step over라고 한다

Step into

The step into command executes the next statement in the normal execution path of the program
만약 function call이 나면 callee의 statement를 하나씩 실행한 후
caller로 다시 돌아오는 것처럼 모든 statement를 살펴보는 것으로 생각하면 된다

For Visual Studio users

F11 단축기로 step into를 사용할 수 있다
혹은, Debug menu > Step Into

Step over

The step over command executes the next statement in the normal execution path of the program. However, whereas step into will enter function calls and execute them line by line, step over will execute an entire function without stopping and return control to you after the function has been executed.
즉, function call을 만났을 경우 function을 line by line으로 실행하는 것이 아닌
함수 전체를 멈춤없이 실행시키고 다음 statement 흐름을 본다

For Visual Studio users

VS에서 단축키는 F10
혹은, Debug menu > Step Over

Step out

Step out does not just execute the next line of code. Instead, it executes all remaining code in the function currently being executed, and then returns control to you when the function has returned.
지금 실행되고 있는 function이 return 될 때까지 쭉 실행시킨다
만약 main 함수였으면 프로그램 종료시까지 실행된다

For Visual Studio users

단축키는 shift-F11
혹은 Debug menu > Step Out

Step back

어떠한 debugger들 (such as Visual Studio Enterprise Edition and GDB 7.0)
은 step back도 지원한다
step in, over, out 모두 forward로만 지원하기 때문에 궁금한 라인을 지나친 경우
멈추고 다시 디버깅을 시작해야 한다
하지만 step back을 사용하면 다시 시작할 필요없이 궁금한 라인으로 돌아갈 수 있으므로
편리하다

profile
청룡동거주민

0개의 댓글