英文:
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'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.
I've looked around online and couldn'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's running fine, it'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>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论