Article View: pl.comp.os.linux.programowanie
Article #72385GCC + GDB + moj program = problemy
From: Marcin Laszewski
Date: Fri, 11 Nov 2011 14:34
Date: Fri, 11 Nov 2011 14:34
116 lines
4151 bytes
4151 bytes
Witam,
Ponizej jest prosty program, ktory, przynajmniej na moich komputerach, nie
da sie porzadnie debugoac - nie mozna wejsc do funkcji 'fun' (polecenie
's'). Od razu wyswietla wynik dziala 'fun' i to od razu dwoch wywolan.
Co ciekawsze, jesli sie cokolwiek w programie zmieni, np. f=1 to nie ma tego
problemu. PRzy f=0 lub nieinicjwowanym w ogole - jest.
Czy u Was tez tak jest? Co tego moze byc przyczna? Jakies magiczene,
domyslne opcje 'optymalizacyjne'? Jak to zmienic?
Zapis dzialan:
-----------------------------------------------------------------------------------
laser@ml-linux-1:~$ cc -g -o xxx xxx.c
laser@ml-linux-1:~$ gdb xxx
warning: Can not parse XML syscalls information; XML support was disabled at compile time.
GNU gdb (GDB) 7.0.1-debian
Copyright (C) 2009 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 "i486-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /mnt/sdb1/home/users/laser/xxx...done.
(gdb) b main
Breakpoint 1 at 0x80483ef: file xxx.c, line 37.
(gdb) r
Starting program: /mnt/sdb1/home/users/laser/xxx
Breakpoint 1, main (argc=1, argv=0xbffff6c4) at xxx.c:37
37 fun(f, &o, &q, &r);
(gdb) p f
$1 = -1073744408
(gdb) s
aaa
aaa
Program exited normally.
(gdb) quit
--------------------------------------------------------------------------------------------------
Skrypt wykonany pią, 11 lis 2011, 15:13:31
Moj kompilator:
laser@ml-dom:~/laser/c/sms-1.0$ gcc -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.4.5-8'
--with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.4 --enable-shared --enable-multiarch
--enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.4 --libdir=/usr/lib
--enable-nls --enable-clocale=gnu --enable-libstdcxx-debug
--enable-objc-gc --enable-targets=all --with-arch-32=i586
--with-tune=generic
--enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu
--target=i486-linux-gnu
Thread model: posix
gcc version 4.4.5 (Debian 4.4.5-8)
Program 'xxx.c':
-------------------------------------------------------------
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int fun(int f, unsigned char * a, unsigned * b, unsigned * c)
{
while(1)
{
puts("aaa");
if(f <= 0)
return 0;
}
return 0;
}
int main(int argc, const char * argv[])
{
int f/* = 0*/;
/* int f = 1;*/
int a;
int b;
const char * c;
char d;
int e;
unsigned char g;
int h;
unsigned char i;
FILE * j;
const char * k;
time_t l;
const char * m;
const char * n;
unsigned char o;
unsigned q, r;
fun(f, &o, &q, &r);
fun(f, &o, &q, &r);
return 0;
}
------------------------------------------------------------
--
ml
http://www.archimedes.eu.org/
Technical Details
Message-ID:
<4ebd328c$0$2184$65785112@news.neostrada.pl>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!agh.edu.pl!news.agh.edu.pl!newsfeed2.atman.pl!newsfeed.atman.pl!newsfeed.neostrada.pl!unt-exc-02.news.neostrada.pl!unt-spo-b-01.news.neostrada.pl!news.neostrada.pl.POSTED!not-for-mailShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!agh.edu.pl!news.agh.edu.pl!newsfeed2.atman.pl!newsfeed.atman.pl!newsfeed.neostrada.pl!unt-exc-02.news.neostrada.pl!unt-spo-b-01.news.neostrada.pl!news.neostrada.pl.POSTED!not-for-mail Newsgroups: pl.comp.os.linux.programowanie From: Marcin Laszewski <laser@www.allegro.pl> Subject: GCC + GDB + moj program = problemy User-Agent: slrn/pre1.0.0-18 (Linux) Mime-Version: 1.0 Date: 11 Nov 2011 14:34:52 GMT Lines: 117 Message-ID: <4ebd328c$0$2184$65785112@news.neostrada.pl> Organization: Telekomunikacja Polska NNTP-Posting-Host: 83.12.211.92 X-Trace: 1321022092 unt-rea-a-01.news.neostrada.pl 2184 83.12.211.92:58033 X-Complaints-To: abuse@news.neostrada.pl Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit