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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

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

Getting Started with GDB 143<br />

[rr@conformix 5]$ gdb arg<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.<br />

This GDB was configured as "i386-redhat-linux"...<br />

(gdb) run test1 test2<br />

Starting program: /home/rr/5/arg test1 test2<br />

This program prints two comm<strong>and</strong> line arguments<br />

<strong>The</strong> first argument is : test1<br />

<strong>The</strong> second argument is : test2<br />

Program exited with code 037.<br />

(gdb)<br />

Another method is to set the arguments using the set comm<strong>and</strong> as done in the following<br />

gdb session. You can display current arguments using the show comm<strong>and</strong>, which is also<br />

present in this gdb session. After setting the arguments, you can use the run comm<strong>and</strong> to start<br />

executing the program.<br />

[rr@conformix 5]$ gdb arg<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.<br />

This GDB was configured as "i386-redhat-linux"...<br />

(gdb) set args test1 test2<br />

(gdb) show args<br />

Argument list to give program being debugged when it is<br />

started is "test1 test2".<br />

(gdb) run<br />

Starting program: /home/rr/5/arg test1 test2<br />

This program prints two comm<strong>and</strong> line arguments<br />

<strong>The</strong> first argument is : test1<br />

<strong>The</strong> second argument is : test2<br />

Program exited with code 037.<br />

(gdb)

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

Saved successfully!

Ooh no, something went wrong!