|
From: Bartels, E. <Enn...@ea...> - 2004-12-03 06:51:27
Attachments:
curses_test.c
|
Hi
I have added the smallest possible
curses test program for this case.
It's a curses program that increases
a counter every second starting with 0.
At counter 6 it will print an uninitialised
value.
You can stop the program with key 'q'.
compile:
cc curses_test.c -c -g -o curses_test.o
link:
cc curses_test.o -lc -lm -lncurses -g -o curses_test
start with valgrind - output into logfile:
valgrind --tool=memcheck --log-file=ct ./curses_test
Maybe now can somebody help and tell how to attach
the gdb debugger and with working "y"es keyboard
sended to valgrind the right way!
Thanks for listening.
Enno
|
|
From: Bartels, E. <Enn...@ea...> - 2004-12-03 08:04:20
|
Hi
Sorry attachment is not shown in the
mailing list now add it inside
the mail.
Here is the code of the curses_test.c file:
---------------------------------------------
/* Test program by Enno Bartels
*/
#include <curses.h>
/*! Curses window pointer */
WINDOW *p_win_g;
int
main (int argc, char **p_argv)
{
int go = 1;
int loop_number = 0;
int keyboard = 0;
int valgrind_uninitialised_test_variable;
/***************/
/* INIT CURSES */
/***************/
/* Clear the keyboard buffer */
fflush (stdin);
/* Initialize screen, clears screen, returns pointer */
p_win_g = initscr ();
/* Typed characters immediately available to program */
cbreak ();
/* No echo of typed characters on the screen */
noecho ();
/* No new line for faster cursor motion */
nonl ();
/* No waiting until a key is pressed */
nodelay (p_win_g, TRUE);
/* Single value for function and arrow keys */
keypad (p_win_g, TRUE);
/************************/
/* Do something in loop */
/************************/
do
{
/* Print the loop number on screen */
mvprintw (10,10, "Loop number: %d", loop_number);
/* Query the keyboard */
keyboard = wgetch (p_win_g);
/* Analyse keyboard key */
if (keyboard == 'q')
{
go = 0;
}
/* Print an uninitialised variable */
if (loop_number == 6)
{
mvprintw (13, 10, "valgrind_uninitialised_test_variable = %d ",
valgrind_uninitialised_test_variable);
mvprintw (14, 10, " shown at loop %d ", loop_number);
}
/* Increase loop counter */
loop_number++;
/* Sleep one second */
sleep (1);
} while (go == 1);
/*****************/
/* FINISH CURSES */
/*****************/
/* Update the screen */
wrefresh (p_win_g);
/* End curses session */
endwin ();
} /* End of main */
|