程序与gdb一起运行,但不与./ProgramName一起运行 [英] Program runs with gdb but doesn't run with ./ProgramName
问题描述
我正在Linux中以汇编64位模式编写编辑器.当我在GDB中调试程序时,它可以正确运行,但是当我正常运行它时,它却不能正确运行,这意味着当我使用./programName时,它会出现运行时错误.
I am writing an editor in assembly 64bit mode in linux. It runs correctly when I debug the program in GDB but it does not run correctly when I run it normally it means it has runtime errors when I use ./programName .
推荐答案
您可能正在访问未初始化的数据或存在某种内存损坏问题.这将解释程序在调试器中运行时的行为方式不同-您会看到未定义行为的结果.
You're probably accessing uninitialized data or have some kind of memory corruption problem. This would explain the program behaving differently when run in the debugger - you're seeing the results of undefined behavior.
通过 valgrind 的memcheck工具运行程序,并查看其输出. Valgrind是一个功能强大的工具,可以识别Linux上的许多运行时错误,包括对该错误的完整堆栈跟踪.
Run your program through valgrind's memcheck tool and see what it outputs. Valgrind is a powerful tool that will identify many runtime errors on Linux, including a full stack trace to the error.
这篇关于程序与gdb一起运行,但不与./ProgramName一起运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!