gdb调试的时候提示如下:no debugging symbols found,这说明可执行文件编译时没有包含了调试符号,所以需要修改makefile,编译时要-g
zbb@ihp:~/core_dump$ mips-linux-gnu-gdb video_test core-video_test-11-0-0-426-7836
GNU gdb (Ingenic Ingenic r3.3.0-gcc540 Smaller Size 2023.05-22) 7.10.50.20150827-cvs
Copyright (C) 2015 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 "--host=i686-pc-linux-gnu --target=mips-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 video_test...(no debugging symbols found)...done.
[New LWP 426]warning: Could not load shared library symbols for 8 libraries, e.g. /lib/libpthread.so.0.
Use the "info sharedlibrary" command to see the complete listing.
Do you need "set solib-search-path" or "set sysroot"?
Core was generated by `./video_test'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x004008a8 in _ftext ()
(gdb)
(gdb)
(gdb)
(gdb)
(gdb)
(gdb)
(gdb) bt
#0 0x004008a8 in _ftext ()
(gdb)
#0 0x004008a8 in _ftext ()
(gdb)
#0 0x004008a8 in _ftext ()
(gdb)
#0 0x004008a8 in _ftext ()
(gdb) list
No symbol table is loaded. Use the "file" command.
(gdb) q
修改makefile如下
#CFLAGS = $(INCLUDES) -O2 -Wall -march=mips32r2
CFLAGS = $(INCLUDES) -g -Wall -march=mips32r2(改为这个)
CONFIG_UCLIBC_BUILD=yCROSS_COMPILE ?= mips-linux-gnu-CC = $(CROSS_COMPILE)gcc
CPLUSPLUS = $(CROSS_COMPILE)g++
LD = $(CROSS_COMPILE)ld
AR = $(CROSS_COMPILE)ar cr
STRIP = $(CROSS_COMPILE)strip#CFLAGS = $(INCLUDES) -O2 -Wall -march=mips32r2
CFLAGS = $(INCLUDES) -g -Wall -march=mips32r2
ifeq ($(CONFIG_UCLIBC_BUILD), y)
CFLAGS += -muclibc
LDFLAG += -muclibc
endififeq ($(CONFIG_UCLIBC_BUILD), y)
SDK_LIB_DIR = ./lib
else
SDK_LIB_DIR = ../../lib/glibc
endifSDK_INC_DIR = ./INCLUDES = -I$(SDK_INC_DIR)LIBS = $(SDK_LIB_DIR)/libimp.a $(SDK_LIB_DIR)/libalog.a $(SDK_LIB_DIR)/libmove_inf.a\$(SDK_LIB_DIR)/libsysutils.a $(SDK_LIB_DIR)/libjzdl.a $(SDK_LIB_DIR)/libpersonDet_inf.a $(SDK_LIB_DIR)/libmxu_contrib.a\$(SDK_LIB_DIR)/libmxu_core.a $(SDK_LIB_DIR)/libmxu_imgproc.a $(SDK_LIB_DIR)/libmxu_merge.a $(SDK_LIB_DIR)/libmxu_objdetect.a \$(SDK_LIB_DIR)/libmxu_video.aLDFLAG += -Wl,-gc-sectionsSAMPLES = video_test \all: $(SAMPLES)video_test: main.o $(SDK_LIB_DIR)/libdsp.a $(SDK_LIB_DIR)/libimp.a $(SDK_LIB_DIR)/libalog.a $(SDK_LIB_DIR)/libmove_inf.a\$(SDK_LIB_DIR)/libsysutils.a $(SDK_LIB_DIR)/libjzdl.a $(SDK_LIB_DIR)/libpersonDet_inf.a $(SDK_LIB_DIR)/libmxu_contrib.a\$(SDK_LIB_DIR)/libmxu_core.a $(SDK_LIB_DIR)/libmxu_imgproc.a $(SDK_LIB_DIR)/libmxu_merge.a $(SDK_LIB_DIR)/libmxu_objdetect.a \$(SDK_LIB_DIR)/libmxu_video.a $(CPLUSPLUS) $(LDFLAG) -o $@ $^ $(LIBS) -lpthread -lm -lrt -ldl%.o:%.c sample-common.h$(CPLUSPLUS) -c $(CFLAGS) $< -o $@clean:rm -f *.o *~distclean: cleanrm -f $(SAMPLES)
修改后调试成功如下
zbb@ihp:~/core_dump$ mips-linux-gnu-gdb video_test core-video_test-11-0-0-224-455
GNU gdb (Ingenic Ingenic r3.3.0-gcc540 Smaller Size 2023.05-22) 7.10.50.20150827-cvs
Copyright (C) 2015 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 "--host=i686-pc-linux-gnu --target=mips-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 video_test...done.
[New LWP 224]warning: Could not load shared library symbols for 8 libraries, e.g. /lib/libpthread.so.0.
Use the "info sharedlibrary" command to see the complete listing.
Do you need "set solib-search-path" or "set sysroot"?
Core was generated by `./video_test'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x004008a8 in main () at main.c:9
9 int i = *ptr;
(gdb)
(gdb)
(gdb)
(gdb) bt
#0 0x004008a8 in main () at main.c:9
(gdb)
#0 0x004008a8 in main () at main.c:9
(gdb)
#0 0x004008a8 in main () at main.c:9
(gdb)
#0 0x004008a8 in main () at main.c:9
(gdb)
#0 0x004008a8 in main () at main.c:9
(gdb)
#0 0x004008a8 in main () at main.c:9
(gdb) list
4
5 * Copyright (C) 2017 Ingenic Semiconductor Co.,Ltd
6 *
7 */
8
9 #include <unistd.h>
10 #include <sys/ioctl.h>
11 #include <sys/prctl.h>
12 #include <string.h>
13 #include <stdio.h>
(gdb)
Line number 14 out of range; main.c has 13 lines.
(gdb)
Line number 14 out of range; main.c has 13 lines.
(gdb)
Line number 14 out of range; main.c has 13 lines.
(gdb)
Line number 14 out of range; main.c has 13 lines.
(gdb)
Line number 14 out of range; main.c has 13 lines.
(gdb)