Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to debug embedded remote targets using arm-none-eabi-gdb on Windows (path issues) #706

Open
gojimmypi opened this issue May 10, 2017 · 3 comments
Assignees

Comments

@gojimmypi
Copy link

gojimmypi commented May 10, 2017

This is very similar to issue #328 however the problems I am experiencing are on Windows.

I am using the Atmel Studio 7 arm-none-eabi-gdb.exe found in my:

C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\arm\arm-gnu-toolchain\bin

However I believe there's a problem with spaces in the path, as even when escaping the path like this:

"miDebuggerPath": "C:\\Program Files (x86)\\Atmel\\Studio\\7.0\\toolchain\\arm\\arm-gnu-toolchain\\binarm-none-eabi-gdb.exe",

I will receive an error:

Unable to start debugging. The value of miDebuggerPath is invalid

So I moved the exe to my project path:

"miDebuggerPath": "C:\\workspace\\opendps\\opendps\\arm-none-eabi-gdb.exe",

I used the sample launch.json in issue #328 as a template and created this one:

{
    "version": "0.2.0",
    "configurations": [

        {
            "name": "Debug",
            "type": "cppdbg",
            "request": "launch",
            "miDebuggerPath": "C:\\workspace\\opendps\\opendps\\arm-none-eabi-gdb.exe",
            "targetArchitecture": "arm",
            "program": "C:\\workspace\\opendps\\opendps\\opendps.elf",

            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
            {
                "text": "file 'C:\\workspace\\opendps\\opendps\\opendps.elf'"
            },
            {
                "text": "target remote 192.168.8.130:3333"
            },
            {
                "text": "monitor reset init"
            }
                
            ],
            "externalConsole": false,
            "cwd": "C:\\workspace\\opendps\\opendps\\"
            }
    ]
}

Notice I have OpenOCD running on a Ubuntu VM (in VMWare not WSL)... when debugging with F5 with the above VSCode returns this error:

Unable to start debugging. Unexpected GDB output from command "-interpreter-exec console "file 'C:\\workspace\\opendps\\opendps\\opendps.elf'"". C:workspaceopendpsopend...

Note how the path is mashed without slash delimiters at the end of the error. No additional information is available. Debug window is blank. See attached.

vscodegdb_error

for reference, I am using the code found here: https://github.com/kanflo/opendps and I otherwise have the Ubuntu version of arm-none-eabi-gdb debugging properly with the given elf file from within the VM. I am also able to use the Atmel Studio arm-none-eabi-gdb.exe from within a DOS window to connect to the OpenOCD server and debug successfully. So the problem seems to be specific to VSCode.

edit: The Windows / Atmel Studioarm-none-eabi-gdb.exe --versionreturns:

GNU gdb (Atmel build: 487) 7.10.1.20160210-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".

edit 2: it seems that if windows paths are instead entered using forward slashes, instead of escaped backslashes, the error does not occur, even with spaces in the path:

"miDebuggerPath": "C:/Program Files (x86)/Atmel/Studio/7.0/toolchain/arm/arm-gnu-toolchain/bin/arm-none-eabi-gdb.exe",

I'm not sure if this is as intended so I will not close this issue at this time. The docs here:

https://code.visualstudio.com/docs/languages/cpp#_debugging
and
https://github.com/Microsoft/vscode-cpptools/blob/master/launch.md

seem to indicate that either forward slashes (for Linux) and escaped backslashes (for Windows) should work.

@gojimmypi gojimmypi changed the title Unable to debug embedded remote targets using arm-none-eabi-gdb on Windows Unable to debug embedded remote targets using arm-none-eabi-gdb on Windows (path issues) May 10, 2017
@pieandcakes
Copy link
Contributor

@gojimmypi They should work for windows if your target is not Linux. You can view what we send by enabling the following block in launch.json:

"logging": { "trace": true, "traceResponse": true, "engineLogging": true }

The engineLogging will show the calls we send to gdb and it's responses. We use the MI Command interpreter interface within gdb. If you verify that what we are sending in that instance is wrong, that's something we can fix, but if we're sending the right thing and gdb is processing it wrong, I don't think this is fixable from us.

