Unable to start debugging (error 216) Visual Studio Code on Windows 10

862 views
Skip to first unread message

Greg O

unread,
Aug 7, 2021, 4:19:08 PM8/7/21
to libmodbus
Visual Studio Code version 1.59.0 creates the modbus.exe file, but Run > Start Debugging generates error 216 (more detail below).
  • My other programs in VS Code debug with no problem
  • Disabling Avast Free Antivirus did not work
  • Running the program from a cmd prompt gives the message:
    •  'cannot start or run due to incompatibility with  64-bit versions of Windows.
  • Since I don't think a dll is required, and I am using VS Code 2021, I have not installed src/win32 files.
Any assistance would be appreciated.  Thank you for your time.

Kind regards,
Greg

  • Debugger output
=thread-group-added,id="i1"
GNU gdb (GDB) 10.2
Copyright (C) 2021 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 "x86_64-w64-mingw32".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://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".
Warning: Debuggee TargetArchitecture not detected, assuming x86_64.
=cmd-param-changed,param="pagination",value="off"
ERROR: Unable to start debugging. Unexpected GDB output from command "-exec-run". Error creating process c:\Users\Appa Oh\Documents\GitHub\libmodbus\src\modbus.exe, (error 216).
The program 'c:\Users\Appa Oh\Documents\GitHub\libmodbus\src\modbus.exe' has exited with code 42 (0x0000002a).

My other programs in VS Code debug with no problem
Disabling Avast Free Antivirus did not work

  • c_cpp_properties.json
{
    "configurations": [
        {
            "name""Win32",
            "includePath": [
                "${workspaceFolder}/**",
                "C:\\msys64\\mingw64\\x86_64-w64-mingw32\\include"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "windowsSdkVersion""8.1",
            "compilerPath""C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\\\VC/bin/cl.exe",
            "cStandard""c17",
            "cppStandard""c++17",
            "intelliSenseMode""windows-msvc-x64"
        }
    ],
    "version"4
}

  • launch.json
{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version""0.2.0",
    "configurations": [
        {
            "name""gcc.exe - Build and debug active file",
            "type""cppdbg",
            "request""launch",
            "program""${fileDirname}\\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry"false,
            "cwd""C:\\msys64\\mingw32\\bin",
            "environment": [],
            "externalConsole"false,
            "MIMode""gdb",
            "miDebuggerPath""C:\\msys64\\mingw64\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description""Enable pretty-printing for gdb",
                    "text""-enable-pretty-printing",
                    "ignoreFailures"true
                }
            ],
            "preLaunchTask""C/C++: gcc.exe build active file"
        }
    ]
}

  • tasks.json
{
    "tasks": [
        {
            "type""cppbuild",
            "label""C/C++: gcc.exe build active file",
            "command""C:\\msys64\\mingw64\\bin\\gcc.exe",
            "args": [
                "-c",
                "-ggdb",
                "-municode"// to use mWinMain instead of WinMain go 2021-07-31
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd""${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind""build",
                "isDefault"true
            },
            "detail""Task generated by Debugger."
        }
    ],
    "version""2.0.0"
}

Greg O

unread,
Aug 7, 2021, 7:27:40 PM8/7/21
to libmodbus
Additional information:

My main program and supporting routine:
// Main program for Modbus RTU device communication
//

#include "modbus_comm.h"

int main(void)
{
    modbus_comm();
}

Supporting routine:
#include    <stdio.h>   // for stderr and many others

#include    "modbus-rtu.h" // for modbus_t and more


int modbus_comm (void)
{
    // 1. Common: create context
    modbus_t *ctx;

    ctx = modbus_new_rtu(
        "COM5"// device
        9600,   // baud rate
        "N",    // party None
        8,      // number of data bits
        1);     // number of stop bits

    if (modbus_connect(ctx) == -1) {
        fprintf(stderr, "Connection failed: %s\n"modbus_strerror(errno));
        modbus_free(ctx);
        return -1;
    }
}
Reply all
Reply to author
Forward
0 new messages