如何自动和非交互,在源代码中触发分割故障的位置?

发布于 2025-01-21 09:04:57 字数 546 浏览 2 评论 0原文

我正在使用一种自动测试工具,该工具发现通常表现为分段故障的错误。我试图找出其中有多少个检测到的错误是唯一的。唯一性是我的研究中使用的一个特殊术语:如果两个分割故障由不同的陈述触发,则两者被认为是不同的。我目前的方法来判断两个分割故障是否由不同的语句触发是使用GDB。例如:

(gdb) r

Program received signal SIGSEGV, Segmentation fault.
0x00007f050c9efac2 in gsl_stats_quantile_from_sorted_data (sorted_data=sorted_data@entry=0x7fffe1477c40, stride=stride@entry=1,
    n=n@entry=5, f=675) at quantiles_source.c:37
37        result = sorted_data[lhs * stride]

如您所见,GDB停止在分割故障的位置(C Program Quantiles_Source.c的第37行如上图所示)。我想知道如何通过命令行或脚本获得非交互方式获取该信息?

I am working on an automated testing tool which has found bugs that are usually manifested as segmentation faults. I am trying to find out how many of these detected bugs are unique. Uniqueness is a special term used in my study: If two segmentation faults are triggered by different statements, the two are considered different. My current approach to tell if two segmentation faults are triggered by different statements or not is to use GDB. For example:

(gdb) r

Program received signal SIGSEGV, Segmentation fault.
0x00007f050c9efac2 in gsl_stats_quantile_from_sorted_data (sorted_data=sorted_data@entry=0x7fffe1477c40, stride=stride@entry=1,
    n=n@entry=5, f=675) at quantiles_source.c:37
37        result = sorted_data[lhs * stride]

As you can see, GDB stops at where the segmentation fault arises (line 37 of the C program quantiles_source.c as shown above). I am wondering how to get that piece of information by a command line or script, non-interactively?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

破晓 2025-01-28 09:04:57

您可以通过使用-X文件在文件中执行指定的命令,在二进制上运行gdb,或者您可以使用-ex命令< /code>(如果需要,多次使用)。无论哪种情况,与结合使用 - 批处理随后退出。另一个选项配置您的shell以允许核心文件使用ulimit -c ulimited,然后使用上述参数在二进制和结果的核心文件上运行gdb

You can run gdb non-interactive on the binary by executing the commands specified in file with -x file, or you can specify a command with -ex command (used multiple times if needed). In either case when combined with --batch it subsequently exit. Another option configure your shell to allow a core file to dumped with ulimit -c ulimited then run gdb on the binary and resulting core file using the arguments mentioned above.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文