Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

26.13. gdb/mi Stack Manipulation Commands

26.13.1. The -stack-info-frameCommand

26.13.1.1. Synopsis

 -stack-info-frame

Get info on the current frame.

26.13.1.2. gdb Command

The corresponding gdb command is info frame or frame (without arguments).

26.13.1.3. Example

N.A.

26.13.2. The -stack-info-depthCommand

26.13.2.1. Synopsis

 -stack-info-depth [ max-depth ]

Return the depth of the stack. If the integer argument max-depth is specified, do not count beyond max-depth frames.

26.13.2.2. gdb Command

There's no equivalent gdb command.

26.13.2.3. Example

For a stack with frame levels 0 through 11:

(gdb)
-stack-info-depth
^done,depth="12"
(gdb)
-stack-info-depth 4
^done,depth="4"
(gdb)
-stack-info-depth 12
^done,depth="12"
(gdb)
-stack-info-depth 11
^done,depth="11"
(gdb)
-stack-info-depth 13
^done,depth="12"
(gdb)

26.13.3. The -stack-list-argumentsCommand

26.13.3.1. Synopsis

 -stack-list-arguments show-values
    [ low-frame high-frame ]

Display a list of the arguments for the frames between low-frame and high-frame (inclusive). If low-frame and high-frame are not provided, list the arguments for the whole call stack.

The show-values argument must have a value of 0 or 1. A value of 0 means that only the names of the arguments are listed, a value of 1 means that both names and values of the arguments are printed.

26.13.3.2. gdb Command

gdb does not have an equivalent command. gdbtk has a gdb_get_args command which partially overlaps with the functionality of -stack-list-arguments.

26.13.3.3. Example

(gdb)
-stack-list-frames
^done,
stack=[
frame={level="0",addr="0x00010734",func="callee4",
file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="8"},
frame={level="1",addr="0x0001076c",func="callee3",
file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="17"},
frame={level="2",addr="0x0001078c",func="callee2",
file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="22"},
frame={level="3",addr="0x000107b4",func="callee1",
file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="27"},
frame={level="4",addr="0x000107e0",func="main",
file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="32"}]
(gdb)
-stack-list-arguments 0
^done,
stack-args=[
frame={level="0",args=[]},
frame={level="1",args=[name="strarg"]},
frame={level="2",args=[name="intarg",name="strarg"]},
frame={level="3",args=[name="intarg",name="strarg",name="fltarg"]},
frame={level="4",args=[]}]
(gdb)
-stack-list-arguments 1
^done,
stack-args=[
frame={level="0",args=[]},
frame={level="1",
 args=[{name="strarg",value="0x11940 \"A string argument.\""}]},
frame={level="2",args=[
{name="intarg",value="2"},
{name="strarg",value="0x11940 \"A string argument.\""}]},
{frame={level="3",args=[
{name="intarg",value="2"},
{name="strarg",value="0x11940 \"A string argument.\""},
{name="fltarg",value="3.5"}]},
frame={level="4",args=[]}]
(gdb)
-stack-list-arguments 0 2 2
^done,stack-args=[frame={level="2",args=[name="intarg",name="strarg"]}]
(gdb)
-stack-list-arguments 1 2 2
^done,stack-args=[frame={level="2",
args=[{name="intarg",value="2"},
{name="strarg",value="0x11940 \"A string argument.\""}]}]
(gdb)

26.13.4. The -stack-list-framesCommand

26.13.4.1. Synopsis

 -stack-list-frames [ low-frame high-frame ]

List the frames currently on the stack. For each frame it displays the following info:

level

The frame number, 0 being the topmost frame, that is, the innermost function.

addr

The $pc value for that frame.

func

Function name.

file

File name of the source file where the function lives.

line

Line number corresponding to the $pc.

If invoked without arguments, this command prints a backtrace for the whole stack. If given two integer arguments, it shows the frames whose levels are between the two arguments (inclusive). If the two arguments are equal, it shows the single frame at the corresponding level.

26.13.4.2. gdb Command

The corresponding gdb commands are backtrace and where.

26.13.4.3. Example

Full stack backtrace:

(gdb)
-stack-list-frames
^done,stack=
[frame={level="0",addr="0x0001076c",func="foo",
  file="recursive2.c",line="11"},
frame={level="1",addr="0x000107a4",func="foo",
  file="recursive2.c",line="14"},
frame={level="2",addr="0x000107a4",func="foo",
  file="recursive2.c",line="14"},
frame={level="3",addr="0x000107a4",func="foo",
  file="recursive2.c",line="14"},
frame={level="4",addr="0x000107a4",func="foo",
  file="recursive2.c",line="14"},
frame={level="5",addr="0x000107a4",func="foo",
  file="recursive2.c",line="14"},
frame={level="6",addr="0x000107a4",func="foo",
  file="recursive2.c",line="14"},
frame={level="7",addr="0x000107a4",func="foo",
  file="recursive2.c",line="14"},
frame={level="8",addr="0x000107a4",func="foo",
  file="recursive2.c",line="14"},
frame={level="9",addr="0x000107a4",func="foo",
  file="recursive2.c",line="14"},
frame={level="10",addr="0x000107a4",func="foo",
  file="recursive2.c",line="14"},
frame={level="11",addr="0x00010738",func="main",
  file="recursive2.c",line="4"}]
(gdb)

Show frames between low_frame and high_frame:

(gdb)
-stack-list-frames 3 5
^done,stack=
[frame={level="3",addr="0x000107a4",func="foo",
  file="recursive2.c",line="14"},
frame={level="4",addr="0x000107a4",func="foo",
  file="recursive2.c",line="14"},
frame={level="5",addr="0x000107a4",func="foo",
  file="recursive2.c",line="14"}]
(gdb)

Show a single frame:

(gdb)
-stack-list-frames 3 3
^done,stack=
[frame={level="3",addr="0x000107a4",func="foo",
  file="recursive2.c",line="14"}]
(gdb)

26.13.5. The -stack-list-localsCommand

26.13.5.1. Synopsis

 -stack-list-locals print-values

Display the local variable names for the current frame. With an argument of 0 prints only the names of the variables, with argument of 1 prints also their values.

26.13.5.2. gdb Command

info locals in gdb, gdb_get_locals in gdbtk.

26.13.5.3. Example

(gdb)
-stack-list-locals 0
^done,locals=[name="A",name="B",name="C"]
(gdb)
-stack-list-locals 1
^done,locals=[{name="A",value="1"},{name="B",value="2"},
  {name="C",value="3"}]
(gdb)

26.13.6. The -stack-select-frameCommand

26.13.6.1. Synopsis

 -stack-select-frame framenum

Change the current frame. Select a different frame framenum on the stack.

26.13.6.2. gdb Command

The corresponding gdb commands are frame, up, down, select-frame, up-silent, and down-silent.

26.13.6.3. Example

(gdb)
-stack-select-frame 2
^done
(gdb)

 
 
  Published under the terms of the GNU General Public License Design by Interspire