<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule"
>

<channel>
	<title>EMSTONE Bebop &#187; Gdb</title>
	<atom:link href="http://bebop.emstone.com/tags/gdb/feed/" rel="self" type="application/rss+xml" />
	<link>http://bebop.emstone.com</link>
	<description>엠스톤 개발팀 블로그</description>
	<lastBuildDate>Sun, 29 Jan 2012 05:25:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<creativeCommons:license>http://creativecommons.org/licenses/by-nc-nd/2.0/kr/</creativeCommons:license>
		<item>
		<title>GDB Debugger 사용 팁</title>
		<link>http://bebop.emstone.com/2008/12/23/gdb-debugger-%ec%82%ac%ec%9a%a9-%ed%8c%81/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=gdb-debugger-%25ec%2582%25ac%25ec%259a%25a9-%25ed%258c%2581</link>
		<comments>http://bebop.emstone.com/2008/12/23/gdb-debugger-%ec%82%ac%ec%9a%a9-%ed%8c%81/#comments</comments>
		<pubDate>Tue, 23 Dec 2008 05:24:32 +0000</pubDate>
		<dc:creator>lethean</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Gdb]]></category>

		<guid isPermaLink="false">http://bebop.emstone.com/?p=236</guid>
		<description><![CDATA[자주 사용하는 GDB 명령어 run command-line-arguments : 디버깅할 프로그램을 시작합니다. 실행 시 명령어 라인 인자를 전달할 수 있습니다. break place : breakpoint를 설정합니다. delete N : N 에 해당하는 breakpoint를 제거합니다. (N은 info breakpoints 명령을 통해서 확인할 수 있습니다.) help &#8230; <a href="http://bebop.emstone.com/2008/12/23/gdb-debugger-%ec%82%ac%ec%9a%a9-%ed%8c%81/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h3>자주 사용하는 GDB 명령어</h3>
<div style="margin-bottom: 10px; background-color: #ded6c6; text-align: justify; border: #b5a58c 1px dashed; padding: 10px;">
<p style="text-align: justify;"><strong>run</strong> <em>command-line-arguments</em> : 디버깅할 프로그램을 시작합니다. 실행 시 명령어 라인 인자를 전달할 수 있습니다.</p>
<p style="text-align: justify;"><strong>break</strong> <em>place</em> : breakpoint를 설정합니다.</p>
<p style="text-align: justify;"><strong>delete</strong> <em>N</em> : <em>N</em> 에 해당하는 breakpoint를 제거합니다. (<em>N</em>은 info breakpoints 명령을 통해서 확인할 수 있습니다.)</p>
<p style="text-align: justify;"><strong>help</strong> <em>command</em> : GDB 명령어에 대한 설명을 제공합니다.</p>
<p style="text-align: justify;"><strong>step</strong> : 프로그램의 현재 라인을 실행하고 다음 라인에서 정지합니다. 현재 라인이 함수인 경우 함수의 시작위치에서 정지하게 됩니다.</p>
<p style="text-align: justify;"><strong>next</strong> : 프로그램의 현재 라인을 실행합니다. 현재 라인이 함수인 경우 함수를 실행하고 다음 라인에서 정지하게 됩니다.</p>
<p style="text-align: justify;"><strong>finish</strong> : 현재 실행된 함수의 끝에 도달할 때까지 next 명령을 실행합니다.</p>
<p style="text-align: justify;"><strong>continue</strong> : breakpoint를 만나거나, 프로그램이 정지될 때까지 프로그램을 실행합니다.</p>
<p style="text-align: justify;"><strong>print</strong> E : 실행 중인 함수에서 사용하는 변수값을 화면에 표시할 때 사용합니다. E는 C언어에서 사용하는 표현식입니다.</p>
<p style="text-align: justify;"><strong>quit</strong> : GDB를 종료합니다.</p>
</div>
<h3>Breakpoint 사용하기</h3>
<div style="margin-bottom: 10px; background-color: #ded6c6; text-align: justify; border: #b5a58c 1px dashed; padding: 10px;">
<p style="text-align: justify;">breakpoint를 설정하는 명령어는 <strong>break</strong> 입니다. <strong>break</strong> 명령어는 다음과 같이 사용할 수 있습니다.</p>
<p style="text-align: justify;">현재 소스 파일에서 19번째 라인에 breakpoint를 걸고 싶은 경우<br />
(gdb) b 17</p>
<p style="text-align: justify;">현재 소스 파일에서 main 함수에 breakpoint를 걸고 싶은 경우<br />
(gdb) b main</p>
<p style="text-align: justify;">gui.c 파일에서 17번째 라인에 breakpoint를 걸고 싶은 경우<br />
(gdb) b gui.c:17</p>
<p style="text-align: justify;">gui.c 파일에서 gui_init () 함수에 breakpoint를 걸고 싶은 경우<br />
(gdb) b gui.c:gui_init
</p>
<p style="text-align: justify;">breakpoint를 한번만 걸고 제거하고 싶은 경우에는 <strong>tbreak</strong> 명령을 이용합니다.</p>
<p style="text-align: justify;">breakpoint에 대한 정보를 보고 싶은 경우에는<strong> info breakpoints </strong>명령을 이용합니다.<br />
(gdb) info breakpoints<br />
Num     Type           Disp Enb Address    What<br />
1       breakpoint     keep y   0x0805c53a in main_restart_idle at main.c:17<br />
2       breakpoint     keep y   0x0805b199 in main at main.c:1139</p>
<p style="text-align: justify;">breakpoint를 사용하고 싶지 않을 경우에는 <strong>disable</strong> 명령어를 사용합니다.<br />
(gdb) disable 2</p>
<p style="text-align: justify;">breakpoints를 사용하고 싶은 경우에는 <strong>enable</strong> 명령어를 사용합니다.<br />
(gdb) enable 2</p>
<p style="text-align: justify;">breakpoint를 설정한 지점에서 무시하고 특정 횟수만큼 지나가고 싶은 경우에는 <strong>ignore</strong> 명령어를 사용합니다.<br />
(gdb) ignore 1 2
</p>
<p style="text-align: justify;">ignore 명령어의 첫번째 인자는 breakpoint 번호, 두번째 인자는 무시하고 지나갈 횟수를 나타냅니다.</p>
<p style="text-align: justify;">breakpoint를 제거하고 싶은 경우에는 <strong>delete</strong> 명령어를 사용합니다.<br />
(gdb) delete 1</p>
</div>
<h3>Watchpoint 사용하기</h3>
<div style="margin-bottom: 10px; background-color: #ded6c6; text-align: justify; border: #b5a58c 1px dashed; padding: 10px;">
<p style="text-align: justify;">변수에 값이 써지는 것을 확인하고 싶은 경우 <strong>watch</strong> 명령어를 사용합니다.<br />
(gdb) watch x</p>
<p style="text-align: justify;">값이 변경될 경우 다음과 같은 결과를 화면에서 볼 수 있습니다.<br />
Old value = -10291281<br />
New value = 20<br />
main (argc=1, argv=0xbfd8c2e4) at main.c:1176<br />
1176 x = 20</p>
<p style="text-align: justify;">변수에 있는 값이 다른 변수로 읽히는 것을 확인하고 싶은 경우 <strong>rwatch</strong> 명령어를 사용합니다.<br />
(gdb) rwatch
</p>
<p style="text-align: justify;">읽기 / 쓰기를 확인하고 싶은 경우에는 <strong>awatch</strong> 명령어를 이용합니다.</p>
<p style="text-align: justify;">설정한 watchpoint 정보를 보고 싶을 경우 <strong>info breakpoints </strong>명령을 사용합니다.</p>
<p style="text-align: justify;">watchpoint를 사용하고 싶지 않을 경우 breakpoint에서 사용한 <strong>disable</strong> 명령어를 사용합니다.</p>
</div>
<h3>Call Stack 사용하기</h3>
<div style="margin-bottom: 10px; background-color: #ded6c6; text-align: justify; border: #b5a58c 1px dashed; padding: 10px;">
<p style="text-align: justify;">함수가 호출된 순서를 보고 싶은 경우 <strong>backtrace</strong> 명령을 사용합니다.</p>
<p style="text-align: justify;">현재 함수의 프레임에서 다른 함수의 프레임으로 이동하고 싶은 경우 <strong>frame</strong> 명령어를 사용합니다.<br />
(gdb) frame 4
</p>
<p style="text-align: justify;">frame 명령어의 첫번째 인자는 이동하고 싶은 stack frame 번호를 나타냅니다.</p>
<p style="text-align: justify;">현재 frame의 정보를 보고 싶은 경우에는 <strong>info frame</strong> 명령어를 이용합니다.<br />
현재 frame의 지역 변수의 값을 보고 싶은 경우 <strong>info locals</strong>, 함수가 받은 파라미터 정보를 보고 싶은 경우 <strong>info args </strong>명령어를 이용합니다.</p>
</div>
<h3>이미 실행 중인 프로그램 디버깅하기</h3>
<div style="margin-bottom: 10px; background-color: #ded6c6; text-align: justify; border: #b5a58c 1px dashed; padding: 10px;">
<p style="text-align: justify;">실행 중인 프로세스를 디버깅하고 싶은 경우 <strong>attach</strong> 명령어를 이용할 수 있습니다.<br />
(gdb) attach 1182
</p>
<p style="text-align: justify;">attach 명령어의 첫번째 인자는 process-id 입니다.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://bebop.emstone.com/2008/12/23/gdb-debugger-%ec%82%ac%ec%9a%a9-%ed%8c%81/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-nd/2.0/kr/</creativeCommons:license>
	</item>
	</channel>
</rss>