If possible, can you enable the logging and share the results?

@pieandcakes pieandcakes self-assigned this May 10, 2017
@gojimmypi
Copy link
Author

@pieandcakes thanks for your reply & suggestion.

"They should work for windows if your target is not Linux"

well, I have a somewhat convoluted setup here using both. As VSCode apparently does not have its own OpenOCD, I actually have OpenOCD running on an Ubuntu VM, with the JTAG connector & hardware. Feature request to not have to do that! :) However VSCode is on Windows, pointing at a local Windows directory with a copy of the source code & elf file (compiled on Ubuntu)... and doing a remote connection over the local (VM) network. For more of an explanation, see:

https://gojimmypi.blogspot.com/2017/05/vscode-remote-debugging-of-embedded.html

Per your request, my new launch.json with the logging:

{
    "version": "0.2.0",
    "configurations": [

        {
            "name": "Debug",
            "type": "cppdbg",
            "request": "launch",
            "miDebuggerPath": "C:\\workspace\\opendps\\opendps\\arm-none-eabi-gdb.exe",
            "targetArchitecture": "arm",
            "program": "C:\\workspace\\opendps\\opendps\\opendps.elf",

            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
            {
                "text": "file 'C:\\workspace\\opendps\\opendps\\opendps.elf'"
            },
            {
                "text": "target remote 192.168.174.129:3333"
            },
            {
                "text": "monitor reset init"
            }
                
            ],
            "externalConsole": false,
            "cwd": "C:\\workspace\\opendps\\opendps\\",
            "logging": { "trace": true, "traceResponse": true, "engineLogging": true }
            }
    ]
}

results in this log and error:

1: (149) LaunchOptions<LocalLaunchOptions xmlns='http://schemas.microsoft.com/vstudio/MDDDebuggerOptions/2014'
1: (156) LaunchOptions  ExePath='C:\workspace\opendps\opendps\opendps.elf'
1: (156) LaunchOptions  WorkingDirectory='C:\workspace\opendps\opendps\'
1: (156) LaunchOptions  TargetArchitecture='arm'
1: (156) LaunchOptions  ExeArguments=''
1: (156) LaunchOptions  MIDebuggerPath='C:\workspace\opendps\opendps\arm-none-eabi-gdb.exe'
1: (156) LaunchOptions  WaitDynamicLibLoad='false'
1: (156) LaunchOptions>
1: (156) LaunchOptions    <SetupCommands>
1: (156) LaunchOptions        <Command IgnoreFailures='true' Description='Enable pretty-printing for gdb'>-enable-pretty-printing</Command>
1: (156) LaunchOptions        <Command IgnoreFailures='false' Description=''>file 'C:\workspace\opendps\opendps\opendps.elf'</Command>
1: (156) LaunchOptions        <Command IgnoreFailures='false' Description=''>target remote 192.168.174.129:3333</Command>
1: (156) LaunchOptions        <Command IgnoreFailures='false' Description=''>monitor reset init</Command>
1: (156) LaunchOptions    </SetupCommands>
1: (156) LaunchOptions</LocalLaunchOptions>
1: (297) Starting: "C:\workspace\opendps\opendps\arm-none-eabi-gdb.exe" --interpreter=mi
1: (307) DebuggerPid=23872
1: (334) ->=thread-group-added,id="i1"
1: (334) ->~"GNU gdb (Atmel build: 496) 7.12.0.20161204-git\n"
1: (334) ->~"Copyright (C) 2016 Free Software Foundation, Inc.\n"
1: (336) ->~"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.  Type \"show copying\"\nand \"show warranty\" for details.\n"
1: (336) ->~"This GDB was configured as \"--host=i686-w64-mingw32 --target=arm-none-eabi\".\nType \"show configuration\" for configuration details."
1: (336) ->~"\nFor bug reporting instructions, please see:\n"
1: (337) ->~"<http://www.gnu.org/software/gdb/bugs/>.\n"
1: (337) ->~"Find the GDB manual and other documentation resources online at:\n<http://www.gnu.org/software/gdb/documentation/>.\n"
1: (338) ->~"For help, type \"help\".\n"
1: (338) ->~"Type \"apropos word\" to search for commands related to \"word\".\n"
1: (338) ->(gdb)
1: (340) <-1001-gdb-set target-async on
1: (348) ->1001^done
1: (348) ->(gdb)
1: (349) 1001: elapsed time 9
1: (355) <-1002-enable-pretty-printing
1: (359) ->1002^done
1: (359) ->(gdb)
1: (359) 1002: elapsed time 4
1: (361) <-1003-interpreter-exec console "file 'C:\\workspace\\opendps\\opendps\\opendps.elf'"
1: (373) ->&"C:workspaceopendpsopendpsopendps.elf: No such file or directory.\n"
1: (374) ->1003^error,msg="C:workspaceopendpsopendpsopendps.elf: No such file or directory."
1: (374) ->(gdb)
1: (375) 1003: elapsed time 14
1: (380) <--gdb-exit
1: (382) <-logout
 R: {"success":false,"message":"Unable to start debugging. Unexpected GDB output from command \"-interpreter-exec console \"file 'C:\\\\workspace\\\\opendps\\\\opendps\\\\opendps.elf'\"\". C:workspaceopendpsopendpsopendps.elf: No such file or directory.","request_seq":2,"command":"launch","body":{"error":{"id":1104,"format":"Unable to start debugging. Unexpected GDB output from command \"-interpreter-exec console \"file 'C:\\\\workspace\\\\opendps\\\\opendps\\\\opendps.elf'\"\". C:workspaceopendpsopendpsopendps.elf: No such file or directory.","variables":null}},"running":false,"refs":null,"seq":0,"type":"response"}
