为了找到错误所在,修改 Makefile 在
*/ns*-allinone/ns*/ folder下
1. locate the compiler command it will either be "cc" or "gcc". change
it to "cc -g" or "gcc -g". This will make the compiler generated flags
for gdb
2. Then type
>make clean
>make
this will re compile ns
3. then run ns using gdb using the command below
>gdb ns
>[inside gdb]r your-tcl-file.tcl
4. Then, when you get a seg fault
, it will show you the line number
and file name which caused the Seg Fault
. This will give you lot of
info to debug your code.
[NS2] Segmentation fault 错误
最新推荐文章于 2023-09-23 16:32:49 发布
本文介绍了一种在遇到NS模拟器SegFault错误时的调试方法。通过修改Makefile增加调试标志,然后重新编译并使用GDB运行,可以在出现SegFault时获取到导致错误的具体文件名和行号,从而帮助开发者定位问题。
1414

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



