Linux 编程指南:许可证与脚本入门
1. Linux 编程调试与许可证概述
在 Linux 编程中,调试是一个重要的环节。例如,当遇到未初始化指针导致程序因段错误崩溃时,我们可以使用 gdb 进行调试。以下是一个具体的示例:
(gdb) file dbgtst
A program is being debugged already. Kill it? (y or n) y
Load new symbol table from “/home/naba/sw/dbgtst”? (y or n) y
Reading symbols from /home/naba/sw/dbgtst...done.
(gdb) list
1 #include <stdio.h>
2 static char buf[256];
3 void read_input(char *s);
4 int main(void)
5 {
6 char *input = NULL; /* Just a pointer, no storage
for string */
7 read_input(input);
8 /* Process command. */
9 printf(“You typed: %s\n”, input);
10 /* ... */
(gdb) break 7
Breakpoint 2 at 0x804842b: file dbgtst.c, line 7.
(gdb) run
超级会员免费看
订阅专栏 解锁全文
1581

被折叠的 条评论
为什么被折叠?



