Last active
December 29, 2015 10:29
-
-
Save lucaswerkmeister/7657641 to your computer and use it in GitHub Desktop.
A test script for reading input in cgdb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
cd /tmp | |
cat > tmp.c <<EOF | |
#include <stdio.h> | |
int main() { | |
char str[4096]; | |
fgets(str, 4096, stdin); | |
printf("%s\n", str); | |
return 0; | |
} | |
EOF | |
gcc -ggdb tmp.c | |
echo 'enter "run", then some text, then "quit"' | |
echo '========================================' | |
gdb a.out | |
echo '========================================' | |
echo 'now try the same in cgdb - if it hangs, you can exit cgdb with ESC-:q' | |
sleep 5 # give the user time to read the message | |
cgdb a.out | |
echo '========================================' | |
echo 'Lets try another example with readline' | |
[ -f /usr/include/readline/readline.h ] || { | |
echo "whoops, you don't have the readline library headers installed." | |
exit | |
} | |
cat > tmp.c <<EOF | |
#include <stdio.h> | |
#include <readline/readline.h> | |
int main() { | |
char* str = readline("> "); | |
printf("%s\n", str); | |
return 0; | |
} | |
EOF | |
gcc -ggdb -lreadline tmp.c | |
echo 'enter "run", then some text, then "quit"' | |
echo '========================================' | |
gdb a.out | |
echo '========================================' | |
echo 'now try the same in cgdb - if it hangs, you can exit cgdb with ESC-:q' | |
sleep 5 # give the user time to read the message | |
cgdb a.out |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment