Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Dlang] Can't inspect globals #10751

Open
ryuukk opened this issue Mar 28, 2023 · 4 comments
Open

[Dlang] Can't inspect globals #10751

ryuukk opened this issue Mar 28, 2023 · 4 comments

Comments

@ryuukk
Copy link

ryuukk commented Mar 28, 2023

Environment

  • OS and version: Windows 10 x64
  • VS Code: 1.76.2
  • C/C++ extension: 1.14.4
  • OS and version of remote machine (if applicable):
  • GDB / LLDB version: n/a

Bug Summary and Steps to Reproduce

Bug Summary:

Problem:

I can't inspect global, but i can inspect locals

According to: llvm-pdbutil.exe dump -globals app.pdb > dump

  688032 | S_GTHREAD32 [size = 36] `app.notice_me_global`
           type = 0x0074 (int), addr = 0006:0000

Therefore i should be able to watch it via: app.notice_me_global

But it says: "app" is undefined

image

I suspect the . is causing confusion for the debugger

How to reproduce:

Debug this executable:

executable + pdb:

app.zip

Debugger Configurations

{
    // 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": "windows: game",
            "type": "cppvsdbg",
            "request": "launch",
            "program": "${workspaceFolder}/app.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}/",
            "environment": [],
            "externalConsole": false,
        },
    ]
}

Debugger Logs

The key 'externalConsole' is deprecated. Please use 'console' instead.
The key 'externalConsole' is deprecated. Please use 'console' instead.
The key 'externalConsole' is deprecated. Please use 'console' instead.
The key 'externalConsole' is deprecated. Please use 'console' instead.
The key 'externalConsole' is deprecated. Please use 'console' instead.
Launch configuration:
{
  "name": "windows: game",
  "type": "cppvsdbg",
  "request": "launch",
  "program": "C:\\tmp\\glb/app.exe",
  "args": [],
  "stopAtEntry": false,
  "cwd": "C:\\tmp\\glb/",
  "environment": [
    {
      "name": "_NO_DEBUG_HEAP",
      "value": "1"
    }
  ],
  "logging": {
    "engineLogging": true,
    "trace": true,
    "traceResponse": true
  },
  "__configurationTarget": 6
}
<- (E) {"seq":3,"type":"event","event":"output","body":{"category":"console","output":"-------------------------------------------------------------------\nYou may only use the C/C++ Extension for Visual Studio Code\nwith Visual Studio Code, Visual Studio or Visual Studio for Mac\nsoftware to help you develop and test your applications.\n-------------------------------------------------------------------\n","severity":"ok"}}
-------------------------------------------------------------------
You may only use the C/C++ Extension for Visual Studio Code
with Visual Studio Code, Visual Studio or Visual Studio for Mac
software to help you develop and test your applications.
-------------------------------------------------------------------
<- (R) {"seq":5,"type":"response","request_seq":2,"success":true,"command":"launch"}
-> (C) {"type":"response","seq":1,"command":"handshake","request_seq":2,"success":true,"body":{"signature":"438IwFTsPs8In9Ag7rCDCEJfkt+4zmhZShxdVdpIPGSIl0="}}
<- (E) {"seq":8,"type":"event","event":"initialized","body":{}}
-> (C) {"command":"setBreakpoints","arguments":{"source":{"name":"app.d","path":"c:\\tmp\\glb\\app.d"},"lines":[5],"breakpoints":[{"line":5}],"sourceModified":false},"type":"request","seq":3}
<- (R) {"seq":11,"type":"response","request_seq":3,"success":true,"command":"setBreakpoints","body":{"breakpoints":[{"id":1,"verified":false,"message":"The breakpoint is pending and will be resolved when debugging starts.","line":5}]}}
-> (C) {"command":"setFunctionBreakpoints","arguments":{"breakpoints":[]},"type":"request","seq":4}
<- (R) {"seq":14,"type":"response","request_seq":4,"success":true,"command":"setFunctionBreakpoints","body":{"breakpoints":[]}}
-> (C) {"command":"setInstructionBreakpoints","arguments":{"breakpoints":[]},"type":"request","seq":5}
<- (R) {"seq":17,"type":"response","request_seq":5,"success":true,"command":"setInstructionBreakpoints","body":{"breakpoints":[]}}
-> (C) {"command":"setExceptionBreakpoints","arguments":{"filters":[],"filterOptions":[]},"type":"request","seq":6}
<- (R) {"seq":20,"type":"response","request_seq":6,"success":true,"command":"setExceptionBreakpoints","body":{}}
-> (C) {"command":"configurationDone","type":"request","seq":7}
<- (E) {"seq":23,"type":"event","event":"output","body":{"category":"telemetry","output":"VS/Diagnostics/Debugger/vsdbg/ProcessCreate","data":{"VS.Diagnostics.Debugger.vsdbg.OSFamily":"Windows","VS.Diagnostics.Debugger.vsdbg.Version":"17.5.20119.1 commit:77a74c65d4300ba51a347e87db7b32741c8537db","VS.Diagnostics.Debugger.vsdbg.WindowsVersion":"10.0.19045","VS.Diagnostics.Debugger.vsdbg.TargetArchitecture":"AMD64"}}}
<- (E) {"seq":25,"type":"event","event":"process","body":{"name":"C:\\tmp\\glb\\app.exe","systemProcessId":15408,"startMethod":"launch","pointerSize":64}}
<- (E) {"seq":27,"type":"event","event":"breakpoint","body":{"reason":"changed","breakpoint":{"id":1,"verified":false,"message":"No symbols have been loaded for this document.","line":5}}}
<- (E) {"seq":29,"type":"event","event":"output","body":{"category":"telemetry","output":"VS/Diagnostics/Debugger/vsdbg/Launch","data":{"VS.Diagnostics.Debugger.vsdbg.OSFamily":"Windows","VS.Diagnostics.Debugger.vsdbg.Version":"17.5.20119.1 commit:77a74c65d4300ba51a347e87db7b32741c8537db","VS.Diagnostics.Debugger.vsdbg.VisualizerFileUsed":false,"VS.Diagnostics.Debugger.vsdbg.WindowsVersion":"10.0.19045","VS.Diagnostics.Debugger.vsdbg.Launch.Duration":172,"VS.Diagnostics.Debugger.vsdbg.TargetType":"Live","VS.Diagnostics.Debugger.vsdbg.AdapterId":"cppvsdbg","VS.Diagnostics.Debugger.vsdbg.SourceFileMappings":0}}}
<- (R) {"seq":31,"type":"response","request_seq":7,"success":true,"command":"configurationDone"}
<- (E) {"seq":33,"type":"event","event":"progressStart","body":{"progressId":"1","title":"Loading...","cancellable":true,"message":"Loading symbols for app.exe","percentage":0}}
<- (E) {"seq":35,"type":"event","event":"progressUpdate","body":{"progressId":"1","message":"Loading symbols for app.exe from: C:\\tmp\\glb","percentage":0}}
-> (C) {"command":"threads","type":"request","seq":8}
<- (R) {"seq":38,"type":"response","request_seq":8,"success":true,"command":"threads","body":{"threads":[]}}
<- (E) {"seq":40,"type":"event","event":"output","body":{"category":"console","output":"Loaded 'C:\\tmp\\glb\\app.exe'. Symbols loaded.\n"}}
Loaded 'C:\tmp\glb\app.exe'. Symbols loaded.
<- (E) {"seq":42,"type":"event","event":"module","body":{"reason":"new","module":{"id":1000,"name":"app.exe","path":"C:\\tmp\\glb\\app.exe","isUserCode":true,"symbolStatus":"Symbols loaded.","symbolFilePath":"C:\\tmp\\glb\\app.pdb"}}}
<- (E) {"seq":44,"type":"event","event":"breakpoint","body":{"reason":"changed","breakpoint":{"id":1,"verified":true,"source":{"name":"app.d","path":"C:\\tmp\\glb\\app.d","sourceReference":0},"line":5,"endLine":5,"instructionReference":"0x00007FF6D9086EB6","offset":0}}}
<- (E) {"seq":46,"type":"event","event":"thread","body":{"reason":"started","threadId":17208}}
<- (E) {"seq":48,"type":"event","event":"progressUpdate","body":{"progressId":"1","message":"Loading symbols for ntdll.dll","percentage":0}}
<- (E) {"seq":50,"type":"event","event":"progressUpdate","body":{"progressId":"1","message":"Loading symbols for ntdll.dll from: C:\\tmp\\glb","percentage":0}}
<- (E) {"seq":52,"type":"event","event":"progressUpdate","body":{"progressId":"1","message":"Loading symbols for ntdll.dll from: C:\\Windows\\System32\\","percentage":0}}
<- (E) {"seq":54,"type":"event","event":"progressUpdate","body":{"progressId":"1","message":"Loading symbols for ntdll.dll from: C:\\WINDOWS\\","percentage":0}}
<- (E) {"seq":56,"type":"event","event":"output","body":{"category":"console","output":"Loaded 'C:\\Windows\\System32\\ntdll.dll'. \n"}}
Loaded 'C:\Windows\System32\ntdll.dll'.
<- (E) {"seq":58,"type":"event","event":"module","body":{"reason":"new","module":{"id":1001,"name":"ntdll.dll","path":"C:\\Windows\\System32\\ntdll.dll","isUserCode":false,"version":"10.0.19041.2130 (WinBuild.160101.0800)","symbolStatus":"Cannot find or open the PDB file."}}}
<- (E) {"seq":60,"type":"event","event":"progressUpdate","body":{"progressId":"1","message":"Loading symbols for ntdll.dll from: C:\\WINDOWS\\symbols\\dll\\","percentage":0}}
<- (E) {"seq":62,"type":"event","event":"progressUpdate","body":{"progressId":"1","message":"Loading symbols for ntdll.dll from: C:\\WINDOWS\\dll\\","percentage":0}}
<- (E) {"seq":64,"type":"event","event":"progressUpdate","body":{"progressId":"1","message":"Loading symbols for kernel32.dll","percentage":0}}
<- (E) {"seq":66,"type":"event","event":"progressUpdate","body":{"progressId":"1","message":"Loading symbols for kernel32.dll from: C:\\tmp\\glb","percentage":0}}
<- (E) {"seq":68,"type":"event","event":"output","body":{"category":"console","output":"Loaded 'C:\\Windows\\System32\\kernel32.dll'. \n"}}
Loaded 'C:\Windows\System32\kernel32.dll'.
<- (E) {"seq":70,"type":"event","event":"progressUpdate","body":{"progressId":"1","message":"Loading symbols for kernel32.dll from: C:\\Windows\\System32\\","percentage":0}}
<- (E) {"seq":72,"type":"event","event":"module","body":{"reason":"new","module":{"id":1002,"name":"kernel32.dll","path":"C:\\Windows\\System32\\kernel32.dll","isUserCode":false,"version":"10.0.19041.2251 (WinBuild.160101.0800)","symbolStatus":"Cannot find or open the PDB file."}}}
<- (E) {"seq":74,"type":"event","event":"progressUpdate","body":{"progressId":"1","message":"Loading symbols for kernel32.dll from: C:\\WINDOWS\\","percentage":0}}
<- (E) {"seq":76,"type":"event","event":"progressUpdate","body":{"progressId":"1","message":"Loading symbols for kernel32.dll from: C:\\WINDOWS\\symbols\\dll\\","percentage":0}}
<- (E) {"seq":78,"type":"event","event":"progressUpdate","body":{"progressId":"1","message":"Loading symbols for kernel32.dll from: C:\\WINDOWS\\dll\\","percentage":0}}
<- (E) {"seq":80,"type":"event","event":"output","body":{"category":"console","output":"Loaded 'C:\\Windows\\System32\\KernelBase.dll'. \n"}}
<- (E) {"seq":82,"type":"event","event":"progressUpdate","body":{"progressId":"1","message":"Loading symbols for KernelBase.dll","percentage":0}}
Loaded 'C:\Windows\System32\KernelBase.dll'.
<- (E) {"seq":84,"type":"event","event":"progressUpdate","body":{"progressId":"1","message":"Loading symbols for KernelBase.dll from: C:\\tmp\\glb","percentage":0}}
<- (E) {"seq":86,"type":"event","event":"module","body":{"reason":"new","module":{"id":1003,"name":"KernelBase.dll","path":"C:\\Windows\\System32\\KernelBase.dll","isUserCode":false,"version":"10.0.19041.2193 (WinBuild.160101.0800)","symbolStatus":"Cannot find or open the PDB file."}}}
<- (E) {"seq":88,"type":"event","event":"progressUpdate","body":{"progressId":"1","message":"Loading symbols for KernelBase.dll from: C:\\Windows\\System32\\","percentage":0}}
<- (E) {"seq":90,"type":"event","event":"progressUpdate","body":{"progressId":"1","message":"Loading symbols for KernelBase.dll from: C:\\WINDOWS\\","percentage":0}}
<- (E) {"seq":92,"type":"event","event":"progressUpdate","body":{"progressId":"1","message":"Loading symbols for KernelBase.dll from: C:\\WINDOWS\\symbols\\dll\\","percentage":0}}
<- (E) {"seq":94,"type":"event","event":"progressUpdate","body":{"progressId":"1","message":"Loading symbols for KernelBase.dll from: C:\\WINDOWS\\dll\\","percentage":0}}
<- (E) {"seq":96,"type":"event","event":"stopped","body":{"reason":"breakpoint","threadId":17208,"allThreadsStopped":true,"hitBreakpointIds":[1],"source":{"name":"app.d","path":"C:\\tmp\\glb\\app.d"},"line":5,"column":0}}
-> (C) {"command":"threads","type":"request","seq":9}
<- (R) {"seq":99,"type":"response","request_seq":9,"success":true,"command":"threads","body":{"threads":[{"id":17208,"name":"Main Thread"}]}}
-> (C) {"command":"stackTrace","arguments":{"threadId":17208,"startFrame":0,"levels":20},"type":"request","seq":10}
<- (R) {"seq":102,"type":"response","request_seq":10,"success":true,"command":"stackTrace","body":{"stackFrames":[{"id":1000,"name":"app.exe!app.main(...) Line 5","source":{"name":"app.d","path":"C:\\tmp\\glb\\app.d","sourceReference":0},"line":5,"column":1,"endLine":5,"endColumn":0,"instructionPointerReference":"0x00007FF6D9086EB6","moduleId":1000},{"id":1001,"name":"[Inline Frame] app.exe!invoke_main() Line 78","source":{"name":"exe_common.inl","path":"D:\\a\\_work\\1\\s\\src\\vctools\\crt\\vcstartup\\src\\startup\\exe_common.inl","sourceReference":0,"checksums":[{"algorithm":"SHA256","checksum":"06302037b260f066fed492d8bb29ef08d9906fd3afb9dd34a71b9c4c537a9dbc"}]},"line":78,"column":1,"endLine":78,"endColumn":0,"instructionPointerReference":"0x00007FF6D90898AC","moduleId":1000},{"id":1002,"name":"app.exe!__scrt_common_main_seh() Line 288","source":{"name":"exe_common.inl","path":"D:\\a\\_work\\1\\s\\src\\vctools\\crt\\vcstartup\\src\\startup\\exe_common.inl","sourceReference":0,"checksums":[{"algorithm":"SHA256","checksum":"06302037b260f066fed492d8bb29ef08d9906fd3afb9dd34a71b9c4c537a9dbc"}]},"line":288,"column":1,"endLine":288,"endColumn":0,"instructionPointerReference":"0x00007FF6D90898AC","moduleId":1000},{"id":1003,"name":"kernel32.dll!00007ffac17f74b4()","line":0,"column":0,"instructionPointerReference":"0x00007FFAC17F74B4","moduleId":1002},{"id":1004,"name":"ntdll.dll!00007ffac30c26a1()","line":0,"column":0,"instructionPointerReference":"0x00007FFAC30C26A1","moduleId":1001}],"totalFrames":5}}
-> (C) {"command":"threads","type":"request","seq":11}
<- (R) {"seq":105,"type":"response","request_seq":11,"success":true,"command":"threads","body":{"threads":[{"id":17208,"name":"Main Thread"}]}}
-> (C) {"command":"evaluate","arguments":{"expression":"app.notice_me_global","frameId":1000,"context":"watch"},"type":"request","seq":12}
-> (C) {"command":"evaluate","arguments":{"expression":"notice_me_global","frameId":1000,"context":"watch"},"type":"request","seq":13}
<- (E) {"seq":109,"type":"event","event":"output","body":{"category":"telemetry","output":"VS/Diagnostics/Debugger/vsdbg/Evaluate","data":{"VS.Diagnostics.Debugger.vsdbg.Evaluation.IsError":true,"VS.Diagnostics.Debugger.vsdbg.Evaluation.Duration":16,"VS.Diagnostics.Debugger.vsdbg.OSFamily":"Windows","VS.Diagnostics.Debugger.vsdbg.Version":"17.5.20119.1 commit:77a74c65d4300ba51a347e87db7b32741c8537db","VS.Diagnostics.Debugger.vsdbg.WindowsVersion":"10.0.19045","VS.Diagnostics.Debugger.vsdbg.AdapterId":"cppvsdbg"}}}
<- (R) {"seq":111,"type":"response","request_seq":12,"success":true,"command":"evaluate","body":{"result":"identifier \"app\" is undefined","presentationHint":{"attributes":["readOnly","failedEvaluation"]},"variablesReference":0}}
<- (E) {"seq":113,"type":"event","event":"output","body":{"category":"telemetry","output":"VS/Diagnostics/Debugger/vsdbg/Evaluate","data":{"VS.Diagnostics.Debugger.vsdbg.Evaluation.IsError":true,"VS.Diagnostics.Debugger.vsdbg.Evaluation.Duration":16,"VS.Diagnostics.Debugger.vsdbg.OSFamily":"Windows","VS.Diagnostics.Debugger.vsdbg.Version":"17.5.20119.1 commit:77a74c65d4300ba51a347e87db7b32741c8537db","VS.Diagnostics.Debugger.vsdbg.WindowsVersion":"10.0.19045","VS.Diagnostics.Debugger.vsdbg.AdapterId":"cppvsdbg"}}}
<- (R) {"seq":115,"type":"response","request_seq":13,"success":true,"command":"evaluate","body":{"result":"identifier \"notice_me_global\" is undefined","presentationHint":{"attributes":["readOnly","failedEvaluation"]},"variablesReference":0}}
-> (C) {"command":"scopes","arguments":{"frameId":1000},"type":"request","seq":14}
<- (R) {"seq":118,"type":"response","request_seq":14,"success":true,"command":"scopes","body":{"scopes":[{"name":"Locals","variablesReference":1000,"expensive":false},{"name":"Registers","presentationHint":"registers","variablesReference":1001,"expensive":true}]}}
-> (C) {"command":"variables","arguments":{"variablesReference":1000},"type":"request","seq":15}
<- (R) {"seq":121,"type":"response","request_seq":15,"success":true,"command":"variables","body":{"variables":[]}}
<- (E) {"seq":123,"type":"event","event":"progressEnd","body":{"progressId":"1"}}

