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.

Escaped double quotes in postLaunchCommands = 'Problem parsing arguments' error

See original GitHub issue

The upcoming OpenOCD 0.11.0 supports a new set of rtt commands. One of the commands requires that its last argument is wrapped in double quotes, e.g. rtt setup 0x20000000 49152 "SEGGER RTT".

Specifying that command with escaped double quotes in the postLaunchCommands results in a parsing error.

This is the launch.json file I used:

{
    "version": "0.2.0",
    "configurations": [
        {
            "cwd": "${workspaceRoot}",
            "executable": "./target/thumbv7em-none-eabihf/debug/stm-app",
            "name": "Debug Microcontroller (launch)",
            "request": "launch",
            "preLaunchTask": "rust: cargo build",
            "type": "cortex-debug",
            "runToMain": true,
            "configFiles": [
                "interface/stlink.cfg",
                "target/stm32l4x.cfg"
            ],
            "servertype": "openocd",
            "postLaunchCommands": [
                "monitor rtt setup 0x20000000 49152 \"SEGGER RTT\"", // <-
                "monitor rtt start",
                "monitor rtt server start 8765 0",
            ],
            "svdFile": "STM32L4x3.svd"
        }
    ]
}

I get the following pop-up error message when I try to use the above launch configuration:

Failed to launch GDB: Problem parsing arguments: interpreter-exec console "monitor rtt setup 0x20000000 49152 "SEGGER RTT"" (from interpreter-exec console "monitor rtt setup 0x20000000 49152 "SEGGER RTT"")

Is there a way to execute OpenOCD commands that contain double quotes after the main breakpoint has been hit (i.e. with "runToMain": true in the launch.json)?

Workaround

As a workaround I’m currently using an external GDB script file.

            "postLaunchCommands": [
                "source rtt.gdb",
            ],
$ cat rtt.gdb
monitor rtt setup 0x20000000 49152 "SEGGER RTT"
monitor rtt start
monitor rtt server start 8765 0

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
Maruscommented, Jan 20, 2021

Yeah - once I put in a proper encoding fix (not sure if I expect this will come in 0.3.9 - as I’ve already started the 0.3.8 preparations then you’ll have to remove that extra \\ - but just thought that might be a nicer work-around than the source variation until I can do that.

0reactions
japariccommented, Jan 25, 2021

thanks for the quick fix, 0.3.9 works nicely!

Read more comments on GitHub >

github_iconTop Results From Across the Web

PowerShell stripping double quotes from command line ...
For now, the fix is to escape command line arguments in accordance with these rules (which seem to be used (indirectly) by the...
Read more >
Escaped double quotes and Parse JSON
Solved: Hello. I've got an issue. I have some JSON object I want to convert into Power Automate object with Parse JSON ....
Read more >
Double quotes in CSV file fields cause parsing to truncate ...
DataWave, how to parse double double quotes when included in CSV fields. ... Adding escape sequence to the called function parameter.
Read more >
Quotes, Escape Characters, Delimiters - Windows CMD - SS64
Delimiters separate one parameter from the next - they split the command line up into words. Parameters are most often separated by spaces,...
Read more >
How to Use PowerShell to Escape Double Quotes
Knowing these differences will make you a more effective PowerShell scriptwriter and help you avoid a rather simple mistake. In this post, you ......
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