question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add ability to change localhost when starting gdb

See original GitHub issue

Is there a way to change how to connect to the remote when starting gdb? To not always use localhost. I can’t find any setting for this. I thought that preLaunchCommands or overrideLaunchCommands would do it but it seems the three first commands are hardcoded. I found several references to target-select extended-remote localhost in debugadapter.js and extension.js. I tried changing these to the IP-adress I wanted and then I got it working as I wanted.

Reading symbols from 'xyz.elf'
Finished reading symbols
Please check OUTPUT tab (Adapter Output) for output from /mnt/c/Program Files (x86)/SEGGER/JLink/JLinkGDBServerCL.exe
Launching server: "/mnt/c/Program Files (x86)/SEGGER/JLink/JLinkGDBServerCL.exe" "-if" "swd" "-port" "50000" "-swoport" "50001" "-telnetport" "50002" "-device" "LPC1768" "-nolocalhostonly"
Launching GDB: "/gcc/gcc-arm-none-eabi-9-2019-q4-major/bin/arm-none-eabi-gdb" "-q" "--interpreter=mi2"
1-gdb-set target-async on
2-interpreter-exec console "source /home/user/.vscode-server/extensions/marus25.cortex-debug-0.3.12/support/gdbsupport.init"
3-target-select extended-remote localhost:50000

Some background information: I am using WSL2 on windows 10 as my primary development environment where i use a cross-compiler in a docker container. Since I’m doing this all the paths in the elf file will be relative to the linux system. Since WSL2 doesn’t support USB forwarding i want to run the gdbserver in Windows and gdb in Linux. Therefore I want to change localhost:port since localhost in Linux won’t point to the localhost in Windows that gdbserver is listening to. VS code is run as a remote in WSL2 with VS code Server making it think that it is running in Linux. Therefore I can’t run both gdbserver and gdb in Windows since then gdb mi2 interpreter will spit out paths in the form of //$wsl/some_path which doesn’t make sense under Linux.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:5
  • Comments:25 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
haneefdmcommented, May 21, 2021

Yea @RisinT96 , I know, the thought of doing this makes me shudder. I feel bad about doing such a port-scan and MS may plug that hole anytime

0reactions
haneefdmcommented, Jun 17, 2022

I am closing this as USB ports work better with WSL2 and for JLink, there are other options like using their server software

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do you start running the program over again in gdb with ...
When you're running gdb on an embedded system, as with the command target localhost:3210 , how do you start the program over again...
Read more >
Server (Debugging with GDB) - sourceware.org
During a GDB session using gdbserver , you can use the monitor command to send special requests to gdbserver . Here are the...
Read more >
Debugging with gdb - Debugging remote programs
Connecting to a remote target​​ Start up GDB as usual, using the name of the local copy of your program as the first...
Read more >
Server - Debugging with GDB
During a gdb session using gdbserver , you can use the monitor command to send special requests to gdbserver . Here are the...
Read more >
Debugging with GDB - Server
communicates via a TCP connection to port 2345 on host `the-target'. For TCP connections, you must start up gdbserver prior to using the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found