C disconnect: {"restart":false}
 R: {"success":true,"message":null,"request_seq":3,"command":"disconnect","body":null,"running":false,"refs":null,"seq":0,"type":"response"}

A quick Ctrl-H to replace the double-black-slashes with single-forward-slashes:


{
    "version": "0.2.0",
    "configurations": [

        {
            "name": "Debug",
            "type": "cppdbg",
            "request": "launch",
            "miDebuggerPath": "C:/workspace/opendps/opendps/arm-none-eabi-gdb.exe",
            "targetArchitecture": "arm",
            "program": "C:/workspace/opendps/opendps/opendps.elf",

            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
            {
                "text": "file 'C:/workspace/opendps/opendps/opendps.elf'"
            },
            {
                "text": "target remote 192.168.174.129:3333"
            },
            {
                "text": "monitor reset init"
            }
                
            ],
            "externalConsole": false,
            "cwd": "C:/workspace/opendps/opendps/",
            "logging": { "trace": true, "traceResponse": true, "engineLogging": true }
            }
    ]
}

has a much different result:

1: (148) LaunchOptions<LocalLaunchOptions xmlns='http://schemas.microsoft.com/vstudio/MDDDebuggerOptions/2014'
1: (154) LaunchOptions  ExePath='C:\workspace\opendps\opendps\opendps.elf'
1: (154) LaunchOptions  WorkingDirectory='C:\workspace\opendps\opendps\'
1: (154) LaunchOptions  TargetArchitecture='arm'
1: (154) LaunchOptions  ExeArguments=''
1: (154) LaunchOptions  MIDebuggerPath='C:/workspace/opendps/opendps/arm-none-eabi-gdb.exe'
1: (154) LaunchOptions  WaitDynamicLibLoad='false'
1: (154) LaunchOptions>
1: (154) LaunchOptions    <SetupCommands>
1: (154) LaunchOptions        <Command IgnoreFailures='true' Description='Enable pretty-printing for gdb'>-enable-pretty-printing</Command>
1: (154) LaunchOptions        <Command IgnoreFailures='false' Description=''>file 'C:/workspace/opendps/opendps/opendps.elf'</Command>
1: (154) LaunchOptions        <Command IgnoreFailures='false' Description=''>target remote 192.168.174.129:3333</Command>
1: (154) LaunchOptions        <Command IgnoreFailures='false' Description=''>monitor reset init</Command>
1: (154) LaunchOptions    </SetupCommands>
1: (154) LaunchOptions</LocalLaunchOptions>
1: (289) Starting: "C:/workspace/opendps/opendps/arm-none-eabi-gdb.exe" --interpreter=mi
1: (299) DebuggerPid=23000
1: (326) ->=thread-group-added,id="i1"
1: (327) ->~"GNU gdb (Atmel build: 496) 7.12.0.20161204-git\n"
1: (327) ->~"Copyright (C) 2016 Free Software Foundation, Inc.\n"
1: (329) ->~"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.  Type \"show copying\"\nand \"show warranty\" for details.\n"
1: (329) ->~"This GDB was configured as \"--host=i686-w64-mingw32 --target=arm-none-eabi\".\nType \"show configuration\" for configuration details."
1: (330) ->~"\nFor bug reporting instructions, please see:\n"
1: (330) ->~"<http://www.gnu.org/software/gdb/bugs/>.\n"
1: (331) ->~"Find the GDB manual and other documentation resources online at:\n<http://www.gnu.org/software/gdb/documentation/>.\n"
1: (331) ->~"For help, type \"help\".\n"
1: (331) ->~"Type \"apropos word\" to search for commands related to \"word\".\n"
1: (331) ->(gdb)
1: (334) <-1001-gdb-set target-async on
1: (342) ->1001^done
1: (342) ->(gdb)
1: (343) 1001: elapsed time 10
1: (348) <-1002-enable-pretty-printing
1: (352) ->1002^done
1: (352) ->(gdb)
1: (352) 1002: elapsed time 4
1: (355) <-1003-interpreter-exec console "file 'C:/workspace/opendps/opendps/opendps.elf'"
1: (364) ->~"Reading symbols from C:/workspace/opendps/opendps/opendps.elf..."
1: (370) ->~"done.\n"
1: (371) ->1003^done
1: (371) ->(gdb)
1: (371) 1003: elapsed time 16
1: (371) <-1004-interpreter-exec console "target remote 192.168.174.129:3333"
1: (399) ->~"Remote debugging using 192.168.174.129:3333\n"
1: (403) ->=thread-group-started,id="i1",pid="42000"
1: (403) ->=thread-created,id="1",group-id="i1"
1: (410) ->~"adc1_2_isr () at hw.c:249\n"
1: (411) ->&"warning: Source file is more recent than executable.\n"
1: (411) ->~"249\t            i_out_adc = i;\n"
1: (411) ->*stopped,frame={addr="0x08001586",func="adc1_2_isr",args=[],file="hw.c",fullname="C:\\workspace\\opendps\\opendps\\hw.c",line="249"},thread-id="1",stopped-threads="all"
1: (412) ->1004^done
1: (412) ->(gdb)
1: (418) 1004: elapsed time 46
1: (418) <-1005-thread-info 1
1: (423) ->1005^done,threads=[{id="1",target-id="Remote target",frame={level="0",addr="0x08001586",func="adc1_2_isr",args=[],file="hw.c",fullname="C:\\workspace\\opendps\\opendps\\hw.c",line="249"},state="stopped"}]
1: (423) ->(gdb)
1: (424) 1005: elapsed time 6
1: (424) <-1006-interpreter-exec console "monitor reset init"
E thread: {"reason":"started","threadId":-2,"type":"thread"}
1: (457) ->@"JTAG tap: stm32f1x.cpu tap/device found: 0x3ba00477 (mfg: 0x23b, part: 0xba00, ver: 0x3)\n"
1: (458) ->@"JTAG tap: stm32f1x.bs tap/device found: 0x16410041 (mfg: 0x020, part: 0x6410, ver: 0x1)\n"
1: (863) ->@"target state: halted\n"
1: (863) ->@"target halted due to debug-request, current mode: Thread \n"

@gojimmypi
Copy link
Author

See also issue #696

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants