Find which assembly instruction caused an Illegal Instruction error without debugging

后端 未结 6 1950
走了就别回头了
走了就别回头了 2020-12-24 05:57

While running a program I\'ve written in assembly, I get Illegal instruction error. Is there a way to know which instruction is causing the error, without debug

6条回答
  •  别那么骄傲
    2020-12-24 06:16

    If you can enable core dumps on that system, just run the program, let it crash, then pull the core dump off the target machine onto your development machine and load it into a GDB built to debug the target architecture - that should tell you exactly where the crash occurred. Just use GDB's core command to load the core file into the debugger.

    • To enable core dumps on the target:

      ulimit -c unlimited
      
    • pseudo-files that control how the core file will be named (cat these to see the current configuration, write to them to change the configuration):

      /proc/sys/kernel/core_pattern
      /proc/sys/kernel/core_uses_pid
      

    On my system, once core dumps are enabled, a crashing program will write a file simply named "core" in the working directory. That's probably good enough for your purposes, but changing how the core dump file is named lets you keep a history of core dumps if that's necessary (maybe for a more intermittent problem).

提交回复
热议问题