User forums > Embedded development

Gdb work with openocd in pipe mode,but in C::B ,some message seems missing ?

<< < (2/4) > >>

BlueHazzard:
very strange...

If all executable are the same for cmd and codeblocks it should work...
Are you starting OpenOCD separately or trough codeblocks?

jjingwer:
@BlueHazzard

I use C::B   to  start  Gdb .  And start Openocd  through  Gdb.

I get the infomation form Openocd  user guide


--- Code: ---21.1 Connecting to GDB
Use GDB 6.7 or newer with OpenOCD if you run into trouble. For instance GDB 6.3 has a known bug that produces bogus memory access errors, which has since been fixed; see http://osdir.com/ml/gdb.bugs.discuss/2004-12/msg00018.html

OpenOCD can communicate with GDB in two ways:

A socket (TCP/IP) connection is typically started as follows:
target extended-remote localhost:3333
This would cause GDB to connect to the gdbserver on the local pc using port 3333.

The extended remote protocol is a super-set of the remote protocol and should be the preferred choice. More details are available in GDB documentation https://sourceware.org/gdb/onlinedocs/gdb/Connecting.html

To speed-up typing, any GDB command can be abbreviated, including the extended remote command above that becomes:

tar ext :3333
Note: If any backward compatibility issue requires using the old remote protocol in place of the extended remote one, the former protocol is still available through the command:

target remote localhost:3333

A pipe connection is typically started as follows:

target extended-remote | openocd -c "gdb_port pipe; log_output openocd.log"

This would cause GDB to run OpenOCD and communicate using pipes (stdin/stdout). Using this method has the advantage of GDB starting/stopping OpenOCD for the debug session. log_output sends the log output to a file to ensure that the pipe is not saturated when using higher debug level outputs.

To list the available OpenOCD commands type monitor help on the GDB command line.

--- End code ---

One way to connect Openocd is

--- Code: ---target remote localhost:3333

--- End code ---

The other is

--- Code: ---target extended-remote | openocd -c "gdb_port pipe; log_output openocd.log"

--- End code ---

I  used the second .

when in cmd or powershell ,  also  use cmd to start  Gdb and use gdb to start Openocd.


In fact , I  want to use the first way  , but  I can not   find plugins for  Openocd.

BlueHazzard:

--- Code: ---target extended-remote | openocd -c "gdb_port pipe; log_output openocd.log"
--- End code ---
So this line starts openocd from within gdb?
My guess is, that it starts the old version of openocd you still have in your path... Where do you have openocd installed? Where is your self build version of OpenOCD? Have you tried to use a full path to openocd in this command line?
Have you tried to start openocd from command line, and connect with codeblocks to it?
You can use processExplorer https://docs.microsoft.com/en-us/sysinternals/downloads/process-explorer to see the path from your executable if you hover the mouse over it. So start codebocks and your gdb setup, and look at the path of the started openocd

jjingwer:
@BlueHazzard

I  can  set path  for C::B and cmd  ,so   I am sure  it is  the same Gdb and Openocd .

Also  I  can  set path in Gdb to start Openocd.


--- Code: ---Active debugger config: GDB/CDB debugger:Default
Building to ensure sources are up-to-date
Selecting target:
Debug
Adding source dir: D:\FPGA\CB_Projs\123456\
Adding source dir: D:\FPGA\CB_Projs\123456\
Adding file: D:\FPGA\CB_Projs\123456\bin\Debug\123456.elf
Changing directory to: D:/FPGA/CB_Projs/123456/
Set variable: PATH=.;D:\FPGA\CODEBLOCKS-20200813\CODEBLOCKS\DSC\bin\riscv-tc-llvm\bin;D:\FPGA\CODEBLOCKS-20200813\CODEBLOCKS\DSC\bin;D:\FPGA\CODEBLOCKS-20200813\CODEBLOCKS\DSC;C:\Windows\System32;C:\Windows;D:\CodeBlocks\MinGW\bin;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Users\jim\AppData\Local\Microsoft\WindowsApps;D:\modeltech64_2019\win64;C:\Users\jim\AppData\Local\Programs\Microsoft VS Code\bin;\;D:\FPGA\CODEBLOCKS-20200813\CODEBLOCKS\DSC\bin\bin;D:\FPGA\CODEBLOCKS-20200813\CODEBLOCKS\DSC\bin\mingw-w64\bin;D:\FPGA\CODEBLOCKS-20200813\CODEBLOCKS\DSC\bin\riscv-tc-gcc\bin;D:\FPGA\CODEBLOCKS-20200813\CODEBLOCKS\DSC\bin\riscv-tc-gcc\riscv32-unknown-elf\bin;D:\FPGA\CODEBLOCKS-20200813\CODEBLOCKS\DSC\bin\riscv64-unknown-elf-gcc-8.2.0-2019.02.0\bin;D:\FPGA\CODEBLOCKS-20200813\CODEBLOCKS\DSC\bin\riscv64-unknown-elf-gcc-8.2.0-2019.02.0\riscv64-unknown-elf\bin;D:\FPGA\CODEBLOCKS-20200813\CODEBLOCKS\tools\openocd;D:\FPGA\CODEBLOCKS-20200813\CODEBLOCKS\tools

