По какой-то причине я получаю сообщение об ошибке и не позволяю мне выполнять мой код.Чтение символов из sshell ... (не найдены отладочные символы) ... сделано. (Да, я использовал -g при компиляции)
ubuntu (master *) ECS150-Simple-Shell $ gdb sshell
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.04) 7.11.1
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from sshell...(no debugging symbols found)...done.
(gdb) b LoadTerminal
Breakpoint 1 at 0x4010e8
(gdb) r
Starting program: /media/ubuntu/folder/sshell
warning: the debug information found in "/lib64/ld-2.23.so" does not match "/lib64/ld-linux-x86-64.so.2" (CRC mismatch).
Breakpoint 1, 0x00000000004010e8 in LoadTerminal()
(gdb) n
Single stepping until exit from function LoadTerminal,
which has no line number information.
sshell$
Вместо того чтобы проходить по строкам, он прошел через конец кода.
Мои Makefile
objects = main.o terminal.o history.o parser.o
cc = gcc
cflags = -g -Werror
sshell: $(objects)
$(cc) $(cflags) $(objects) -o sshell
rm $(objects)
main.o: main.c
terminal.o: terminal.c
history.o: history.c
parser.o: parser.c
.PHONY: clean
clean:
rm sshell
Мой Makefile с -g на каждом объекте файла
objects = main.o terminal.o history.o parser.o
cc = gcc
cflags = -g -Werror
sshell: $(objects)
$(cc) $(cflags) $(objects) -o sshell
rm $(objects)
main.o: main.c
gcc -g -Werror -c main.c -o main.o
terminal.o: terminal.c
gcc -g -Werror -c terminal.c -o terminal.o
history.o: history.c
gcc -g -Werror -c history.c -o history.o
parser.o: parser.c
gcc -g -Werror -c parser.c -o parser.o
.PHONY: clean
clean:
rm sshell
Я даже попытался добавить -g варианты моих объектных файлов, но я получаю ту же ошибку.
При компиляции '.c' файлов вы обязательно должны использовать' -g'. Из вашего фрагмента Makefile нет указаний на то, что это происходит. Вы можете проверить, имеет ли 'sshell' информацию об отладке через' readelf -WS sshell | grep debug'. –