Author Topic: Re opning topic: Run bash script before remote debugging  (Read 390 times)

Offline usercb2017

  • Single posting newcomer
  • *
  • Posts: 5
Re opning topic: Run bash script before remote debugging
« on: April 26, 2017, 03:16:02 pm »
Hello guys,

i create this post 'cause i need to copy my binaries to a remote target device (i'm running C::B on windows)and also launch gdbserver from the host.

I tried all the suggestions posted in the following topic: http://forums.codeblocks.org/index.php?topic=19279.0 but, unfortunately, these didn't work for me. I'm on 16.01 CB.

Thanks in advance for your assistance.

MB

Offline BlueHazzard

  • Lives here!
  • ****
  • Posts: 1352
Re: Re opning topic: Run bash script before remote debugging
« Reply #1 on: April 26, 2017, 11:57:01 pm »
A simply won't work is not enough information...

Some logs? Some error descriptions? Some detailed description of what you are doing, what happens and what should happen?

Quote
i create this post 'cause i need to copy my binaries to a remote target device (i'm running C::B on windows)and also launch gdbserver from the host.
This sounds like your remote target is not a windows host? Some detailed description of the host, target? What connection are you planning to use?

[EDIT:] Sorry, i over read the title... Your question is to run a script before the debugger on the target? My questions above are still valid.
« Last Edit: April 26, 2017, 11:59:27 pm by BlueHazzard »

Offline usercb2017

  • Single posting newcomer
  • *
  • Posts: 5
Re: Re opning topic: Run bash script before remote debugging
« Reply #2 on: April 27, 2017, 01:02:33 pm »
Hello guys,

Sorry for my poor explanations....

@BlueHazzard:
=> my remote host is an embedded linux. I connect to it via SSH.

=> I would like to execute a script before the debugger started in order to copy my binary to the remote target, enable the rights on it and then launch gdbserver for this binary. is that clear enough?

Here is the procedure i followed:
- Configure the remote connection tab with target IP address and gdbserver port
- Enter some command lines on both "additionnal tab" (i did that for both cause i would like to identify when those commands will be executed). I simply populate the fields with a single "pscp command line describe below". For the "GDB" tab i used  shell before the command line.

Command line used : shell C:\cp\od\Putty\pscp.exe -scp -r -pw ....... "C:\Users\mbarril\Documents\Codeblocks project\test command linesw\bin\Debug" user@192.10.200.200:/home/user

Finally, i find out the root cause. it was due to the "$" in the password populated in the pscp command line. But i still have one question:

Could you please tell me when these tabs will execute the command lines populated in there?

Thank you in advance






Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2063
Re: Re opning topic: Run bash script before remote debugging
« Reply #3 on: April 27, 2017, 06:15:10 pm »
Additional GDB commands tab has two windows. "Before connection" and "After connection"
Commands in those windows are issued (as described) before or after a good connection to a gdb server.

Examples:
monitor reset
load

Commands in the "Additional Shells" tab also have two windows entitled Before connection and after connection. These command are wrapped by a "Shell " command and queued Before or after connection to the gdb server.
Example:
cmd /c start "GdbServer" "c:\usrPrograms\st-util.exe" -v

In setting/debugger/common, turn on full (debug) log.
You will then see when commands are issued in the Debugger log.
Look for the keyword "connected" in the log.

Example log:
Code: [Select]
Active debugger config: GDB/CDB debugger:Default
Building to ensure sources are up-to-date
Selecting target:
Debug
Adding source dir: C:\User\icc programs\iccv9cortex\CGnuExamples\ArmGnuPrj\
Adding source dir: C:\User\icc programs\iccv9cortex\CGnuExamples\ArmGnuPrj\
Adding file: C:\User\icc programs\iccv9cortex\CGnuExamples\ArmGnuPrj\bin\Debug\ArmGnuPrj.elf
Changing directory to: C:/User/ICCPRO~1/ICCV9C~1/CGNUEX~1/ARMGNU~1/.
Set variable: PATH=.;c:\User\icc programs\iccv9cortex\lib;c:\User\icc programs\iccv9cortex\GnuArm\bin;c:\User\icc programs\iccv9cortex\GnuArm;c:\User\icc programs\iccv9cortex\GnuArm\lib\gcc\arm-none-eabi\6.3.1;C:\User\icc programs\iccv9cortex\GnuArm\lib\gcc\arm-none-eabi\6.3.1;C:\User\icc programs\iccv9cortex\GnuArm\arm-none-eabi\bin;c:\User\icc programs\iccv9cortex\GnuArm\arm-none-eabi\bin;C:\User\Programs\SubVersion\SubversionClient;C:\Program Files (x86)\Intel\iCLS Client;C:\Program Files\Intel\iCLS Client;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\usr\bin;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\Hewlett-Packard\HP Performance Advisor;C:\Program Files\Intel\WiFi\bin;C:\Program Files\Common Files\Intel\WirelessCommon;c:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files (x86)\AMD\ATI.ACE\Core-Static;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT

