GDB or Kdevelop bug?

axa axa783axa at yahoo.com
Mon Dec 4 14:45:01 UTC 2006


Never mind the program itself, but when I try to debug
the following simple program, with breakpoint on line
32 (while...):
--- BEGIN ---
#include <iostream>
#include <cstdio>
#include <cstdlib>

bool parsePair(FILE *file, char *pair, int pairLength,
char delimiter) {
	char tmp[pairLength+1];
	
	if ((std::fgets(tmp, pairLength+1, file)) == NULL)
return false;
	
	for (int i = 0; i < std::strlen(tmp); i++)
		if (tmp[i] != delimiter)
			pair[i] = tmp[i];
		else
			pair[i] = 0;

	return true;
}

int main(int argc, char *argv[])
{
	FILE *file;
	char pair[200];
	char *c;
	char cr;
	
	if ((file = fopen("test.txt", "r")) == NULL) {
		std::cout << "Greska pri otvaranju datoteke!" <<
std::endl;
		std::cin >> cr;
		return EXIT_FAILURE;
	}
	
	while (!feof(file)) {
		if (parsePair(file, pair, 200, '#')) {
			c = pair;
			std::cout << c << " : " << (c + std::strlen(c) + 1)
<< std::endl;
		} else
			std::cout << "parsePair(): je vratila gresku!" <<
std::endl;
	}
	
	std::cin >> cr;
	
	return EXIT_SUCCESS;
}
--- END ---

debugging breaks with the message:
"GDB exited abnormally
This is likely a bug in GDB. Examine the gdb output
window and then stop the debugger"

And this is what in that window is:
--- BEGIN ---
/bin/sh -c /home/milaks/projects/flud/debug/libtool
gdb /home/milaks/projects/flud/debug/src/flud
--interpreter=mi2 -quiet(gdb) set print static-members
off
Using host libthread_db library
"/lib/tls/i686/cmov/libthread_db.so.1".
set print static-members off
^done
(gdb) set width 0
set width 0
^done
(gdb) set height 0
set height 0
^done
(gdb) set stop-on-solib-events 1
set stop-on-solib-events 1
^done
(gdb) handle SIG32 pass nostop noprint
handle SIG32 pass nostop noprint
Signal        Stop	Print	Pass to program	Description
SIG32         No	No	Yes		Real-time event 32
^done
(gdb) handle SIG41 pass nostop noprint
handle SIG41 pass nostop noprint
Signal        Stop	Print	Pass to program	Description
SIG41         No	No	Yes		Real-time event 41
^done
(gdb) handle SIG42 pass nostop noprint
handle SIG42 pass nostop noprint
Signal        Stop	Print	Pass to program	Description
SIG42         No	No	Yes		Real-time event 42
^done
(gdb) handle SIG43 pass nostop noprint
handle SIG43 pass nostop noprint
Signal        Stop	Print	Pass to program	Description
SIG43         No	No	Yes		Real-time event 43
^done
(gdb) set print asm-demangle on
set print asm-demangle on
^done
(gdb) set output-radix 10
set output-radix 10
Output radix now set to decimal 10, hex a, octal 12.
^done
(gdb) cd /home/milaks/projects/flud/debug/src
cd /home/milaks/projects/flud/debug/src
Working directory
/home/milaks/projects/flud/debug/src.
^done
(gdb) -break-insert
/home/milaks/projects/flud/src/flud.cpp:32
^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x08048b76",func="main",file="/home/milaks/projects/flud/src/flud.cpp",fullname="/home/milaks/projects/flud/src/flud.cpp",line="32",times="0"}
(gdb) tty /dev/pts/7
tty /dev/pts/7
^done
(gdb) -exec-run
^running
Stopped due to shared library event
*stopped,thread-id="0"
(gdb) -break-condition 1 
^done
(gdb) -break-after 1 0
^done
(gdb) -break-enable 1
^done
(gdb) -exec-continue
^running
Stopped due to shared library event
*stopped,thread-id="0"
(gdb) -exec-continue
^running
Cannot access memory at address 0x0
*stopped,reason="breakpoint-hit",bkptno="1",thread-id="0",frame={addr="0x08048b76",func="main",args=[{name="argc"}],file="/home/milaks/projects/flud/src/flud.cpp",fullname="/home/milaks/projects/flud/src/flud.cpp",line="32"}
(gdb) -file-list-exec-source-file
^done,line="32",file="/home/milaks/projects/flud/src/flud.cpp",fullname="/home/milaks/projects/flud/src/flud.cpp"
(gdb) -break-list
^done,BreakpointTable={nr_rows="1",nr_cols="6",hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},{width="14",alignment="-1",col_name="type",colhdr="Type"},{width="4",alignment="-1",col_name="disp",colhdr="Disp"},{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},{width="10",alignment="-1",col_name="addr",colhdr="Address"},{width="40",alignment="2",col_name="what",colhdr="What"}],body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x08048b76",func="main",file="/home/milaks/projects/flud/src/flud.cpp",fullname="/home/milaks/projects/flud/src/flud.cpp",line="32",times="1"}]}
(gdb) -stack-list-arguments 0 0 0
^done,stack-args=[frame={level="0",args=[name="argc",name="argv"]}]
(gdb) -stack-list-locals 0
^done,locals=[name="file",name="pair",name="c",name="cr"]
(gdb) -thread-list-ids
^done,thread-ids={},number-of-threads="0"
(gdb) info frame
info frame
Stack level 0, frame at 0xbf943350:
 eip = 0x8048b76 in main
