指向指针的指针测试

[shidongxue@centossvr testtool]$ vi a.c
#include <stdio.h>
int test2(int argc,char** argv)
{
    printf("argc=%d, argv[0]=%s\n",argc,argv[0]);
    return 0;
}
int main(int argc,char** argv)
{
    printf("%p\n",argv);
    printf("sizeof argv=%d\n",sizeof(argv));
    return test2(argc,argv);
}

~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"a.c" 13L, 239C 已写入
[shidongxue@centossvr testtool]$ gcc a.c
[shidongxue@centossvr testtool]$ gcc a.c -g
[shidongxue@centossvr testtool]$ gdb
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-80.el7
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
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"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
(gdb) file a.out
Reading symbols from /home/shidongxue/work/testtool/a.out...done.
(gdb) b main
Breakpoint 1 at 0x400570: file a.c, line 9.
(gdb) r x
Starting program: /home/shidongxue/work/testtool/a.out x

Breakpoint 1, main (argc=2, argv=0x7fffffffe4a8) at a.c:9
9               printf("%p\n",argv);
Missing separate debuginfos, use: debuginfo-install glibc-2.17-106.el7_2.8.x86_64 glibc-2.17-157.el7_3.2.x86_64
(gdb) s
0x7fffffffe4a8
10              printf("sizeof argv=%d\n",sizeof(argv));
(gdb) s
sizeof argv=8
11              return test2(argc,argv);
(gdb) x/16c 0x7fffffffe4a8
0x7fffffffe4a8: -12 '\364'      -26 '\346'      -1 '\377'       -1 '\377'       -1 '\377'       127 '\177'   0 '\000'        0 '\000'
0x7fffffffe4b0: 25 '\031'       -25 '\347'      -1 '\377'       -1 '\377'       -1 '\377'       127 '\177'   0 '\000'        0 '\000'
(gdb) x/16x 0x7fffffffe4a8
0x7fffffffe4a8: 0xf4    0xe6    0xff    0xff    0xff    0x7f    0x00    0x00
0x7fffffffe4b0: 0x19    0xe7    0xff    0xff    0xff    0x7f    0x00    0x00
(gdb) x/32c 0x7fffffffe6f4
0x7fffffffe6f4: 47 '/'  104 'h' 111 'o' 109 'm' 101 'e' 47 '/'  115 's' 104 'h'
0x7fffffffe6fc: 105 'i' 100 'd' 111 'o' 110 'n' 103 'g' 120 'x' 117 'u' 101 'e'
0x7fffffffe704: 47 '/'  119 'w' 111 'o' 114 'r' 107 'k' 47 '/'  116 't' 101 'e'
0x7fffffffe70c: 115 's' 116 't' 116 't' 111 'o' 111 'o' 108 'l' 47 '/'  97 'a'
(gdb) x/32c 0x7fffffffe719
0x7fffffffe719: 120 'x' 0 '\000'        88 'X'  68 'D'  71 'G'  95 '_'  83 'S'  69 'E'
0x7fffffffe721: 83 'S'  83 'S'  73 'I'  79 'O'  78 'N'  95 '_'  73 'I'  68 'D'
0x7fffffffe729: 61 '='  50 '2'  55 '7'  57 '9'  54 '6'  0 '\000'        72 'H'  79 'O'
0x7fffffffe731: 83 'S'  84 'T'  78 'N'  65 'A'  77 'M'  69 'E'  61 '='  99 'c'
(gdb) x/1c 0x7fffffffe719
0x7fffffffe719: 120 'x'
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值