GDB trial (1)

Source: Internet
Author: User

GDB trial (1)
cutepig @ Ubuntu:/mnt/HGFS/share/testvalgrind $ GDB. /test
gnu gdb (GDB) 7.0-ubuntu
copyright (c) 2009 Free Software Foundation, Inc.
license gplv3 +: gnu gpl Version 3 or later
This is free software: You are free to change and redistribute it.
there is no warranty, to the extent permitted by law. type "show copying"
This GDB was configured as "i486-linux-gnu ".
for Bug reporting instructions, please see:
...
reading symbols from/mnt/HGFS/share/testvalgrind/test... done.

(GDB) List
1 # include <string. h>
2 # include <stdlib. h>
3
4
5 Int main (INT argc, char * argv [])
6 {
7 char * PTR;
8
9 PTR = (char *) malloc (10 );
Ten strcpy (PTR, "01234567890 ");

(GDB) B 9
Breakpoint 1 at 0x804850d: file test. cpp, line 9.
(GDB) r
Starting program:/mnt/HGFS/share/testvalgrind/test

Breakpoint 1, main (argc = 1, argv = 0xbffff524) at test. cpp: 9
9 PTR = (char *) malloc (10 );

(GDB) info break
Num type disp ENB address what
1 breakpoint keep y 0x0804850d in main at test. cpp: 9
Breakpoint already hit 1 time
Variables visible to the current frame
(GDB) info Frame
Stack level 0, frame at 0xbffff.pdf:
EIP = 0x804850d in main (test. cpp: 9); saved EIP 0x3bdb56
Source Language C ++.
Arglist at 0xbffff478, argS: argc = 1, argv = 0xbffff524
Locals at 0xbffff478, previous frame's SP is 0xbffff478
Saved registers:
EBP at 0xbffff478, EIP at 0xbffff47c
View a variable
(GDB) print argv
$1 = (char **) 0xbffff524
(GDB) whatis argv
Type = char **
(GDB)

Reference
Http://www.study-area.org/cyril/opentools/opentools/x1253.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.