大澤です

  実行ファイルのプロファイルをとろうとしてつまずいています。
  -pgオプションをつけるとmain()への引数渡しができなくなって
いるようです。
  gccは7.0-Stableのgcc-4.2.1とportsのgcc-4.3.1の両方で起こります。

> cat hello.c
#include <stdio.h>

int main(int argc, char **argv)
{
  printf("hello world: %d, %s\n", argc, argv[1]);
}
> gcc -g -o hello hello.c
> ./hello abc
hello world: 2, abc

となるわけですが、

> gcc -pg -g -o hello hello.c
> ./hello abc
Segmentation fault (core dumped)
> gdb ./hello
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-marcel-freebsd"...
(gdb) b main
Breakpoint 1 at 0x80481e0: file hello.c, line 4.
(gdb) run abc
Starting program: /home/osawa/Microsc/SIM/restoration/newsrc/IM2/hello abc
SSH_TTY: Undefined variable.

Breakpoint 1, main (argc=Error accessing memory address 0x1ea8c: Bad address.
) at hello.c:4
4       {
(gdb) s

Program received signal SIGSEGV, Segmentation fault.
main (argc=Error accessing memory address 0x19: Bad address.
) at hello.c:5
5         printf("hello world: %d, %s\n", argc, argv[1]);

となってしまいます。


-- 
[&#x30E1;&#x30FC;&#x30EB;&#x30A2;&#x30C9;&#x30EC;&#x30B9;&#x4FDD;&#x8B77;] ☆ミ

メールによる返信