zoukankan      html  css  js  c++  java
  • 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开始调试
  • 相关阅读:
    Linux显示文件内容常用命令
    Linux文件权限和更改权限
    数据存储及恢复的基本原理
    使用jemter发送HTTPS请求
    运行Jmeter时,出现java.util.prefs.WindowsPreferences <init>异常警告
    Server08AD域安装以及推送
    SVN服务器和客户端搭建
    selenium常见操作
    TestNG 入门教程
    ant+TestNG-xslt生成selenium测试报告
  • 原文地址:https://www.cnblogs.com/DragonStart/p/14237612.html
Copyright © 2011-2022 走看看