如果我使用gdb -tui源窗口调试文件总是搞砸了.因此,每次我点击enter我必须立即键入ctrl+ L以摆脱这个问题,这是如何gdb刷新窗口.我正在使用gnu屏幕进行tty.
是否有可能在tui模式下自动刷新gdb?
如果gdb没有这种能力,Python可能是一个解决方案,因为gdb能够获取Python文件,但我不知道Python.
这个Python代码段在Bash中工作正常,但在gdb中不行:
import sys
r = "\033[2J" # here I try to emulate [ctrl-L]
t = ""
while 1:
i = sys.stdin.read(1)
t = t +i
if i == '\n':
print(r)
Run Code Online (Sandbox Code Playgroud)
当然我接受gdb支持的所有其他语言.
感谢每一位帮助.
顺便说一句,这是一个显示我的问题的截屏视频https://youtu.be/DqiH6Jym1JY.
这是我用于在gdb中演示的文件,如show's,mess_up.c上面的链接
#include <stdio.h>
int main(void){
//int n = 120;
int n;
n = 120;
char stuff[n+2];
printf( "Max: %d\n", n );
printf( "Sizeof int: %d\n", sizeof(int) );
printf( "Sizeof char: %d\n", …Run Code Online (Sandbox Code Playgroud) 我无法使GDB正确打印一些C风格的十六进制浮点数,请参阅:
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
Copyright (C) 2014 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 "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online …Run Code Online (Sandbox Code Playgroud) 我想在 C 中的子写入器和父读取器之间建立一个管道。我认为我的父进程必须等待它的子进程写入缓冲区才能读取它,但后来我想检查所以我写了下面的一段代码:
pipe(fd);
// ... checks for pipe
pid_t pid = fork();
// ... checks for fork
if (pid == 0) {
close(fd[0]);
// Long sleep hoping parent will terminate before the write()
sleep(10);
write(fd[1], "hello", strlen("hello") + 1);
close(fd[1]);
} else {
close(fd[1]);
read(fd[0], buf, sizeof(buf));
printf("received: %s\n", buf);
close(fd[0]);
}
return 0;
Run Code Online (Sandbox Code Playgroud)
输出出乎意料(或者不是?)received: hello。如果我用for (volatile int i = 0; i < some_big_int; ++i);循环替换对 sleep() 的调用,则输出相同。我不认为调用read()会阻止我的父进程,直到孩子在管道的另一端写入,但我无法解释这种行为。任何提示?