lldb not running – c

huangapple go评论68阅读模式
英文:

lldb not running - c

问题

这是你要翻译的内容:

"Hey I've recently downloaded lldb and haven't been able to get it working properly. I'm compiling a c program with a segmentation fault and want to use lldb to help me solve the problem.

This is the error message I recieve:

charlielamb@Charlies-MacBook-Air jackCompiler % lldb compiled             
(lldb) target create "compiled"
Current executable set to '/Users/charlielamb/Documents/Uni/cs/compliterDesignAndConstruction/comp/jackCompiler/compiled' (x86_64).
(lldb) run
Process 3378 launched: '/Users/charlielamb/Documents/Uni/cs/compliterDesignAndConstruction/comp/jackCompiler/compiled' (x86_64)
Process 3378 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x00007ff80f9cc6b2 libsystem_platform.dylib`_platform_strlen + 18
libsystem_platform.dylib`:
->  0x7ff80f9cc6b2 <+18>: pcmpeqb (%rdi), %xmm0
    0x7ff80f9cc6b6 <+22>: pmovmskb %xmm0, %esi
    0x7ff80f9cc6ba <+26>: andq   $0xf, %rcx
    0x7ff80f9cc6be <+30>: orq    $-0x1, %rax
Target 0: (compiled) stopped."


<details>
<summary>英文:</summary>

Hey I&#39;ve recently downloaded lldb and haven&#39;t been able to get it working properly. I&#39;m compiling a c program with a segmentation fault and want to use lldb to help me solve the problem.

This is the error message I recieve:

charlielamb@Charlies-MacBook-Air jackCompiler % lldb compiled
(lldb) target create "compiled"
Current executable set to '/Users/charlielamb/Documents/Uni/cs/compliterDesignAndConstruction/comp/jackCompiler/compiled' (x86_64).
(lldb) run
Process 3378 launched: '/Users/charlielamb/Documents/Uni/cs/compliterDesignAndConstruction/comp/jackCompiler/compiled' (x86_64)
Process 3378 stopped

  • thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x00007ff80f9cc6b2 libsystem_platform.dylib_platform_strlen + 18
    libsystem_platform.dylib
    :
    -> 0x7ff80f9cc6b2 <+18>: pcmpeqb (%rdi), %xmm0
    0x7ff80f9cc6b6 <+22>: pmovmskb %xmm0, %esi
    0x7ff80f9cc6ba <+26>: andq $0xf, %rcx
    0x7ff80f9cc6be <+30>: orq $-0x1, %rax
    Target 0: (compiled) stopped.

I&#39;ve looked around online and couldn&#39;t find anything that helps. Does anyone know how to fix this problem?

</details>


# 答案1
**得分**: 0

lldb的运行正常,只是告诉你在运行strlen时程序崩溃了。`EXC_BAD_ACCESS`表示你尝试读取或写入无效的内存。异常消息还告诉你地址是什么:

EXC_BAD_ACCESS(代码=1,地址=0x0)

代码表示这是一个读取访问。你尝试从0x0地址读取数据。

这看起来很像你的代码向strlen传递了一个空指针。

<details>
<summary>英文:</summary>

lldb&#39;s running fine, it&#39;s just telling you your program crashed while running strlen.  `EXC_BAD_ACCESS` means you tried to read or write from invalid memory.  The exception message also tells you what the address was:

EXC_BAD_ACCESS (code=1, address=0x0)

The code means it was a read access.  The address you tried to read from was 0x0.

That looks a lot like your code passed a NULL pointer to strlen.


</details>



huangapple
  • 本文由 发表于 2023年3月4日 01:51:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/75630353.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定