(/home/milaks/projects/flud/src/flud.cpp:32); saved
eip 0xb7cf68cc
 source language c++.
 Arglist at 0xbf943348, args: argc=Cannot access
memory at address 0x0
^error,msg="Cannot access memory at address 0x0"
(gdb) -stack-info-depth 6
^done,depth="1"
(gdb) -stack-list-frames 0 1
^done,stack=[frame={level="0",addr="0x08048b76",func="main",file="/home/milaks/projects/flud/src/flud.cpp",fullname="/home/milaks/projects/flud/src/flud.cpp",line="32"}]
(gdb) print /x &argc
print /x &argc
$1 = 0x0
^done
(gdb) -var-create KDEV0 * "argc"
^done,name="KDEV0",numchild="0",type="int"
(gdb) print /x &argv
print /x &argv
$2 = 0xbf943258
^done
(gdb) -var-create KDEV1 * "argv"
^done,name="KDEV1",numchild="1",type="char **"
(gdb) print /x &file
print /x &file
$3 = 0xbf943264
^done
(gdb) -var-create KDEV2 * "file"
^done,name="KDEV2",numchild="1",type="FILE *"
(gdb) print /x &pair
print /x &pair
$4 = 0xbf943270
^done
(gdb) -var-create KDEV3 * "pair"
^done,name="KDEV3",numchild="200",type="char [200]"
(gdb) print /x &c
print /x &c
$5 = 0xbf943268
^done
(gdb) -var-create KDEV4 * "c"
^done,name="KDEV4",numchild="1",type="char *"
(gdb) print /x &cr
print /x &cr
$6 = 0xbf94326f
^done
(gdb) -var-create KDEV5 * "cr"
^done,name="KDEV5",numchild="0",type="char"
(gdb) print /x &argc
print /x &argc
$7 = 0x0
^done
(gdb) whatis argc
whatis argc
type = int
^done
(gdb) print /x &argv
print /x &argv
$8 = 0xbf943258
^done
(gdb) whatis argv
whatis argv
type = char **
^done
(gdb) print /x &file
print /x &file
$9 = 0xbf943264
^done
(gdb) whatis file
whatis file
type = FILE *
^done
(gdb) print /x &pair
print /x &pair
$10 = 0xbf943270
^done
(gdb) whatis pair
whatis pair
type = char [200]
^done
(gdb) print /x &c
print /x &c
$11 = 0xbf943268
^done
(gdb) whatis c
whatis c
type = char *
^done
(gdb) print /x &cr
print /x &cr
$12 = 0xbf94326f
^done
(gdb) whatis cr
whatis cr
type = char
^done
(gdb) -var-update *
(gdb) Process exited
--- END ---

Since I'm not member of this list, someone please
inform me if you find out what is wrong.
Thanks.


 
____________________________________________________________________________________
Do you Yahoo!?
Everyone is raving about the all-new Yahoo! Mail beta.
http://new.mail.yahoo.com




More information about the KDevelop-devel mailing list