'gdb 내부 명령어'에 해당되는 글 1건

  1. 2009.06.26 gdb help
gdb 내부 명령어 모음집

가장 눈여겨 볼 만한 부분은
help breakpoints
help running
help stack
으로

gdb에서 한줄 실행, 함수 들어가기, 나가기 등은 running에
함수 불려진 순서등의추적은 stack에
브레이크 포인트 생성/삭제는 breakpoints의 항목에 들어 있다.

일단 Visual Studio에서 많이 쓰는것들로

브레이크 포인트 설정은 break 와 delete breakpoints 이다. (F8)
(gdb) help break
Set breakpoint at specified line or function.
break [LOCATION] [thread THREADNUM] [if CONDITION]
LOCATION may be a line number, function name, or "*" and an address.
If a line number is specified, break at start of code for that line.
If a function is specified, break at start of code for that function.
If an address is specified, break at that exact address.
With no LOCATION, uses current execution address of selected stack frame.
This is useful for breaking on return to a stack frame.

THREADNUM is the number from "info threads".
CONDITION is a boolean expression.

Multiple breakpoints at one place are permitted, and useful if conditional.

Do "help breakpoints" for info on other commands dealing with breakpoints.
--------------------------------------------------------------------------------
(gdb) help delete breakpoints
Delete some breakpoints or auto-display expressions.
Arguments are breakpoint numbers with spaces in between.
To delete all breakpoints, give no argument.
This command may be abbreviated "delete".

그리고 한줄 실행은 next(행단위 실행 F10) / step(함수단위 실행 F11) 으로
원하는 곳까지 실행은 breakpoint를 잡은후 continue를 하면 된다.

(gdb) help next
Step program, proceeding through subroutine calls.
Like the "step" command as long as subroutine calls do not happen;
when they do, the call is treated as one instruction.
Argument N means do this N times (or till program stops for another reason).

(gdb) help step
Step program until it reaches a different source line.
Argument N means do this N times (or till program stops for another reason).

(gdb) help jump
Continue program being debugged at specified line or address.
Give as argument either LINENUM or *ADDR, where ADDR is an expression for an address to start at.

gdb의 차이점은, 현재 실행중인 라인을 보기가 조금은 힘들다는 것인데,
소스를 보기 위해서는 list를 입력하면 된다.
(gdb) help list
List specified function or line.
With no argument, lists ten more lines after or around previous listing.
"list -" lists the ten lines before a previous ten-line listing.
One argument specifies a line, and ten lines are listed around that line.
Two arguments with comma between specify starting and ending lines to list.
Lines can be specified in these ways:
  LINENUM, to list around that line in current file,
  FILE:LINENUM, to list around that line in that file,
  FUNCTION, to list around beginning of that function,
  FILE:FUNCTION, to distinguish among like-named static functions.
  *ADDRESS, to list around the line containing that address.
With two args if one is empty it stands for ten lines away from the other arg.




Posted by 구차니