[debug]Command-line: D:\FPGA\CODEBLOCKS-20200813\CODEBLOCKS\DSC\bin\riscv64-unknown-elf-gcc-8.2.0-2019.02.0\bin\riscv64-unknown-elf-gdb.exe -nx -fullname -quiet  -args D:/FPGA/CB_Projs/123456/bin/Debug/123456.elf
[debug]Working dir : D:\FPGA\CB_Projs\123456

Starting debugger: D:\FPGA\CODEBLOCKS-20200813\CODEBLOCKS\DSC\bin\riscv64-unknown-elf-gcc-8.2.0-2019.02.0\bin\riscv64-unknown-elf-gdb.exe -nx -fullname -quiet  -args D:/FPGA/CB_Projs/123456/bin/Debug/123456.elf
done

[debug]D:\FPGA\CODEBLOCKS-20200813\CODEBLOCKS\DSC\bin\riscv64-unknown-elf-gcc-8.2.0-2019.02.0\bin\riscv64-unknown-elf-gdb.exe: warning: Couldn't determine a path for the index cache directory.
[debug]Reading symbols from D:/FPGA/CB_Projs/123456/bin/Debug/123456.elf...
[debug](gdb)
[debug]> set prompt >>>>>>cb_gdb:

Setting breakpoints

[debug]>>>>>>cb_gdb:
[debug]> show version
[debug]GNU gdb (GDB) 8.2.90.20190228-git
[debug]Copyright (C) 2019 Free Software Foundation, Inc.
[debug]License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
[debug]This is free software: you are free to change and redistribute it.
[debug]There is NO WARRANTY, to the extent permitted by law.
[debug]Type "show copying" and "show warranty" for details.
[debug]This GDB was configured as "--host=x86_64-w64-mingw32 --target=riscv64-unknown-elf".
[debug]Type "show configuration" for configuration details.
[debug]For bug reporting instructions, please see:
[debug]<http://www.gnu.org/software/gdb/bugs/>.
[debug]Find the GDB manual and other documentation resources online at:
[debug]    <http://www.gnu.org/software/gdb/documentation/>.
[debug]For help, type "help".
[debug]Type "apropos word" to search for commands related to "word".
[debug]>>>>>>cb_gdb:
[debug]> set confirm off

Debugger name and version: GNU gdb (GDB) 8.2.90.20190228-git

[debug]>>>>>>cb_gdb:
[debug]> set width 0
[debug]>>>>>>cb_gdb:
[debug]> set height 0
[debug]>>>>>>cb_gdb:
[debug]> set breakpoint pending on
[debug]>>>>>>cb_gdb:
[debug]> set print asm-demangle on
[debug]>>>>>>cb_gdb:
[debug]> set unwindonsignal on
[debug]>>>>>>cb_gdb:
[debug]> set print elements 200
[debug]>>>>>>cb_gdb:
[debug]> set disassembly-flavor att
[debug]No symbol "disassembly" in current context.
[debug]>>>>>>cb_gdb:
[debug]> catch throw
[debug]Catchpoint 1 (throw)
[debug]>>>>>>cb_gdb:
[debug]> directory D:/FPGA/CB_Projs/123456/
[debug]Source directories searched: D:/FPGA/CB_Projs/123456;$cdir;$cwd
[debug]>>>>>>cb_gdb:
[debug]> target extended-remote | D:\\FPGA\\CODEBLOCKS-20200813\\CODEBLOCKS\\tools\\openocd\\openocd -c "gdb_port pipe"  -f   D:\\FPGA\\CODEBLOCKS-20200813\\CODEBLOCKS\\tools\\openocd\\openocd_test.cfg  -c "log_output openocd.log"
[debug]Open On-Chip Debugger 0.10.0+dev-00923-g9e6a7a2e5-dirty (2020-09-27-13:35)
[debug]Licensed under GNU GPL v2
[debug]For bug reports, read
[debug] http://openocd.org/doc/doxygen/bugs.html
[debug]Info : OpenOCD will shutdown when debugger closed connection
[debug]Info : J-Link V9 compiled Oct 25 2018 11:46:07
[debug]Remote debugging using | D:\\FPGA\\CODEBLOCKS-20200813\\CODEBLOCKS\\tools\\openocd\\openocd -c "gdb_port pipe"  -f   D:\\FPGA\\CODEBLOCKS-20200813\\CODEBLOCKS\\tools\\openocd\\openocd_test.cfg  -c "log_output openocd.log"
[debug]Info : Hardware version: 9.20
[debug]Info : VTarget = 3.283 V
[debug]Info : clock speed 1000 kHz
[debug]Info : JTAG tap: riscv.cpu tap/device found: 0x00007c03 (mfg: 0x601 (<unknown>), part: 0x0007, ver: 0x0)
[debug]Info : datacount=2 progbufsize=8
[debug]Info : Examined RISC-V core; found 1 harts
[debug]Info :  hart 0: XLEN=32, misa=0x40001104
[debug]Remote replied unexpectedly to 'vMustReplyEmpty': PacketSize=4000;qXfer:memory-map:read+;qXfer:features:read+;qXfer:threads:read+;QStartNoAckMode+;vContSupported+
[debug]>>>>>>cb_gdb:
[debug]> load
[debug]You can't do that when your target is `exec'
[debug]>>>>>>cb_gdb:
[debug]> b main
[debug]Breakpoint 2 at 0x12356: file main.c, line 52.
[debug]>>>>>>cb_gdb:
[debug]> run
[debug]Don't know how to run.  Try "help target".
[debug]>>>>>>cb_gdb:

