[英]Net raid FS with FUSE, gcc -hello.c -o a.out, a.out is not executable
[英]Now output when debugging hello world in a C script with gdb on Macos (only working when both script.o and a.out present)
我在Macos 11.2.3
上安裝了gdb
。 我按照本教程進行了設置,目前有一個包含set startup-with-shell off
的文件.gdbinit
。 我使用以下腳本:
#include <stdio.h>
#include <stdlib.h>
int main (){
printf("hello world");
return 0;
}
然后我運行了命令:
$ gcc -Wall hello_world.c -o hello_world.o
$ gdb hello_world.o
(gdb) run
...
Starting program: /path/to/hello_world.o
[New Thread 0x2403 of process 10983]
但是不要打印出hello world
現在,如果用gcc hello_world.c
生成a.out
然后運行gdb hello_world.o
(創建hello_world.o
和a.out
)和(gdb) run
現在(gdb) run
我得到
$ gcc -Wall hello_world.c -o hello_world.o
$ gcc hello_world.c
$ gdb hello_world.o
...
(gdb) run
Starting program: /path/to/hello_world.o
[New Thread 0x2803 of process 15213]
[New Thread 0x1c03 of process 15213]
warning: unhandled dyld version (17)
hello world[Inferior 1 (process 15213) exited normally]
看來, gdb
當有兩部作品hello_world.o
和a.out
,但不是hello_world.o
孤單。 為什么? 我究竟做錯了什么? 如何運行gdb
並獲取hello world
輸出而不必同時使用$gcc -Wall hello_world.c -o hello_world.o
和$ gcc hello_world.c
編譯腳本
編輯根據此 github 鏈接,Macos 似乎存在問題,其中提到了以下內容:
If after hitting run in `gdb`, you get "Starting program: /path/to/your/executable [args] [New Thread 0x2303 of process 795]" followed by a blank line which does not respond to anything, then you have hit GDB bug 24069. Check that you built the patched version from source.
我究竟做錯了什么?
您正在嘗試運行hello.o
,它不是可執行程序,無法運行。
您正在遵循的教程使用gcc hello_world.c -o hello_world -ggdb
創建一個可執行文件(注意缺少-c
參數)。
好的,我可以按照GDB Wiki BuildingOnDarwin上的說明解決問題
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.