• 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开始调试
  • 相关阅读:
    flash actionscript MovieClip(电影剪辑)控制
    浅谈测试驱动开发(TDD)(转)
    双缓冲渲染
    可以控制多层嵌套的movieClip播放和暂停
    flash actionscript MovieClip(电影剪辑)控制
    栈(stack)
    CDC::GetDeviceCaps()物理长度与屏幕像素间的转换
    转载学习结构体和union大小的问题
    GetDeviceCaps参数
    链表(list)
  • 原文地址:https://www.cnblogs.com/DragonStart/p/14237612.html
Copyright © 2020-2023  润新知