Иногда в инструментах бывают отвратительные ошибки, и, не зная о них, он может тратить часы и часы, и, конечно, разочаровываться. Знание этих проблем не устраняет проблему, но, по крайней мере, помогает сократить время на ее решение. И вот одна из них, которая некоторое время мучила меня отладчиком GNU GDB в Eclipse… ..
Я счастливо отлаживал свой проект, вносил некоторые изменения, и вдруг я больше не могу отлаживать его. Что происходит, так это то, что я могу загрузить двоичный файл с помощью GDB, но он немедленно завершает работу и отключается:
После копания и проб и ошибок я нашел причину этого.
Проблема в том, что GDB пытается установить точку останова на фрагменте кода, который больше не существует. Например, раньше я ссылался на функцию «TestFunction» и на ней была точка абрекции. Теперь, если эта функция больше не связана, и у меня все еще есть точка отклика, происходит вышеуказанный сбой:
Я думаю, что это общая проблема клиента GDB, а не проблема сервера P & E Multilink или Segger J-Link GDB.
Клиент GDB не предоставляет никакой информации:
monitor clrbp monitor reset monitor halt monitor regs flushreg monitor speed auto Register cache flushed. The target endianness is set automatically (currently little endian)
И следы GDB также не указывают на проблему:
734,080 2-environment-cd C:/Users/tastyger/Data/HSLU/Vorlesung/INTRO_HS2014/git/INTRO_HS2014/Project\ s/INTRO_FRDM 734,084 2^done 734,084 (gdb) 734,084 3-gdb-set breakpoint pending on 734,094 3^done 734,094 (gdb) 734,094 4-enable-pretty-printing 734,094 4^done 734,094 (gdb) 734,094 5-gdb-set python print-stack none 734,104 5^done 734,104 (gdb) 734,104 6-gdb-set print object on 734,104 6^done 734,104 (gdb) 734,104 7-gdb-set print sevenbit-strings on 734,114 7^done 734,114 (gdb) 734,114 8-gdb-set charset ISO-8859-1 734,124 8^done 734,124 (gdb) 734,124 9set mem inaccessible-by-default off 734,124 10source .gdbinit 734,124 &"set mem inaccessible-by-default off\n" 734,124 =cmd-param-changed,param="mem inaccessible-by-default",value="off" 734,124 9^done 734,124 (gdb) 734,124 &"source .gdbinit\n" 734,125 11-gdb-set auto-solib-add on 734,125 &".gdbinit: No such file or directory.\n" 734,125 10^error,msg=".gdbinit: No such file or directory." 734,125 (gdb) 734,125 11^done 734,125 (gdb) 734,125 12-target-select remote localhost:2331 734,192 13-list-thread-groups 734,644 =thread-group-started,id="i1",pid="42000" 734,644 =thread-created,id="1",group-id="i1" 734,645 14-list-thread-groups --available 734,647 *stopped,frame={addr="0x00000000",func="??",args=[]},thread-id="1",stopped-threads="all" 734,647 12^connected 734,647 (gdb) 734,647 &"\n" 734,647 ^done 734,647 (gdb) 734,648 13^done,groups=[{id="i1",type="process",pid="42000"}] 734,648 (gdb) 734,648 14^error,msg="Can not fetch data now." 734,648 (gdb) 734,648 15monitor speed 1000 monitor clrbp monitor reset monitor halt monitor regs flushreg monitor \ speed auto 734,658 &"monitor speed 1000\n" 734,658 @"Target interface speed set to 1000 kHz\r\n" 734,658 15^done 734,658 (gdb) 734,658 &"monitor clrbp\n" 734,659 ^done 734,659 (gdb) 734,659 &"monitor reset\n" 734,681 @"Resetting target\r\n" 734,681 ^done 734,681 (gdb) 734,681 &"monitor halt\n" 734,681 ^done 734,681 (gdb) 734,681 &"monitor regs\n" 734,681 @"R0 = 00000000, R1 = 20000F18, R2 = 20000168, R3 = 12345678\n" 734,681 @"R4 = 4761032D, R5 = 40020000, R6 = 0000FFFF, R7 = 00000000\n" 734,681 @"R8 = AFBF9D3F, R9 = EFBBFFFB, R10= DFBEFEFD, R11= 00002000\n" 734,681 @"R12= FF7FEBFD, R13= 20003000, MSP= 20003000, PSP= FF7FBFFC\n" 734,681 @"R14(LR) = 20000121, R15(PC) = 00000BDC\n" 734,681 @"XPSR 61000000, APSR 60000000, EPSR 01000000, IPSR 00000000\n" 734,681 @"CFBP 00000000, CONTROL 00, FAULTMASK 00, BASEPRI 00, PRIMASK 00\r\n" 734,681 ^done 734,681 (gdb) 734,682 &"flushreg\n" 734,682 ~"Register cache flushed.\n" 734,682 ^done 734,682 (gdb) 734,682 &"monitor speed auto\n" 734,682 @"Select auto target interface speed (2000 kHz)\r\n" 734,682 ^done 734,682 (gdb) 734,715 16monitor flash breakpoints 1 monitor semihosting enable monitor semihosting IOClient 1 734,721 17-list-thread-groups i1 734,723 &"monitor flash breakpoints 1\n" 734,723 @"Flash breakpoints enabled\r\n" 734,723 16^done 734,723 (gdb) 734,723 &"monitor semihosting enable\n" 734,723 18symbol-file C:\\Users\\tastyger\\Data\\HSLU\\Vorlesung\\INTRO_HS2014\\git\\INTRO_HS2014\\P\ rojects\\INTRO_FRDM\\Debug\\INTRO_FRDM.elf 734,723 @"Semi-hosting enabled (VectorAddr = 0x08)\r\n" 734,723 19load C:\\Users\\tastyger\\Data\\HSLU\\Vorlesung\\INTRO_HS2014\\git\\INTRO_HS2014\\Projects\ \\INTRO_FRDM\\Debug\\INTRO_FRDM.elf 734,723 ^done 734,723 (gdb) 734,723 &"monitor semihosting IOClient 1\n" 734,723 @"Semihosting I/O set to TELNET Client\r\n" 734,724 ^done 734,724 (gdb) 734,725 17^done,threads=[{id="1",target-id="Thread <main>",frame={level="0",addr="0x00000bdc",func="\ ??",args=[]},state="stopped"}] 734,725 (gdb) 734,725 &"symbol-file C:\\\\Users\\\\tastyger\\\\Data\\\\HSLU\\\\Vorlesung\\\\INTRO_HS2014\\\\git\\\\ \INTRO_HS2014\\\\Projects\\\\INTRO_FRDM\\\\Debug\\\\INTRO_FRDM.elf\n" 734,726 ~"Reading symbols from C:\\Users\\tastyger\\Data\\HSLU\\Vorlesung\\INTRO_HS2014\\git\\INTRO_\ HS2014\\Projects\\INTRO_FRDM\\Debug\\INTRO_FRDM.elf..." 734,726 20-stack-info-depth --thread 1 11 734,729 ~"done.\n" 734,731 18^done 734,731 (gdb) 734,731 21-gdb-show --thread-group i1 language 734,731 &"load C:\\\\Users\\\\tastyger\\\\Data\\\\HSLU\\\\Vorlesung\\\\INTRO_HS2014\\\\git\\\\INTRO_\ HS2014\\\\Projects\\\\INTRO_FRDM\\\\Debug\\\\INTRO_FRDM.elf\n" 734,731 ~"Loading section .interrupts, size 0xc0 lma 0x0\n" 734,732 19+download,{section=".interrupts",section-size="192",total-size="377725"} 734,732 19+download,{section=".interrupts",section-sent="192",section-size="192",total-sent="192",to\ tal-size="377725"} 734,732 ~"Loading section .cfmprotect, size 0x10 lma 0x400\n" 734,732 19+download,{section=".cfmprotect",section-size="16",total-size="377725"} 734,732 ~"Loading section .text, size 0x1f38 lma 0x410\n" 734,733 19+download,{section=".text",section-size="7992",total-size="377725"} 734,733 ~"Loading section .init_array, size 0x4 lma 0x2348\n" 734,733 19+download,{section=".init_array",section-size="4",total-size="377725"} 734,733 ~"Loading section .fini_array, size 0x4 lma 0x234c\n" 734,733 19+download,{section=".fini_array",section-size="4",total-size="377725"} 734,733 ~"Loading section .romp, size 0x18 lma 0x2350\n" 734,734 19+download,{section=".romp",section-size="24",total-size="377725"} 734,734 ~"Start address 0xbdc, load size 8232\n" 734,734 ~"Transfer rate: 2679 KB/sec, 1372 bytes/write.\n" 734,734 19^done 734,734 (gdb) 734,735 20^done,depth="1" 734,735 (gdb) 734,735 21^done,value="auto" 734,735 (gdb) 734,735 22-gdb-set --thread-group i1 language c 734,745 22^done 734,745 (gdb) 734,745 23-data-evaluate-expression --thread-group i1 "sizeof (void*)" 734,755 23^done,value="4" 734,755 (gdb) 734,759 24-gdb-set --thread-group i1 language auto 734,765 24^done 734,765 (gdb) 734,765 25-interpreter-exec --thread-group i1 console "show endian" 734,775 ~"The target endianness is set automatically (currently little endian)\n" 734,775 25^done 734,775 (gdb) 734,779 26-break-insert --thread-group i1 -t -f C:\\Users\\tastyger\\Data\\HSLU\\Vorlesung\\INTRO_HS\ 2014\\git\\INTRO_HS2014\\Projects\\INTRO_FRDM\\Sources\\main.c:main 734,779 27-break-insert --thread-group i1 -f C:\\Users\\tastyger\\Data\\HSLU\\Vorlesung\\INTRO_HS201\ 4\\git\\INTRO_HS2014\\Projects\\INTRO_Common\\Application.c:27 734,796 26^done,bkpt={number="1",type="breakpoint",disp="del",enabled="y",addr="0x0000096c",func="ma\ in",file="../Sources/main.c",fullname="C:\\Users\\tastyger\\Data\\HSLU\\Vorlesung\\INTRO_HS2014\\git\ \\INTRO_HS2014\\Projects\\INTRO_FRDM\\Sources\\main.c",line="84",thread-groups=["i1"],times="0",orig\ inal-location="C:\\\\Users\\\\tastyger\\\\Data\\\\HSLU\\\\Vorlesung\\\\INTRO_HS2014\\\\git\\\\INTRO_\ HS2014\\\\Projects\\\\INTRO_FRDM\\\\Sources\\\\main.c:main"} 734,797 (gdb)
Сервер P & E сообщает:
P&E GDB Server, Version 5.07.00.00 Copyright 2014, P&E Microcomputer Systems Inc, All rights reserved Loading library C:\Freescale\KDS_1.1.1\eclipse\plugins\com.pemicro.debug.gdbjtag.pne_1.1.4.201409071615\win32\gdi\unit_ngs_arm_internal.dll ... Done. Command line arguments: -device=KL25Z128M4 -startserver -serverport=7224 -interface=OPENSDA -speed=5000 -port=USB1 -USE_CYCLONEPRO_RELAYS=0 -FORCE_MASS_ERASE=0 Device selected is kl25z128m4 User Specified Hardware Selection : Interface=OPENSDA and Port=USB1 Connecting to target. OpenSDA detected - Flash Version 1.14 Device is KL25Z128M4. Mode is In-Circuit Debug. 'Kinetis' is a registered trademark of Freescale. (C)opyright 2012, P&E Microcomputer Systems, Inc. (www.pemicro.com) API version is 101 Server running on 127.0.0.1:7224 Connection from "127.0.0.1" via 127.0.0.1 Copyright 2012 P&E Microcomputer Systems,Inc. Command Line :C:\Freescale\KDS_1.1.1\eclipse\plugins\com.pemicro.debug.gdbjtag.pne_1.1.4.201409071615\win32\pegdbserver_console -device=KL25Z128M4 -startserver -serverport=7224 -interface=OPENSDA -speed=5000 -port=USB1 -USE_CYCLONEPRO_RELAYS=0 -FORCE_MAS CMD>RE Initializing. Target has been RESET and is active. CMD>CM C:\Freescale\KDS_1.1.1\eclipse\plugins\com.pemicro.debug.gdbjtag.pne_1.1.4.201409071615\win32\gdi\P&E\kl25z128m4_pflash_pipeline.arp Initializing. Initialized. ;version 1.03, 07/17/2013, Copyright P&E Microcomputer Systems, www.pemicro.com [mk_128k_n_pflash_m0] ;device freescale, kl25z128m4, 1x32x32k, desc=pflash_pipeline ;begin_cs device=$00000000, length=$00020000, ram=$20000000 Loading programming algorithm ... Done. CMD>EM Erasing. Module has been erased. Initializing. Initialized. ;version 1.03, 07/17/2013, Copyright P&E Microcomputer Systems, www.pemicro.com [mk_128k_n_pflash_m0] ;device freescale, kl25z128m4, 1x32x32k, desc=pflash_pipeline ;begin_cs device=$00000000, length=$00020000, ram=$20000000 Loading programming algorithm ... Done. CMD>PM Programming. Processing Object File Data ... . Programmed. CMD>VC Verifying object file CRC-16 to device ranges ... block 00000000-000000BF ... Ok. block 00000400-00002367 ... Ok. Checksum Verification Successful. (Cumulative CRC-16=$D438) CMD>RE Initializing. Target has been RESET and is active. Disconnected from "127.0.0.1" via 127.0.0.1 Terminating Gracefully... Target Disconnected.
Сервер Segger J-Link сообщает:
SEGGER J-Link GDB Server V4.88a Command Line Version JLinkARM.dll V4.88a (DLL compiled Jul 17 2014 18:20:19) -----GDB Server start settings----- GDBInit file: none GDB Server Listening port: 2331 SWO raw output listening port: 2332 Terminal I/O port: 2333 Accept remote connection: localhost only Generate logfile: off Verify download: on Init regs on start: on Silent mode: off Single run mode: on Target connection timeout: 5 sec. ------J-Link related settings------ J-Link Host interface: USB J-Link script: none J-Link settings file: none ------Target related settings------ Target device: MKL25Z128xxx4 Target interface: SWD Target interface speed: 1000kHz Target endian: little Connecting to J-Link... J-Link is connected. Firmware: J-Link V9 compiled Jul 17 2014 12:01:11 Hardware: V9.00 S/N: 609100567 Feature(s): RDI, FlashBP, FlashDL, JFlash, GDB Checking target voltage... Target voltage: 2.94 V Listening on TCP/IP port 2331 Connecting to target...Connected to target Waiting for GDB connection...Connected to 127.0.0.1 Reading all registers Read 4 bytes @ address 0x00000000 (Data = 0x20003000) Target interface speed set to 1000 kHz Resetting target Halting target CPU... ...Target halted (PC = 0x00000BDC) R0 = 00000000, R1 = 20000F18, R2 = 20000168, R3 = 12345678 R4 = 4761032D, R5 = 40020000, R6 = 0000FFFF, R7 = 00000000 R8 = AFBF9D3F, R9 = EFBBFFFB, R10= DFBEFEFD, R11= 00002000 R12= FF7FEBFD, R13= 20003000, MSP= 20003000, PSP= FF7FBFFC R14(LR) = 20000121, R15(PC) = 00000BDC XPSR 61000000, APSR 60000000, EPSR 01000000, IPSR 00000000 CFBP 00000000, CONTROL 00, FAULTMASK 00, BASEPRI 00, PRIMASK 00 Reading all registers Select auto target interface speed (2000 kHz) Flash breakpoints enabled Semi-hosting enabled (VectorAddr = 0x08) Semihosting I/O set to TELNET Client Read 4 bytes @ address 0x00000BDC (Data = 0xB082B580) Downloading 192 bytes @ address 0x00000000 - Verified OK Downloading 16 bytes @ address 0x00000400 - Verified OK Downloading 7992 bytes @ address 0x00000410 - Verified OK Downloading 4 bytes @ address 0x00002348 - Verified OK Downloading 4 bytes @ address 0x0000234C - Verified OK Downloading 24 bytes @ address 0x00002350 - Verified OK Read 4 bytes @ address 0x00000BDC (Data = 0xB082B580) Read 2 bytes @ address 0x0000096C (Data = 0xF000) Read 2 bytes @ address 0x0000096C (Data = 0xF000) Read 2 bytes @ address 0x00000000 (Data = 0x3000) Read 2 bytes @ address 0x00000002 (Data = 0x2000) Read 2 bytes @ address 0x00000004 (Data = 0x0BDD) Read 2 bytes @ address 0x00000006 (Data = 0x0000) Read 2 bytes @ address 0x00000008 (Data = 0x0F49) Read 2 bytes @ address 0x0000000A (Data = 0x0000) Read 2 bytes @ address 0x0000000C (Data = 0x1769) Read 2 bytes @ address 0x0000000E (Data = 0x0000) Read 2 bytes @ address 0x00000010 (Data = 0x0F55) Read 2 bytes @ address 0x00000012 (Data = 0x0000) Read 2 bytes @ address 0x00000014 (Data = 0x0F55) Read 2 bytes @ address 0x00000016 (Data = 0x0000) Read 2 bytes @ address 0x00000018 (Data = 0x0F55) Read 2 bytes @ address 0x0000001A (Data = 0x0000) Read 2 bytes @ address 0x0000001C (Data = 0x0F55) Read 2 bytes @ address 0x0000001E (Data = 0x0000) Read 2 bytes @ address 0x00000020 (Data = 0x0F55) Read 2 bytes @ address 0x00000022 (Data = 0x0000) Read 2 bytes @ address 0x00000024 (Data = 0x0F55) Read 2 bytes @ address 0x00000026 (Data = 0x0000) Read 2 bytes @ address 0x00000028 (Data = 0x0F55) Read 2 bytes @ address 0x0000002A (Data = 0x0000) Read 2 bytes @ address 0x0000002C (Data = 0x0F55) Read 2 bytes @ address 0x0000002E (Data = 0x0000) Read 2 bytes @ address 0x00000030 (Data = 0x0F55) Read 2 bytes @ address 0x00000032 (Data = 0x0000) Read 2 bytes @ address 0x00000034 (Data = 0x0F55) Read 2 bytes @ address 0x00000036 (Data = 0x0000) Read 2 bytes @ address 0x00000038 (Data = 0x0F55) Read 2 bytes @ address 0x0000003A (Data = 0x0000) Read 2 bytes @ address 0x0000003C (Data = 0x0F55) Read 2 bytes @ address 0x0000003E (Data = 0x0000) GDB closed TCP/IP connection
Я думал, что отключение этой точки останова может быть лекарством. Однако необходимо удалить / удалить эту точку останова. То же самое может произойти, если использовать выражение (см. « Отладка переменных с помощью Eclipse Kepler ») для местоположений «не существует больше». Здесь снова: решение состоит в том, чтобы удалить выражения, если это произойдет.
Иногда GDB возвращает ошибку об ошибке установки точки останова:
Это предупреждение также отображается в окне проблем:
Удаление точки останова из представления точки останова не помогает: мне нужно удалить ее из представления «Проблемы» с помощью контекстного меню:
С этим я избавляюсь от этого сообщения :-).
Отличается ГДБ?
Я попробовал то же самое с GDB, присутствующим в обновлении GNU ARM Embedded (lauchpad) 4.8, 2 gdb и инструментами, и здесь возникла еще большая проблема: сбой GDB:
Здесь следы GDB говорят о внутренней проблеме GDB:
443,155 28-list-thread-groups 443,155 29-thread-info 1 443,226 ~"/home/build/work/GCC-4-8-build/src/gdb/gdb/linespec.c:2445: internal-error: decode_line_fu\ ll: Assertion `state->canonical_names[i].suffix != NULL' failed.\nA problem internal to GDB has been\ detected,\nfurther debugging may prove unreliable.\nQuit this debugging session? " 443,226 ~"(y or n) \n" 443,226 ~"/home/build/work/GCC-4-8-build/src/gdb/gdb/linespec.c:2445: internal-error: decode_line_fu\ ll: Assertion `state->canonical_names[i].suffix != NULL' failed.\nA problem internal to GDB has been\ detected,\nfurther debugging may prove unreliable.\nCreate a core file of GDB? " 443,226 ~"(y or n) [answered Y; input not from terminal]\n" 443,226 30-data-disassemble --thread 1 -s 2948 -e 3000 -- 1
Я пытался сделать то же самое с новым обновлением [a title = «Launchpad v4.8 Q3» href = «https://launchpad.net/gcc-arm-embedded/+announcement/12983»] v4.8 q3 update с панели запуска. Здесь снова происходит сбой, но он дает хоть какую-то информацию:
/home/build/work/GCC-4-8-build/src/gdb/gdb/linespec.c:2445: internal-error: decode_line_full: Assertion `state->canonical_names[i].suffix != NULL' failed.
Резюме
Если обнаружены проблемы с установкой точки останова, удалите точку останова из представления «Точки останова» и удалите сообщение из представления «Проблемы». Если вы используете отладчик GDB (например, с плагинами GNU ARM Eclipse и / или Kinetis Design Studio ) и если вы не можете отлаживать, попробуйте удалить точки останова и выражения. По крайней мере, пока эта ошибка GDB не будет исправлена (я отправил отчет об ошибке).
Счастливого завершения ?