• VSCode + GDBServer 远程调试C/C++流水账


    VSCode + GDBServer 远程调试C/C++流水账

    配置了一个开发环境,写个流水账供日后查阅

    工程文件

    main.c

    #include <stdio.h>
    
    void main()
    {
    	printf("hw
    ");
    	return;
    }
    

    Makefile

    # C compiler options
    CC	= gcc
    #CC	= x86_64-w64-mingw32-gcc
    CFLAGS=         
    RELEASE	= release.elf
    DEBUG	= debug.elf
    LIBS = 
    INC	= 
    
    # Source files
    SRCS = main.c
    
    # Make everything
    all:	$(RELEASE) 
    debug: $(DEBUG)
    # Make the application
    $(RELEASE): $(OBJS)
    	$(CC) -o $(RELEASE) $(SRCS) $(LIBS) $(CFLAGS)
    
    $(DEBUG): $(OBJS)
    	$(CC) -g -ggdb3 -o $(DEBUG) $(SRCS) $(LIBS) $(CFLAGS)
    	gdbserver :1234 $(DEBUG)
    
    #
    # Clean all object files...
    #
    clean:
    	$(RM) $(DEBUG) $(RELEASE) 
    
    

    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": "GDB Launch",
    			"type": "cppdbg",
    			"request": "launch",
    			"program": "${workspaceFolder}/debug.elf",
    			"args": [],
    			"stopAtEntry": false,
    			"cwd": "${workspaceFolder}",
    			"environment": [],
    			"externalConsole": false,
    			"MIMode": "gdb",
    			"logging": {
    				"moduleLoad": true,
    				"engineLogging": true,
    				"trace": true
    			},
    			"setupCommands": [
    				{
    					"description": "Enable pretty-printing for gdb",
    					"text": "-enable-pretty-printing",
    					"ignoreFailures": true
    				}
    			],
    			"linux": {
    				"miDebuggerPath": "/usr/bin/gdb",
    			},
    			//"preLaunchTask": "RunGDBServer",
    			"miDebuggerServerAddress": "127.0.0.1:1234"
    		}
    	]
    }
    

    RunDebug.sh

    make debug
    gdbserver :1234 debug.elf
    

    操作步骤:

    1. 运行RunDebug.sh生成调试文件,以及运行gdbserver
    2. 在VSCode里按F5开始调试
  • 相关阅读:
    矩阵分析 p13~p20
    矩阵分析 p1~p13
    复变函数2
    口语80篇(1-2)
    复变函数1
    背单词方法
    writing practice
    将博客搬至CSDN
    windows内核编程 白话设备栈
    sfliter__except_handler4
  • 原文地址:https://www.cnblogs.com/DragonStart/p/14237612.html
Copyright © 2020-2023  润新知