Starting the debuggee failed: Don't know how to run.  Try "help target".

[debug]> quit

Debugger finished with status 0


--- End code ---

like this:

--- Code: ---[debug]Remote debugging using | D:\\FPGA\\CODEBLOCKS-20200813\\CODEBLOCKS\\tools\\openocd\\openocd -c "gdb_port pipe"  -f   D:\\FPGA\\CODEBLOCKS-20200813\\CODEBLOCKS\\tools\\openocd\\openocd_test.cfg  -c "log_output openocd.log"

--- End code ---

Also in powershell:

--- Code: ---PS D:\FPGA\CODEBLOCKS-20200813\CODEBLOCKS> riscv64-unknown-elf-gdb.exe .\123456.elf
D:\FPGA\CODEBLOCKS-20200813\CODEBLOCKS\DSC\bin\riscv64-unknown-elf-gcc-8.2.0-2019.02.0\bin\riscv64-unknown-elf-gdb.exe: warning: Couldn't determine a path for the index cache directory.
GNU gdb (GDB) 8.2.90.20190228-git
Copyright (C) 2019 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=x86_64-w64-mingw32 --target=riscv64-unknown-elf".
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 .\123456.elf...
<-f   D:\\FPGA\\CODEBLOCKS-20200813\\CODEBLOCKS\\tools\\openocd\\openocd_test.cfg  -c "log_output openocd.log"
Remote debugging using | D:\\FPGA\\CODEBLOCKS-20200813\\CODEBLOCKS\\tools\\openocd\\openocd -c "gdb_port pipe"  -f   D:\\FPGA\\CODEBLOCKS-20200813\\CODEBLOCKS\\tools\\openocd\\openocd_test.cfg  -c "log_output openocd.log"
Open On-Chip Debugger 0.10.0+dev-00923-g9e6a7a2e5-dirty (2020-09-27-13:35)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Info : OpenOCD will shutdown when debugger closed connection
Info : J-Link V9 compiled Oct 25 2018 11:46:07
Info : Hardware version: 9.20
Info : VTarget = 3.280 V
Info : clock speed 1000 kHz
Info : JTAG tap: riscv.cpu tap/device found: 0x00007c03 (mfg: 0x601 (<unknown>), part: 0x0007, ver: 0x0)
Info : datacount=2 progbufsize=8
Info : Examined RISC-V core; found 1 harts
Info :  hart 0: XLEN=32, misa=0x40001104
0x007fc026 in ?? ()
(gdb) load
Loading section .PieCtrlRegs, size 0x80 lma 0x1900
Loading section .PieVectTable, size 0x1c0 lma 0x1a00
Loading section .GpioCtrlRegs, size 0x38 lma 0xd800
Loading section .GpioDataRegs, size 0x30 lma 0xd838
Loading section .GpioIntRegs, size 0x10 lma 0xd868
Loading section .text.init, size 0x128 lma 0x12000
Loading section .text, size 0x64c lma 0x12128
Start address 0x12000, load size 2604
Transfer rate: 12 KB/sec, 372 bytes/write.
(gdb)



--- End code ---

Same path:

--- Code: ---Reading symbols from .\123456.elf...
<-f   D:\\FPGA\\CODEBLOCKS-20200813\\CODEBLOCKS\\tools\\openocd\\openocd_test.cfg  -c "log_output openocd.log"
Remote debugging using | D:\\FPGA\\CODEBLOCKS-20200813\\CODEBLOCKS\\tools\\openocd\\openocd -c "gdb_port pipe"  -f   D:\\FPGA\\CODEBLOCKS-20200813\\CODEBLOCKS\\tools\\openocd\\openocd_test.cfg  -c "log_output openocd.log"

--- End code ---

stahta01:
An almost debugger newbie, but, are you sure you are running the same "123456.elf" because it looks like you have different working folders being shown.

Tim S.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version