[debug]Command-line: C:\usr\MinGW492\bin\gdb.exe -nx -fullname -quiet  -args C:/User/ICCPRO~1/ICCV9C~1/CGNUEX~1/ARMGNU~1/bin/Debug/ARMGNU~1.ELF
[debug]Working dir : C:\User\ICCPRO~1\ICCV9C~1\CGNUEX~1\ARMGNU~1

Starting debugger: C:\usr\MinGW492\bin\gdb.exe -nx -fullname -quiet  -args
C:/User/ICCPRO~1/ICCV9C~1/CGNUEX~1/ARMGNU~1/bin/Debug/ARMGNU~1.ELF
done

[debug]> set prompt >>>>>>cb_gdb:

Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Connecting to remote target
Setting breakpoints

[debug]Reading symbols from C:\User\ICCPRO~1\ICCV9C~1\CGNUEX~1\ARMGNU~1\bin\Debug\ARMGNU~1.ELF...done.
[debug](gdb) >>>>>>cb_gdb:
[debug]> show version
[debug]GNU gdb (GDB) 7.6.1
[debug]Copyright (C) 2013 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.  Type "show copying"
[debug]and "show warranty" for details.
[debug]This GDB was configured as "mingw32".
[debug]For bug reporting instructions, please see:
[debug]<http://www.gnu.org/software/gdb/bugs/>.
[debug]>>>>>>cb_gdb:
[debug]> set confirm off

Debugger name and version: GNU gdb (GDB) 7.6.1

[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 0
[debug]>>>>>>cb_gdb:
[debug]> set new-console on
[debug]>>>>>>cb_gdb:
[debug]> set disassembly-flavor att
[debug]>>>>>>cb_gdb:
[debug]> catch throw
[debug]Function "__cxa_throw" not defined.
[debug]Catchpoint 1 (throw)
[debug]>>>>>>cb_gdb:
[debug]> source c:\User\icc programs\iccv9cortex\bin\ImageCraftCB\share\codeblocks/scripts/stl-views-1.0.3.gdb
[debug]>>>>>>cb_gdb:
[debug]> directory C:/User/ICCPRO~1/ICCV9C~1/CGNUEX~1/ARMGNU~1/
[debug]Source directories searched: C:/User/ICCPRO~1/ICCV9C~1/CGNUEX~1/ARMGNU~1;$cdir;$cwd
[debug]>>>>>>cb_gdb:
[debug]> shell cmd /c start "STLink Gdb Server" "c:\User\icc programs\iccv9cortex\STUtilCyg\st-util.exe"
[debug]>>>>>>cb_gdb:
[debug]> target remote tcp:localhost:4242
[debug]Remote debugging using tcp:localhost:4242
[debug]0x00000000 in ?? ()
[debug]>>>>>>cb_gdb:

Connected

[debug]> monitor reset

In ?? () ()

[debug]> monitor reset
[debug]>>>>>>cb_gdb:>>>>>>cb_gdb:
[debug]> load
[debug]Loading section .text, size 0x274 lma 0x8000000
[debug]Loading section .data, size 0x43c lma 0x800046e
[debug]Start address 0x80000b1, load size 1712
[debug]Transfer rate: 3 KB/sec, 856 bytes/write.
[debug]>>>>>>cb_gdb:
[debug]> break "C:/User/icc programs/iccv9cortex/CGnuExamples/ArmGnuPrj/Src/main.c:28"
[debug]Breakpoint 2 at 0x8000122: file C:\User\icc programs\iccv9cortex\CGnuExamples\ArmGnuPrj\Src\main.c, line 28.
[debug]>>>>>>cb_gdb:
[debug]> continue
[debug]Continuing.
[debug]Note: automatically using hardware breakpoints for read-only addresses.
[debug]Program received signal SIGTRAP, Trace/breakpoint trap.
[debug]0x080000b1 in Reset_Handler () at C:\User\icc programs\iccv9cortex\CGnuExamples\ArmGnuPrj\Setup\startup.S:86
[debug]C:\User\icc programs\iccv9cortex\CGnuExamples\ArmGnuPrj\Setup\startup.S:86:3985:beg:0x80000b1
[debug]>>>>>>cb_gdb:

Program received signal SIGTRAP, Trace/breakpoint trap.
At C:\User\icc programs\iccv9cortex\CGnuExamples\ArmGnuPrj\Setup\startup.S:86

[debug]> bt 30
[debug]#0  0x080000b1 in Reset_Handler () at C:\User\icc programs\iccv9cortex\CGnuExamples\ArmGnuPrj\Setup\startup.S:86
[debug]>>>>>>cb_gdb:



« Last Edit: April 27, 2017, 06:20:20 pm by Pecan »