1 | (gdb) call (int)close(fd) |
1 | (gdb) source ~/.gdbinit |
1 2 3 | $ ps ax | grep HelloWorld(要调试的应用程序名) 13522 ?? S 134:47.01 /Users/yyq/projects/1210/HelloWorld 24730 p5 S+ 0:00.00 grep Notes |
1 | $ gdb –pid=13522 |
1 2 | $gdb $atta 13522 |
1 | (gdb) call (void)printf(“\n Is this string printed on gdb window\n”) |
1 2 | (gdb) call (int)close(1) (gdb) call (int)close(2) |
1 2 | (gdb) shell tty /dev/tty5 |
1 2 3 4 | (gdb) p (int)open("/dev/ttyp1", 2) $1 = 1 (gdb) p (int)open("/dev/ttyp1", 2) $2 = 2 |
1 2 | (gdb) call (void)printf(“\n Is this string be printed on gdb window?\n”) Is this string be printed on gdb window? |
1 2 3 4 5 6 | def redirect call (void)close(1) call (void)close(2) call (int)open($arg0, 2) call (int)open($arg0, 2) end |
1 2 | (gdb)shell tty /dev/ttyp3 |
1 2 3 | (gdb)redirect("/dev/ttyp3") $1=1 $2=2 |
1 2 3 4 | document redirect redirect("argument"), this is used to switch stderr and stdout to gdb window. The argument is the name of gdb window. end |
1 2 3 | (gdb) help redirect this is used to switch stderr and stdout to gdb window. The argument is the name of gdb window. |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |