Delve(dlv)无法附加到进程

时间:2019-01-24 01:25:05

标签: debugging go build delve

我正在从dlv中获取此错误

...
"pivot": [
    {
        "field": "inStock",
        "value": true,
        "count": 8,
        "docs": [
            {
                "name": "Product 1",
                "price": 45.3,
                "inStock": true
            },
            {
                "name": "Product 2",
                "price": 41.3,
                "inStock": true
            },
        ],
        "stats": {
            "stats_fields": {
                "price": {
                    "min": 74.98999786376953,
                    "max": 399.0
                }
            }
        }
    },
    {
        "field": "inStock",
        "value": false,
        "count": 4,
        "docs": [
            {
                "name": "Product A",
                "price": 25.3,
                "inStock": false
            },
            {
                "name": "Product B",
                "price": 11.3,
                "inStock": false
            },
        ],
        "stats": {
            "stats_fields": {
                "price": {
                    "min": 11.5,
                    "max": 649.989990234375
                }
            }
        }
    }
],
...

二进制文件是通过以下方式构建的:

could not attach to pid 20727: decoding dwarf section info at offset 0x0: too short

您能否确认是导致以下问题的go build -a -v -ldflags "-w -X main.gitCommit=<sha> -linkmode 'auto' -extldflags '-static'" 标志?它会去除调试符号吗?

1 个答案:

答案 0 :(得分:0)

删除-w标志后,delve可以附加到进程中