31i73 / atom-dbg

An Atom package - An interactive debugger frontend
https://atom.io/packages/dbg
MIT License
30 stars 4 forks source link

Connection to a remote target #1

Closed mikoff closed 7 years ago

mikoff commented 7 years ago

Hello! First of all - thank you for new package, which is going to be universal and enough powerful to debug any target from atom editor. And a short question - do you have any plans on adding the remote target debugging feature? Thanks!

ProPuke commented 7 years ago

Hi. Thanks.

It's not something I'm familiar with or use myself, so it's not likely to be a priority for me to add. (I'm more likely to work on multithreading, conditional breakpoints, and better integrations first).

But if anyone else wants to help and add it I would be very grateful :]

dm-blue commented 7 years ago

For remote debugging we need to use a cross-platform debugger (so, a configurable path to that debugger is needed) and a command file to configure the target parameters (which can be provided using debugger arguments, eg. '-command=file' or '-x file' arguments for gdb). A solution is to add new options in the .atom-dbg.json file, to also configure the debugger path and arguments, not only the target file path and arguments.

ProPuke commented 7 years ago

Hi I've added 3 new parameters to the new version of dbg-gdb, listed in the readme, for specifying a custom gdb path, custom arguments, and custom commands to be executed before -exec-run; Which can be included in your .atom-dbg.* config file.

Hopefully this is a good start, or a usable solution for now.

dm-blue commented 7 years ago

It works fine, so far. This is a good solution, thank you very much !

dotevo commented 7 years ago

Hi. Im trying to setup dbg gdb. When I run gdb from console everything works fine:

$ arm-none-eabi-gdb GNU gdb (GNU Tools for ARM Embedded Processors) 7.10.1.20160923-cvs Copyright (C) 2015 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=i686-w64-mingw32 --target=arm-none-eabi". 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". (gdb) target remote localhost:2331 Remote debugging using localhost:2331 0x00026654 in ?? () (gdb)

client: debugger: 'dbg-gdb' gdb_executable: 'arm-none-eabi-gdb' gdb_commands: ['target remote localhost:2331']

What is wrong with my config file?

dotevo commented 7 years ago

Ok... I was digging into source code and I\ve not found place where commands are send. So I\ve added a few lines.

                else
                    if line!='(gdb)' and line!='(gdb) '
                        if @logToConsole then console.log 'dbg-gdb < ',line
                        if @outputPanel
                            if !outputRevealed
                                outputRevealed = true
                                @outputPanel.show()
                            @outputPanel.print line
                    else
                        for ep in options.gdb_commands
                            @sendCommand ep
                            console.log ep
dm-blue commented 7 years ago

No, you only need add whole path to the debugger, not only the debugger name ( ex: gdf_executable: '/opt/toolchain/.../bin/arm-none-eabi-gdb' ). You can use it without path only if the debugger is available in the atom's search path too, otherwise... You may try o start the atom from console, not from the desktop icon.

dotevo commented 7 years ago

I have debugger in the PATH. But there is something wrong with commands. After my change (prev. comment) gdb server said that are more then one gdb client connected, and I had a lot of disconnects and connects.

ProPuke commented 7 years ago

No need to modify the source to log things. There's a setting in dbg-gdb's package settings for enabling debug console logging (Preferences > Packages > dbg-gdb > ☑ Log to developer console)

Once enabled you'll see all the commands and responses from gdb in the developer console.

dotevo commented 7 years ago

has bug been fixed? I'm not sure that I can update to your version.

ProPuke commented 7 years ago

This thread was for a feature request, which was added before your query.

It's unknown if your issue is local or a dbg issue, yet. Are you able to paste a copy of your logs from the developer console? So I can investigate?

dotevo commented 7 years ago

I'm sorry. Bug is in dbg-gdb package or my configuration. Not atom-dbg.

Usual GDB output:

$ gdb
GNU gdb (GNU Tools for ARM Embedded Processors) 7.10.1.20160923-cvs
Copyright (C) 2015 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=i686-w64-mingw32 --target=arm-none-eabi".
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".
(gdb) target remote localhost:2331
Remote debugging using localhost:2331
0x00012476 in ?? ()
(gdb)

Package is not sending command to GDB.

But if I've added sending command (a few post upper):

else
  for ep in options.gdb_commands
    @sendCommand ep

Some how was working. But I had many connects and disconnects in gdb server. main.coffee 253-259

