Re: [Openocd-development] Bug: segfault when gdb-end and gdb-detach are defined and gdb killed
Øyvind Harboe ha scritto: 1. try to reproduce this using the dummy driver I tried to use it as described here: http://www.mail-archive.com/openocd-development@lists.berlios.de/msg06815.html but I can't issue the continue command when connecting with gdb. When I tried the dummy driver it gave errors: $ ~/src/openocd-0.2.0/src/openocd -f dummy.cfg -f openocd-0.2.0_at91sam7_gdb.cfg $URL: http://svn.berlios.de/svnroot/repos/openocd/tags/openocd-0.2.0/src/openocd.c $ For bug reports, read http://svn.berlios.de/svnroot/repos/openocd/trunk/BUGS Warn : Interface already configured, ignoring Unknown command: ft2232_device_desc {Amontec JTAGkey} So I commented the interface section in my configuration file; however it seems there's something wrong with my configuration. Command line was: $ ~/src/openocd-0.2.0/src/openocd -f dummy.cfg -f openocd-0.2.0_at91sam7_gdb.cfg Log is: Open On-Chip Debugger 0.2.0 (2009-07-27-14:00) Release $URL: http://svn.berlios.de/svnroot/repos/openocd/tags/openocd-0.2.0/src/openocd.c $ For bug reports, read http://svn.berlios.de/svnroot/repos/openocd/trunk/BUGS Warn : Tap/Device does not have IDCODE Error: JTAG tap: sam7.cpu got: 0x (mfg: 0x000, part: 0x, ver: 0x0) Error: JTAG tap: sam7.cpu expected 1 of 1: 0x3f0f0f0f (mfg: 0x787, part: 0xf0f0, ver: 0x3) Error: trying to validate configured JTAG chain anyway... Error: Could not validate JTAG scan chain, IR mismatch, scan returned 0x3F. tap=sam7.cpu pos=0 expected 0x1 got 3 Warn : Could not validate JTAG chain, continuing anyway... Error: unknown EmbeddedICE version (comms ctrl: 0x) target state: halted target halted in Thumb state due to watchpoint, current mode: System cpsr: 0x pc: 0xffef Info : accepting 'gdb' connection from 0 Warn : acknowledgment received, but no packet pending Error: Target autodetection failed! Please specify target parameters in configuration file Error: auto_probe failed -902 **EVENT: gdb-end **EVENT: gdb-end 2. see if you can get a stack trace: In the attachment you will find both the output with -d 3 and the backtrace, as well as my configuration file (the only one I'm using). Best regards, -- Ing. Luca Ottaviano - lottavi...@develer.com Develer S.r.l. - http://www.develer.com/ .hardware . software .innovation Tel.: +39 055 3986627 - ext.: 218 Starting program: /home/lottaviano/src/openocd-0.2.0/src/openocd -f openocd-0.2.0_at91sam7_gdb.cfg -d 3 Open On-Chip Debugger 0.2.0 (2009-07-27-14:00) Release $URL: http://svn.berlios.de/svnroot/repos/openocd/tags/openocd-0.2.0/src/openocd.c $ For bug reports, read http://svn.berlios.de/svnroot/repos/openocd/trunk/BUGS User : 5 0 command.c:396 command_print(): debug_level: 3 Debug: 6 3 configuration.c:83 find_file(): found openocd-0.2.0_at91sam7_gdb.cfg Debug: 8 4 command.c:68 script_debug(): command - telnet_port Debug: 9 4 command.c:77 script_debug(): telnet_port - argv[0]=ocd_telnet_port Debug: 10 4 command.c:77 script_debug(): telnet_port - argv[1]= Debug: 12 4 command.c:68 script_debug(): command - tcl_port Debug: 13 4 command.c:77 script_debug(): tcl_port - argv[0]=ocd_tcl_port Debug: 14 4 command.c:77 script_debug(): tcl_port - argv[1]= Debug: 16 4 command.c:68 script_debug(): command - gdb_port Debug: 17 4 command.c:77 script_debug(): gdb_port - argv[0]=ocd_gdb_port Debug: 18 4 command.c:77 script_debug(): gdb_port - argv[1]= Debug: 20 4 command.c:68 script_debug(): command - gdb_memory_map Debug: 21 4 command.c:77 script_debug(): gdb_memory_map - argv[0]=ocd_gdb_memory_map Debug: 22 4 command.c:77 script_debug(): gdb_memory_map - argv[1]=enable Debug: 24 4 command.c:68 script_debug(): command - interface Debug: 25 4 command.c:77 script_debug(): interface - argv[0]=ocd_interface Debug: 26 4 command.c:77 script_debug(): interface - argv[1]=ft2232 Debug: 28 5 command.c:68 script_debug(): command - ft2232_device_desc Debug: 29 5 command.c:77 script_debug(): ft2232_device_desc - argv[0]=ocd_ft2232_device_desc Debug: 30 5 command.c:77 script_debug(): ft2232_device_desc - argv[1]=Amontec JTAGkey Debug: 32 5 command.c:68 script_debug(): command - ft2232_layout Debug: 33 5 command.c:77 script_debug(): ft2232_layout - argv[0]=ocd_ft2232_layout Debug: 34 5 command.c:77 script_debug(): ft2232_layout - argv[1]=jtagkey Debug: 36 5 command.c:68 script_debug(): command - ft2232_vid_pid Debug: 37 5 command.c:77 script_debug(): ft2232_vid_pid - argv[0]=ocd_ft2232_vid_pid Debug: 38 5 command.c:77 script_debug(): ft2232_vid_pid - argv[1]=0x0403 Debug: 39 5 command.c:77 script_debug(): ft2232_vid_pid - argv[2]=0xcff8 Debug: 41 5 command.c:68 script_debug(): command - reset_config Debug: 42 5 command.c:77 script_debug(): reset_config - argv[0]=ocd_reset_config Debug: 43 5 command.c:77 script_debug(): reset_config - argv[1]=srst_only Debug: 44 5 command.c:77 script_debug(): reset_config - argv[2]=srst_pulls_trst Debug: 45 5 tcl.c:237 jim_newtap_cmd(): Creating New Tap, Chip: sam7, Tap: cpu,
Re: [Openocd-development] Bug: segfault when gdb-end and gdb-detach are defined and gdb killed
Nice work on debug report. How's the attached patch? I've updated the BUGS document to encourage reports to try to reproduce crashes w/dummy interface... -- Øyvind Harboe Embedded software and hardware consulting services http://www.zylin.com ### Eclipse Workspace Patch 1.0 #P openocd Index: src/server/gdb_server.c === --- src/server/gdb_server.c (revision 2561) +++ src/server/gdb_server.c (working copy) @@ -816,6 +816,11 @@ gdb_service_t *gdb_service = connection-service-priv; gdb_connection_t *gdb_connection = connection-priv; + /* we're done forwarding messages. Tear down callback before +* cleaning up connection. +*/ + log_remove_callback(gdb_log_callback, connection); + gdb_actual_connections--; LOG_DEBUG(GDB Close, Target: %s, state: %s, gdb_actual_connections=%d, gdb_service-target-cmd_name, @@ -843,9 +848,10 @@ LOG_ERROR(BUG: connection-priv == NULL); } + target_unregister_event_callback(gdb_target_callback_event_handler, connection); + target_call_event_callbacks(gdb_service-target, TARGET_EVENT_GDB_END); - log_remove_callback(gdb_log_callback, connection); target_call_event_callbacks(gdb_service-target, TARGET_EVENT_GDB_DETACH); ___ Openocd-development mailing list Openocd-development@lists.berlios.de https://lists.berlios.de/mailman/listinfo/openocd-development
Re: [Openocd-development] Bug: segfault when gdb-end and gdb-detach are defined and gdb killed
Øyvind Harboe ha scritto: Nice work on debug report. How's the attached patch? It fixes the problem. Thanks! -- Ing. Luca Ottaviano - lottavi...@develer.com Develer S.r.l. - http://www.develer.com/ .hardware . software .innovation Tel.: +39 055 3986627 - ext.: 218 ___ Openocd-development mailing list Openocd-development@lists.berlios.de https://lists.berlios.de/mailman/listinfo/openocd-development
Re: [Openocd-development] Bug: segfault when gdb-end and gdb-detach are defined and gdb killed
Committed. -- Øyvind Harboe Embedded software and hardware consulting services http://www.zylin.com ___ Openocd-development mailing list Openocd-development@lists.berlios.de https://lists.berlios.de/mailman/listinfo/openocd-development
[Openocd-development] Bug: segfault when gdb-end and gdb-detach are defined and gdb killed
Hi developers, I've found a bug in src/server/gdb_server.c:2005, function gdb_log_callback(). A pointer is used without checking if it's still valid. This is 100% when using GDB to debug a remote target: 1. start openocd to listen for incoming gdb connection 2. setup gdb so that it connects to openocd and let it continue its execution if the target is halted; 3. from another console kill the GDB process. 4. openocd will segfault in the line above. Tested with version 0.2 but I verified that no commit touched that part after the official release. Attaching configuration file. Note that I've added both gdb-end and gdb-detach events; if I remove gdb-end (which in my case it's not what I'm looking for, btw :) Openocd shuts down cleanly. Feel free to contact me if you need further information. Best regards. -- Ing. Luca Ottaviano - lottavi...@develer.com Develer S.r.l. - http://www.develer.com/ .hardware . software .innovation Tel.: +39 055 3986627 - ext.: 218 # Change the default telnet port... telnet_port # Port for TCL connection. tcl_port # GDB connects here gdb_port gdb_memory_map enable interface ft2232 ft2232_device_desc Amontec JTAGkey ft2232_layout jtagkey ft2232_vid_pid 0x0403 0xcff8 #use combined on interfaces or targets that can't set TRST/SRST separately reset_config srst_only srst_pulls_trst if { [info exists CHIPNAME] } { set _CHIPNAME $CHIPNAME } else { set _CHIPNAME sam7 } if { [info exists ENDIAN] } { set _ENDIAN $ENDIAN } else { set _ENDIAN little } if { [info exists CPUTAPID ] } { set _CPUTAPID $CPUTAPID } else { set _CPUTAPID 0x3f0f0f0f } jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID set _TARGETNAME [format %s.cpu $_CHIPNAME] target create $_TARGETNAME arm7tdmi -endian $_ENDIAN -chain-position $_TARGETNAME -variant arm7tdmi $_TARGETNAME configure -event reset-start { # disable watchdog mww 0xfd44 0x8000 # enable user reset mww 0xfd08 0xa501 # CKGR_MOR : enable the main oscillator mww 0xfc20 0x0601 sleep 10 # CKGR_PLLR: 96.1097 MHz mww 0xfc2c 0x00481c0e sleep 10 # PMC_MCKR : MCK = PLL / 2 ~= 48 MHz mww 0xfc30 0x0007 sleep 10 # MC_FMR: flash mode (FWS=1,FMCN=60) mww 0xff60 0x003c0100 sleep 10 # reset PC reg pc } $_TARGETNAME configure -event gdb-end { echo **EVENT: gdb-end } $_TARGETNAME configure -event gdb-detach { echo **EVENT: gdb-detach } $_TARGETNAME configure -work-area-virt 0 -work-area-phys 0x0020 -work-area-size 0x4000 -work-area-backup 0 #flash bank driver base size chip_width bus_width flash bank at91sam7 0 0 0 0 0 ___ Openocd-development mailing list Openocd-development@lists.berlios.de https://lists.berlios.de/mailman/listinfo/openocd-development