delve调试go程序

安装delve:
$ git clone https://github.com/go-delve/delve.git $GOPATH/src/github.com/go-delve/delve
$ cd $GOPATH/src/github.com/go-delve/delve
$ make install

调试main包中代码
dlv debug github.com/me/foo/cmd/foo -- -arg1 value  ##参数

子命令:
    debug 
    test 
    help 查看更多帮助信息
    core
    run 
    exec 
    reply
    trace
    log 
    backend 
    dap 
    core 
    connect 
    attach

调试指令:
    运行命令:
        call
        continue 
        next 
        restart 
        rev 
        rewind 
        step 
        step-instruction 
        step-out 
    中断管理:
        break 
        breakpoints 
        clear 
        clearall
        condition
        on
        trace 
    查看变量和内存:
        args 
        display 
        examinemem
        locals 
        print
        regs 
        set 
        vars 
        whatis 
    线程和goroutine相关命令:
        goroutine 
        goroutines 
        tread 
        treads 
    展示栈中内容
        deferred 
        down 
        frame 
        stack 
        up 
        
    其他命令:
        check 
        checkpoints 
        clear-checkpoint 
        config 
        disassemble 
        edit
        exit 
        funcs
        help 
        libraries
        list 
        source 
        sources 
        types 
        
选项:
      --accept-multiclient   Allows a headless server to accept multiple client connections.
      --api-version int      Selects API version when headless. (default 1)
      --backend string       Backend selection (see 'dlv help backend'). (default "default")
      --build-flags string   Build flags, to be passed to the compiler.
      --check-go-version     Checks that the version of Go in use is compatible with Delve. (default true)
      --headless             Run debug server only, in headless mode.
      --init string          Init file, executed by the terminal client.
      -l, --listen string        Debugging server listen address. (default "127.0.0.1:0")
      --log                  Enable debugging server logging.
      --log-dest string      Writes logs to the specified file or file descriptor (see 'dlv help log').
      --log-output string    Comma separated list of components that should produce debug output (see 'dlv help log')
      --only-same-user       Only connections from the same user that started this instance of Delve are allowed to connect. (default true)
      --wd string            Working directory for running the program. (default ".")
    
    

你可能感兴趣的:(go)