Other Extensions

No response

Additional Information

llvm-pdbutil.exe dump -globals app.pdb > dump

https://gist.github.com/ryuukk/8674e88822038c371a2ea7c631e6744e

@ryuukk
Copy link
Author

ryuukk commented Mar 28, 2023

Differences i notice between a valid C program, and program that i provide

C:

      20 | S_GDATA32 [size = 32] `notice_me_global`
           type = 0x0074 (int), addr = 0003:0000

D:

       0 | S_GDATA32 [size = 40] `app_d.notice_me_global`
           type = 0x0074 (int), addr = 0003:3504

20 | for C
0 | for D

app_d.notice_me_global for D (notice the . (dot))
notice_me_global for C

For D:
image

(notice it stops at the .(dot) and only mention app_d)

For C:
image

Both use the same linker, both are debug builds:

Ready to test project (source + build script + launch.json)

Requirements:

build.zip

Here just for the executables + dump:

binaries.zip

@ryuukk
Copy link
Author

ryuukk commented Mar 28, 2023

Something i noticed:

There are no entry for app_d in the PDB (it seems)

I don't know how the debugger works, but i assume it splits the name

app_d.notice_me_global
-> search for: app_d then if found, look for: notice_me_global?

Since nothing for app_d it complains nothing was found

Perhaps if nothing was found it needs to try the full name app_d.notice_me_global? that would solve it?

Then it's a problem that need to be a solved in msvc debugger? if so, what's the proper issue tracker to use?

@ryuukk
Copy link
Author

ryuukk commented Mar 28, 2023

On linux, with gdb, i can inspect the global properly:

image

objdump content:

 <1><70>: Abbrev Number: 4 (DW_TAG_variable)
    <71>   DW_AT_name        : app_d.notice_me_global
    <88>   DW_AT_type        : <0x69>
    <8c>   DW_AT_external    : 1
    <8d>   DW_AT_location    : 9 byte block: 3 10 40 0 0 0 0 0 0 	(DW_OP_addr: 4010)

full: https://gist.github.com/ryuukk/124ba68b0c7c17e5ba8452c4adbd6170

@WardenGnaw WardenGnaw changed the title Can't inspect globals [Dlang] Can't inspect globals Mar 31, 2023
@ryuukk
Copy link
Author

ryuukk commented Apr 1, 2023

Zig's executable also have the same issue, i'll upload executables tomorow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant