01.09.2014 Views

The Linux Development Platform Configuring, Using, and ... - Classes

The Linux Development Platform Configuring, Using, and ... - Classes

The Linux Development Platform Configuring, Using, and ... - Classes

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CH05.fm Page 151 Monday, October 7, 2002 9:00 PM<br />

Displaying Variables 151<br />

• <strong>The</strong> info frame comm<strong>and</strong> shows more information about the current frame,<br />

including some register values. It also shows the stack pointer for the previous frame.<br />

<strong>The</strong>se values are taken from the stack.<br />

• <strong>The</strong> info args comm<strong>and</strong> displays arguments passed to this frame. This is also taken<br />

from the stack.<br />

• <strong>The</strong> info locals comm<strong>and</strong> displays the values of local variables. <strong>The</strong>se variable<br />

have a scope limited to the current frame.<br />

• <strong>The</strong> info reg comm<strong>and</strong> displays values of register values.<br />

• <strong>The</strong> info all-reg comm<strong>and</strong> displays register values, including math registers.<br />

• <strong>The</strong> up comm<strong>and</strong> takes you one level up in the stack. This means if you are inside a<br />

function call, the up comm<strong>and</strong> will take you to the function that called the current<br />

function. <strong>The</strong> down comm<strong>and</strong> is opposite to the up comm<strong>and</strong>.<br />

• You can use backtrace, up <strong>and</strong> down comm<strong>and</strong>s to move around in different<br />

frames. <strong>The</strong>se comm<strong>and</strong>s are useful for looking into stack data.<br />

A combination of all of these comm<strong>and</strong>s used with other execution control comm<strong>and</strong> can<br />

be used to display a lot of information. If you want to effectively use GNU debugger, knowledge<br />

of comm<strong>and</strong>s related to stack is a must.<br />

5.5 Displaying Variables<br />

<strong>Using</strong> the GNU debugger, you can display environment variables as well as your program variables<br />

during the program execution. You can control display of some variables so that the value<br />

of these variables is displayed with each comm<strong>and</strong>. <strong>Using</strong> this feature you can easily track<br />

changes taking place to these variables when you step through the program. You can also modify<br />

the program as well as environment variables. This section shows examples of how to carry out<br />

these tasks.<br />

5.5.1 Displaying Program Variables<br />

<strong>The</strong> following session uses the sum.c program that you already used earlier in this chapter.<br />

Go through the following gdb session <strong>and</strong> then see the discussion at the end of this session<br />

about actions taking place.<br />

[rr@conformix 5]$ gdb sum<br />

GNU gdb 5.0rh-5 Red Hat <strong>Linux</strong> 7.1<br />

Copyright 2001 Free Software Foundation, Inc.<br />

GDB is free software, covered by the GNU General Public<br />

License, <strong>and</strong> you are<br />

welcome to change it <strong>and</strong>/or distribute copies of it under<br />

certain conditions.<br />

Type "show copying" to see the conditions.<br />

<strong>The</strong>re is absolutely no warranty for GDB. Type "show warranty"<br />

for details.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!