If you want I can try to fix that.

ProPuke commented 7 years ago

I need to see the event log from dbg-gdb to see what's actually going on.

  1. Disable your code changes
  2. Enable Preferences > Packages > dbg-gdb > ☑ Log to developer console
  3. Attempt to debug
  4. Select View > Developer > Toggle Developer Tools
  5. Navigate to the Console
  6. Paste the contents here
dotevo commented 7 years ago
spell-check:en-us Can't load en_US: Cannot find dictionary for en_US.

Uncaught (in promise) TypeError: Path must be a string. Received undefined(…)
assertPath  @   path.js:7
resolve @   path.js:184
debug   @   main.coffee:138
debugWithDebugger   @   main.coffee:364
(anonymous function)    @   main.coffee:217
debug   @   main.coffee:204
module.exports.ConfigList.confirmed @   ConfigList.coffee:36
module.exports.SelectListView.confirmSelection  @   C:\Users\jordanea\.atom\packages\dbg\node_modules\atom-space-pen-views\lib\select-list-view.js:338
atom.commands.add.core:confirm  @   C:\Users\jordanea\.atom\packages\dbg\node_modules\atom-space-pen-views\lib\select-list-view.js:109
module.exports.CommandRegistry.handleCommandEvent   @   command-registry.coffee:255
(anonymous function)    @   command-registry.coffee:1
module.exports.KeymapManager.dispatchCommandEvent   @   C:\Users\jordanea\AppData\Local\atom\app-1.16.0\resources\app.asar\node_modules\atom-keymap\lib\key…:599
module.exports.KeymapManager.handleKeyboardEvent    @   C:\Users\jordanea\AppData\Local\atom\app-1.16.0\resources\app.asar\node_modules\atom-keymap\lib\key…:390
module.exports.WindowEventHandler.handleDocumentKeyEvent    @   window-event-handler.coffee:76
(anonymous function)    @   window-event-handler.coffee:1

dbg-gdb <  = thread-group-added Object
Uncaught (in promise) TypeError: Path must be a string. Received undefined(…)
dbg-gdb <  = thread-group-added Object {id: "i1"}id: "i1"__proto__: Object

client: debugger: 'dbg-gdb' gdb_executable: 'arm-none-eabi-gdb' cwd: 'C:\XXXYYYY' basedir: 'C:\XXXYYY' gdb_commands: ['target remote localhost:2331']

ProPuke commented 7 years ago

Okay, the problem is that currently dbg-gdb expects there to always be a path parameter, as it attempts to run -file-exec-and-symbols PATH before executing custom commands. It's missing, so breaking in a bad way.

I should have noticed that missing in the config file >.>

I hadn't thought about this not being necessary with remote debugs.

I'll get this fixed, thanks.

dotevo commented 7 years ago

:+1: No problem. But I think that is more issues here. But when you fix that we can go to commands :-)

ProPuke commented 7 years ago

Hi @dotevo (and anyone else following remote target support)

I've pushed live an update to fix the issue reported. The path parameter is now optional and breakpoint commands aren't sent to gdb until after it's executed any custom commands specified; So remote debugging should hopefully be better now (although, admittedly, this isn't something I have experience with or can test, myself).

Can you let me know if it's okay now? Cheers

dotevo commented 7 years ago

I think that is working fine. I didn't have any problems. There is one error log but I think that not affect on gdb:

dbg-gdb < ^ error Object {msg: "The "remote" target does not support "run". Try "help target" or "continue"."

Thank you

ProPuke commented 7 years ago

Nice, good to hear!

Yeah, that error's fine. It attempts to run first, then if the target doesn't support it, defaults to continue. You might also see an error about mi-async. This is also fine.

Cheers.

mirage335 commented 6 years ago

Receiving same (path must be a string) error, even with latest version of atom-dbg and atom-dbg-gdb imported from git repository.

Attempting to integrate Atom with Arduino as a more functional IDE, wrapped by sophisticated shell scripts. https://github.com/mirage335/arduinoUbiquitous/blob/master/_lib/Blink/.atom-dbg.cson

"Arduino Firmware":
    gdb_executable: "_gdb"

Please assist!

EDIT: Thanks to ProPuke. Solution was to specify debugger: "dbg-gdb" . Next problem - 'Don't know how to run. Try "help target".' . Because my next problems are unrelated to this issue, I will take their discussion to a new issue.