microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.53k stars 1.56k forks source link

Variables listed in "environment" are not applied #10760

Closed sbobko closed 1 year ago

sbobko commented 1 year ago

Environment

Bug Summary and Steps to Reproduce

Bug Summary: Variables listed in "environment" are not applied.

Steps to reproduce:

  1. Add to launch.json "environment" variables according to the example
  2. Start debugging for the appearance of a debugging terminal
  3. in the debugging terminal, run $ printenv ZET_ENABLE_PROGRAM_DEBUGGING Expected: "1" Actual: "" image

extra: https://github.com/microsoft/vscode/issues/177857

Debugger Configurations

my launch.json:

{
    "configurations": [
        {
            "comments": [
                "Full launch.json configuration details can be found here:",
                "https://code.visualstudio.com/docs/cpp/launch-json-reference"
            ],
            "name": "(gdb-oneapi) array-transform Launch",
            "type": "cppdbg",
            "request": "launch",
            "preLaunchTask": "",
            "postDebugTask": "",
            "program": "/home/user/array-transform/src/array-transform",
            "args": [
                "gpu"
            ],
            "stopAtEntry": true,
            "cwd": "${workspaceFolder}",
            "environment": [
                {
                    "name": "ZET_ENABLE_PROGRAM_DEBUGGING", "value": "1"
                },
                {
                    "name": "IGC_EnableGTLocationDebugging", "value": "1"
                }
            ],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "gdb-oneapi",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description": "Disable target async",
                    "text": "set target-async off",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

### Debugger Logs

```shell
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (203) LaunchOptions{\"comments\":[\"Full launch.json configuration details can be found here:\",\"https://code.visualstudio.com/docs/cpp/launch-json-reference\"],\"name\":\"(gdb-oneapi) array-transform Launch\",\"type\":\"cppdbg\",\"request\":\"launch\",\"preLaunchTask\":\"\",\"postDebugTask\":\"\",\"program\":\"/home/user/array-transform/src/array-transform\",\"args\":[\"gpu\"],\"stopAtEntry\":true,\"cwd\":\"/home/user/array-transform\",\"environment\":[{\"name\":\"ZET_ENABLE_PROGRAM_DEBUGGING\",\"value\":\"1\"},{\"name\":\"IGC_EnableGTLocationDebugging\",\"value\":\"1\"}],\"externalConsole\":false,\"MIMode\":\"gdb\",\"miDebuggerPath\":\"gdb-oneapi\",\"logging\":{\"engineLogging\":true,\"trace\":true,\"traceResponse\":true},\"setupCommands\":[{\"description\":\"Enable pretty-printing for gdb\",\"text\":\"-enable-pretty-printing\",\"ignoreFailures\":true},{\"description\":\"Disable target async\",\"text\":\"set target-async off\",\"ignoreFailures\":true}],\"__configurationTarget\":6,\"__sessionId\":\"a71e368f-4a83-4b87-a000-e9c62be6821a\"}\n"},"seq":2}
1: (203) LaunchOptions{"comments":["Full launch.json configuration details can be found here:","https://code.visualstudio.com/docs/cpp/launch-json-reference"],"name":"(gdb-oneapi) array-transform Launch","type":"cppdbg","request":"launch","preLaunchTask":"","postDebugTask":"","program":"/home/user/array-transform/src/array-transform","args":["gpu"],"stopAtEntry":true,"cwd":"/home/user/array-transform","environment":[{"name":"ZET_ENABLE_PROGRAM_DEBUGGING","value":"1"},{"name":"IGC_EnableGTLocationDebugging","value":"1"}],"externalConsole":false,"MIMode":"gdb","miDebuggerPath":"gdb-oneapi","logging":{"engineLogging":true,"trace":true,"traceResponse":true},"setupCommands":[{"description":"Enable pretty-printing for gdb","text":"-enable-pretty-printing","ignoreFailures":true},{"description":"Disable target async","text":"set target-async off","ignoreFailures":true}],"__configurationTarget":6,"__sessionId":"a71e368f-4a83-4b87-a000-e9c62be6821a"}
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (292) DbgCmd:echo $$ > /tmp/Microsoft-MIEngine-Pid-cto1iyqw.hze ; cd \"/home/user/array-transform/src\" ; DbgTerm=`tty` ; set -o monitor ; trap 'rm \"/tmp/Microsoft-MIEngine-In-e1g0ixqn.4gz\" \"/tmp/Microsoft-MIEngine-Out-nmw4mgzj.a4d\" \"/tmp/Microsoft-MIEngine-Pid-cto1iyqw.hze\" \"/tmp/Microsoft-MIEngine-Cmd-j5obmz2o.0vg\"' EXIT ; \"/home/gta/intel/oneapi/debugger/2023.0.0/gdb/intel64/bin/gdb-oneapi\" --interpreter=mi --tty=$DbgTerm < \"/tmp/Microsoft-MIEngine-In-e1g0ixqn.4gz\" > \"/tmp/Microsoft-MIEngine-Out-nmw4mgzj.a4d\" & clear; pid=$! ; echo $pid > \"/tmp/Microsoft-MIEngine-Pid-cto1iyqw.hze\" ; wait $pid; \n"},"seq":4}
1: (292) DbgCmd:echo $$ > /tmp/Microsoft-MIEngine-Pid-cto1iyqw.hze ; cd "/home/user/array-transform/src" ; DbgTerm=`tty` ; set -o monitor ; trap 'rm "/tmp/Microsoft-MIEngine-In-e1g0ixqn.4gz" "/tmp/Microsoft-MIEngine-Out-nmw4mgzj.a4d" "/tmp/Microsoft-MIEngine-Pid-cto1iyqw.hze" "/tmp/Microsoft-MIEngine-Cmd-j5obmz2o.0vg"' EXIT ; "/home/gta/intel/oneapi/debugger/2023.0.0/gdb/intel64/bin/gdb-oneapi" --interpreter=mi --tty=$DbgTerm < "/tmp/Microsoft-MIEngine-In-e1g0ixqn.4gz" > "/tmp/Microsoft-MIEngine-Out-nmw4mgzj.a4d" & clear; pid=$! ; echo $pid > "/tmp/Microsoft-MIEngine-Pid-cto1iyqw.hze" ; wait $pid;
--> C (runInTerminal-6): {"type":"request","command":"runInTerminal","arguments":{"kind":"integrated","title":"cppdbg: array-transform","cwd":"","args":["/bin/sh","/tmp/Microsoft-MIEngine-Cmd-j5obmz2o.0vg"],"env":{}},"seq":6}
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (311) Wait for connection completion.\n"},"seq":8}
1: (311) Wait for connection completion.
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2188) ->=thread-group-added,id=\"i1\"\n"},"seq":10}
1: (2188) ->=thread-group-added,id="i1"
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2192) ->~\"GNU gdb (Intel(R) distribution for GDB* ) 12.1\\n\"\n"},"seq":12}
1: (2192) ->~"GNU gdb (Intel(R) distribution for GDB* ) 12.1\n"
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2193) ->~\"Copyright (C) 2023 Free Software Foundation, Inc.; (C) 2023 Intel Corp.\\n\"\n"},"seq":14}
1: (2193) ->~"Copyright (C) 2023 Free Software Foundation, Inc.; (C) 2023 Intel Corp.\n"
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2193) ->~\"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\\nThis is free software: you are free to change and redistribute it.\\nThere is NO WARRANTY, to the extent permitted by law.\"\n"},"seq":16}
1: (2193) ->~"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law."
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2193) ->~\"\\nType \\\"show copying\\\" and \\\"show warranty\\\" for details.\\n\"\n"},"seq":18}
1: (2193) ->~"\nType \"show copying\" and \"show warranty\" for details.\n"
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2194) ->~\"This GDB was configured as \\\"x86_64-pc-linux-gnu\\\".\\n\"\n"},"seq":20}
1: (2194) ->~"This GDB was configured as \"x86_64-pc-linux-gnu\".\n"
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2194) ->~\"Type \\\"show configuration\\\" for configuration details.\\n\"\n"},"seq":22}
1: (2194) ->~"Type \"show configuration\" for configuration details.\n"
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2194) ->~\"\\nFor information about how to find Technical Support, Product Updates,\\nUser Forums, FAQs, tips and tricks, and other support information, please visit:\\n\"\n"},"seq":24}
1: (2194) ->~"\nFor information about how to find Technical Support, Product Updates,\nUser Forums, FAQs, tips and tricks, and other support information, please visit:\n"
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2195) ->~\"<https://www.gnu.org/software/gdb/bugs/>.\\n\"\n"},"seq":26}
1: (2195) ->~"<https://www.gnu.org/software/gdb/bugs/>.\n"
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2195) ->~\"For help, type \\\"help\\\".\\n\"\n"},"seq":28}
1: (2195) ->~"For help, type \"help\".\n"
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2196) ->~\"Type \\\"apropos word\\\" to search for commands related to \\\"word\\\".\\n\"\n"},"seq":30}
1: (2196) ->~"Type \"apropos word\" to search for commands related to \"word\".\n"
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2196) ->=cmd-param-changed,param=\"auto-load safe-path\",value=\"/\"\n"},"seq":32}
1: (2196) ->=cmd-param-changed,param="auto-load safe-path",value="/"
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2196) ->(gdb)\n"},"seq":34}
1: (2196) ->(gdb)
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2210) <-1001-gdb-set mi-async on\n"},"seq":36}
1: (2210) <-1001-gdb-set mi-async on
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2211) ->1001^done\n"},"seq":38}
1: (2211) ->1001^done
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2212) ->(gdb)\n"},"seq":40}
1: (2212) ->(gdb)
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2215) 1001: elapsed time 7\n"},"seq":42}
1: (2215) 1001: elapsed time 7
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2232) <-1002-enable-pretty-printing\n"},"seq":44}
1: (2232) <-1002-enable-pretty-printing
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2232) ->1002^done\n"},"seq":46}
1: (2232) ->1002^done
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2233) ->(gdb)\n"},"seq":48}
1: (2233) ->(gdb)
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2233) 1002: elapsed time 1\n"},"seq":50}
1: (2233) 1002: elapsed time 1
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2235) <-1003-interpreter-exec console \"set target-async off\"\n"},"seq":52}
1: (2235) <-1003-interpreter-exec console "set target-async off"
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2236) ->~\"Warning: 'set target-async', an alias for the command 'set mi-async', is deprecated.\\n\"\n"},"seq":54}
1: (2236) ->~"Warning: 'set target-async', an alias for the command 'set mi-async', is deprecated.\n"
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2237) ->~\"Use 'set mi-async'.\\n\\n\"\n"},"seq":56}
1: (2237) ->~"Use 'set mi-async'.\n\n"
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2237) ->=cmd-param-changed,param=\"mi-async\",value=\"off\"\n"},"seq":58}
1: (2237) ->=cmd-param-changed,param="mi-async",value="off"
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2237) ->1003^done\n"},"seq":60}
1: (2237) ->1003^done
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2238) ->(gdb)\n"},"seq":62}
1: (2238) ->(gdb)
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2238) 1003: elapsed time 2\n"},"seq":64}
1: (2238) 1003: elapsed time 2
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2239) <-1004-interpreter-exec console \"set pagination off\"\n"},"seq":66}
1: (2239) <-1004-interpreter-exec console "set pagination off"
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2240) ->=cmd-param-changed,param=\"pagination\",value=\"off\"\n"},"seq":68}
1: (2240) ->=cmd-param-changed,param="pagination",value="off"
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2241) ->1004^done\n"},"seq":70}
1: (2241) ->1004^done
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2241) ->(gdb)\n"},"seq":72}
1: (2241) ->(gdb)
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2241) 1004: elapsed time 2\n"},"seq":74}
1: (2241) 1004: elapsed time 2
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2242) <-1005-gdb-set auto-solib-add on\n"},"seq":76}
1: (2242) <-1005-gdb-set auto-solib-add on
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2242) ->1005^done\n"},"seq":78}
1: (2242) ->1005^done
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2243) ->(gdb)\n"},"seq":80}
1: (2243) ->(gdb)
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2243) 1005: elapsed time 1\n"},"seq":82}
1: (2243) 1005: elapsed time 1
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2243) <-1006-gdb-set solib-search-path /home/user/array-transform/src:\n"},"seq":84}
1: (2243) <-1006-gdb-set solib-search-path /home/user/array-transform/src:
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2244) ->1006^done\n"},"seq":86}
1: (2244) ->1006^done
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2244) ->(gdb)\n"},"seq":88}
1: (2244) ->(gdb)
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2244) 1006: elapsed time 1\n"},"seq":90}
1: (2244) 1006: elapsed time 1
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2244) <-1007-gdb-set stop-on-solib-events 1\n"},"seq":92}
1: (2244) <-1007-gdb-set stop-on-solib-events 1
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2245) ->1007^done\n"},"seq":94}
1: (2245) ->1007^done
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2245) ->(gdb)\n"},"seq":96}
1: (2245) ->(gdb)
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2246) 1007: elapsed time 1\n"},"seq":98}
1: (2246) 1007: elapsed time 1
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2246) <-1008-environment-cd /home/user/array-transform\n"},"seq":100}
1: (2246) <-1008-environment-cd /home/user/array-transform
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2247) ->1008^done\n"},"seq":102}
1: (2247) ->1008^done
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2247) ->(gdb)\n"},"seq":104}
1: (2247) ->(gdb)
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2247) 1008: elapsed time 1\n"},"seq":106}
1: (2247) 1008: elapsed time 1
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2247) <-1009-file-exec-and-symbols /home/user/array-transform/src/array-transform\n"},"seq":108}
1: (2247) <-1009-file-exec-and-symbols /home/user/array-transform/src/array-transform
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2270) ->1009^done\n"},"seq":110}
1: (2270) ->1009^done
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2270) ->(gdb)\n"},"seq":112}
1: (2270) ->(gdb)
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2271) 1009: elapsed time 23\n"},"seq":114}
1: (2271) 1009: elapsed time 23
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2271) <-1010-interpreter-exec console \"show architecture\"\n"},"seq":116}
1: (2271) <-1010-interpreter-exec console "show architecture"
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2272) ->~\"The target architecture is set to \\\"auto\\\" (currently \\\"i386:x86-64\\\").\\n\"\n"},"seq":118}
1: (2272) ->~"The target architecture is set to \"auto\" (currently \"i386:x86-64\").\n"
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2272) ->1010^done\n"},"seq":120}
1: (2272) ->1010^done
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2272) ->(gdb)\n"},"seq":122}
1: (2272) ->(gdb)
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2272) 1010: elapsed time 1\n"},"seq":124}
1: (2272) 1010: elapsed time 1
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2275) <-1011-exec-arguments gpu\n"},"seq":126}
1: (2275) <-1011-exec-arguments gpu
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2276) ->1011^done\n"},"seq":128}
1: (2276) ->1011^done
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2276) ->(gdb)\n"},"seq":130}
1: (2276) ->(gdb)
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2276) 1011: elapsed time 1\n"},"seq":132}
1: (2276) 1011: elapsed time 1
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2277) <-1012-break-insert -f main\n"},"seq":134}
1: (2277) <-1012-break-insert -f main
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2348) ->1012^done,bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"0x0000000000404829\",func=\"main(int, char**)\",file=\"array-transform.cpp\",fullname=\"/home/user/array-transform/src/array-transform.cpp\",line=\"28\",thread-groups=[\"i1\"],times=\"0\",original-location=\"main\"}\n"},"seq":136}
1: (2348) ->1012^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x0000000000404829",func="main(int, char**)",file="array-transform.cpp",fullname="/home/user/array-transform/src/array-transform.cpp",line="28",thread-groups=["i1"],times="0",original-location="main"}
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2349) ->(gdb)\n"},"seq":138}
1: (2349) ->(gdb)
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2364) 1012: elapsed time 87\n"},"seq":140}
1: (2364) 1012: elapsed time 87
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2366) <-1013-interpreter-exec console \"set env ZET_ENABLE_PROGRAM_DEBUGGING 1\"\n"},"seq":142}
1: (2366) <-1013-interpreter-exec console "set env ZET_ENABLE_PROGRAM_DEBUGGING 1"
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2367) ->1013^done\n"},"seq":144}
1: (2367) ->1013^done
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2367) ->(gdb)\n"},"seq":146}
1: (2367) ->(gdb)
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2367) 1013: elapsed time 1\n"},"seq":148}
1: (2367) 1013: elapsed time 1
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2368) <-1014-interpreter-exec console \"set env IGC_EnableGTLocationDebugging 1\"\n"},"seq":150}
1: (2368) <-1014-interpreter-exec console "set env IGC_EnableGTLocationDebugging 1"
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2368) ->1014^done\n"},"seq":152}
1: (2368) ->1014^done
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2369) ->(gdb)\n"},"seq":154}
1: (2369) ->(gdb)
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2369) 1014: elapsed time 1\n"},"seq":156}
1: (2369) 1014: elapsed time 1
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2379) Send Event AD7EngineCreateEvent\n"},"seq":158}
1: (2379) Send Event AD7EngineCreateEvent
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2382) Send Event AD7ProgramCreateEvent\n"},"seq":160}
1: (2382) Send Event AD7ProgramCreateEvent
--> E (output): {"type":"event","event":"output","body":{"category":"telemetry","output":"VS/Diagnostics/Debugger/Launch","data":{"VS.Diagnostics.Debugger.ImplementationName":"Microsoft.MIDebugEngine","VS.Diagnostics.Debugger.EngineVersion":"17.4.21117.1","VS.Diagnostics.Debugger.HostVersion":"17.4.21117.1","VS.Diagnostics.Debugger.AdapterId":"cppdbg","VS.Diagnostics.Debugger.Launch.Duration":2202,"VS.Diagnostics.Debugger.MIMode":"gdb","VS.Diagnostics.Debugger.FrameworkVersion":"6.0.1122.52304"}},"seq":162}
--> R (launch-2): {"type":"response","request_seq":2,"success":true,"command":"launch","body":{},"seq":164}
--> E (initialized): {"type":"event","event":"initialized","body":{},"seq":166}
<--   R (runInTerminal-6) [2105 ms]: {"type":"response","seq":3,"command":"runInTerminal","request_seq":6,"success":true,"body":{"shellProcessId":16355}}
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2419) ShellPid=16371\n"},"seq":169}
1: (2419) ShellPid=16371
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2420) DebuggerPid=16373\n"},"seq":171}
1: (2420) DebuggerPid=16373
<--   C (setBreakpoints-4): {"command":"setBreakpoints","arguments":{"source":{"name":"array-transform.cpp","path":"/home/user/array-transform/src/array-transform.cpp"},"lines":[54,57,59],"breakpoints":[{"line":54},{"line":57,"condition":"-break-insert -p 138 -l 4"},{"line":59,"condition":"-break-insert -p 138 -l 4"}],"sourceModified":false},"type":"request","seq":4}
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2808) <-1015-break-insert -f array-transform.cpp:54\n"},"seq":174}
1: (2808) <-1015-break-insert -f array-transform.cpp:54
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2809) ->1015^done,bkpt={number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"0x0000000000407373\",func=\"main::{lambda(auto:1&)#1}::operator()<sycl::_V1::handler>(sycl::_V1::handler&) const::{lambda(sycl::_V1::id<1>)#1}::operator()(sycl::_V1::id<1>) const\",file=\"array-transform.cpp\",fullname=\"/home/user/array-transform/src/array-transform.cpp\",line=\"54\",thread-groups=[\"i1\"],times=\"0\",original-location=\"array-transform.cpp:54\"}\n"},"seq":176}
1: (2809) ->1015^done,bkpt={number="2",type="breakpoint",disp="keep",enabled="y",addr="0x0000000000407373",func="main::{lambda(auto:1&)#1}::operator()<sycl::_V1::handler>(sycl::_V1::handler&) const::{lambda(sycl::_V1::id<1>)#1}::operator()(sycl::_V1::id<1>) const",file="array-transform.cpp",fullname="/home/user/array-transform/src/array-transform.cpp",line="54",thread-groups=["i1"],times="0",original-location="array-transform.cpp:54"}
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2809) ->(gdb)\n"},"seq":178}
1: (2809) ->(gdb)
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2810) 1015: elapsed time 2\n"},"seq":180}
1: (2810) 1015: elapsed time 2
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2824) <-1016-symbol-list-lines /home/user/array-transform/src/array-transform.cpp\n"},"seq":182}
1: (2824) <-1016-symbol-list-lines /home/user/array-transform/src/array-transform.cpp
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2825) ->1016^done,lines=[]\n"},"seq":184}
1: (2825) ->1016^done,lines=[]
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2825) ->(gdb)\n"},"seq":186}
1: (2825) ->(gdb)
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2829) 1016: elapsed time 4\n"},"seq":188}
1: (2829) 1016: elapsed time 4
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2830) <-1017-symbol-list-lines array-transform.cpp\n"},"seq":190}
1: (2830) <-1017-symbol-list-lines array-transform.cpp
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2831) ->1017^done,lines=[]\n"},"seq":192}
1: (2831) ->1017^done,lines=[]
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2831) ->(gdb)\n"},"seq":194}
1: (2831) ->(gdb)
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2831) 1017: elapsed time 1\n"},"seq":196}
1: (2831) 1017: elapsed time 1
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2837) Send Event AD7BreakpointBoundEvent\n"},"seq":198}
1: (2837) Send Event AD7BreakpointBoundEvent
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2842) <-1018-break-insert -f -c \"-break-insert -p 138 -l 4\" array-transform.cpp:57\n"},"seq":200}
1: (2842) <-1018-break-insert -f -c "-break-insert -p 138 -l 4" array-transform.cpp:57
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2845) ->1018^error,msg=\"No symbol \\\"break\\\" in current context.\"\n"},"seq":202}
1: (2845) ->1018^error,msg="No symbol \"break\" in current context."
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2845) ->(gdb)\n"},"seq":204}
1: (2845) ->(gdb)
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2845) 1018: elapsed time 2\n"},"seq":206}
1: (2845) 1018: elapsed time 2
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2846) Send Event AD7BreakpointErrorEvent\n"},"seq":208}
1: (2846) Send Event AD7BreakpointErrorEvent
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2847) <-1019-break-insert -f -c \"-break-insert -p 138 -l 4\" array-transform.cpp:59\n"},"seq":210}
1: (2847) <-1019-break-insert -f -c "-break-insert -p 138 -l 4" array-transform.cpp:59
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2849) ->1019^error,msg=\"No symbol \\\"break\\\" in current context.\"\n"},"seq":212}
1: (2849) ->1019^error,msg="No symbol \"break\" in current context."
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2849) ->(gdb)\n"},"seq":214}
1: (2849) ->(gdb)
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2849) 1019: elapsed time 1\n"},"seq":216}
1: (2849) 1019: elapsed time 1
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2849) Send Event AD7BreakpointErrorEvent\n"},"seq":218}
1: (2849) Send Event AD7BreakpointErrorEvent
--> R (setBreakpoints-4): {"type":"response","request_seq":4,"success":true,"command":"setBreakpoints","body":{"breakpoints":[{"id":1,"verified":true,"line":54,"BoundBreakpoints":[]},{"id":2,"verified":true,"line":57,"BoundBreakpoints":[]},{"id":3,"verified":true,"line":59,"BoundBreakpoints":[]}]},"seq":220}
--> E (breakpoint): {"type":"event","event":"breakpoint","body":{"reason":"changed","breakpoint":{"id":1,"verified":true,"line":54,"BoundBreakpoints":[]}},"seq":222}
--> E (breakpoint): {"type":"event","event":"breakpoint","body":{"reason":"changed","breakpoint":{"id":2,"verified":false,"message":"Condition \"-break-insert -p 138 -l 4\" : No symbol \"break\" in current context.","line":57,"BoundBreakpoints":[]}},"seq":224}
--> E (breakpoint): {"type":"event","event":"breakpoint","body":{"reason":"changed","breakpoint":{"id":3,"verified":false,"message":"Condition \"-break-insert -p 138 -l 4\" : No symbol \"break\" in current context.","line":59,"BoundBreakpoints":[]}},"seq":226}
<--   C (setFunctionBreakpoints-5): {"command":"setFunctionBreakpoints","arguments":{"breakpoints":[]},"type":"request","seq":5}
--> R (setFunctionBreakpoints-5): {"type":"response","request_seq":5,"success":true,"command":"setFunctionBreakpoints","body":{"breakpoints":[]},"seq":229}
<--   C (setDataBreakpoints-6): {"command":"setDataBreakpoints","arguments":{"breakpoints":[]},"type":"request","seq":6}
--> R (setDataBreakpoints-6): {"type":"response","request_seq":6,"success":true,"command":"setDataBreakpoints","body":{"breakpoints":[]},"seq":232}
<--   C (setInstructionBreakpoints-7): {"command":"setInstructionBreakpoints","arguments":{"breakpoints":[]},"type":"request","seq":7}
--> R (setInstructionBreakpoints-7): {"type":"response","request_seq":7,"success":true,"command":"setInstructionBreakpoints","body":{"breakpoints":[]},"seq":235}
<--   C (setExceptionBreakpoints-8): {"command":"setExceptionBreakpoints","arguments":{"filters":[],"filterOptions":[]},"type":"request","seq":8}
--> R (setExceptionBreakpoints-8): {"type":"response","request_seq":8,"success":true,"command":"setExceptionBreakpoints","body":{"breakpoints":[]},"seq":238}
<--   C (configurationDone-9): {"command":"configurationDone","type":"request","seq":9}
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (3120) Send Event AD7LoadCompleteEvent\n"},"seq":242}
1: (3120) Send Event AD7LoadCompleteEvent
--> R (configurationDone-9): {"type":"response","request_seq":9,"success":true,"command":"configurationDone","body":{},"seq":241}
--> E (output): {"type":"event","event":"output","body":{"category":"stdout","output":"=thread-group-added,id=\"i1\"\nGNU gdb (Intel(R) distribution for GDB* ) 12.1\nCopyright (C) 2023 Free Software Foundation, Inc.; (C) 2023 Intel Corp.\nLicense GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.\nType \"show copying\" and \"show warranty\" for details.\nThis GDB was configured as \"x86_64-pc-linux-gnu\".\nType \"show configuration\" for configuration details.\n\nFor information about how to find Technical Support, Product Updates,\nUser Forums, FAQs, tips and tricks, and other support information, please visit:\n<https://www.gnu.org/software/gdb/bugs/>.\nFor help, type \"help\".\nType \"apropos word\" to search for commands related to \"word\".\n=cmd-param-changed,param=\"auto-load safe-path\",value=\"/\"\nWarning: Debuggee TargetArchitecture not detected, assuming x86_64.\n=cmd-param-changed,param=\"pagination\",value=\"off\"\n"},"seq":245}
=thread-group-added,id="i1"

Other Extensions

No response

Additional Information

No response

sbobko commented 1 year ago

@sean-mcmanus , @browntarik @Colengms Could you help me to sort out this problem?

sean-mcmanus commented 1 year ago

@WardenGnaw Are you able to help?

WardenGnaw commented 1 year ago

From the logs I can see GDB setting it to its debug session.

--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2366) <-1013-interpreter-exec console \"set env ZET_ENABLE_PROGRAM_DEBUGGING 1\"\n"},"seq":142} 1: (2366) <-1013-interpreter-exec console "set env ZET_ENABLE_PROGRAM_DEBUGGING 1" --> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (2368) <-1014-interpreter-exec console \"set env IGC_EnableGTLocationDebugging 1\"\n"},"seq":150} 1: (2368) <-1014-interpreter-exec console "set env IGC_EnableGTLocationDebugging 1"

These variables are expected to only live in the debugee process. They should be set in the created process' environment before it starts up. They are not set in the terminal.

sbobko commented 1 year ago

Hello @WardenGnaw , this is exactly the problem, environment variables are not set for the process being debugged. I found out this because without these environment variables, debugging the GPU kernel is impossible. However, everything works if I set variables in the Debug console manually.

github-actions[bot] commented 1 year ago

This issue has been closed because the described behavior was determined to be by design.

WardenGnaw commented 1 year ago

With this example program, I was able to see the environment set by environment.

#include <iostream>
int main(int argc, char **argv, char **envp)
{
   for (char **env = envp; *env != 0; env++)
   {
      char *thisEnv = *env;
      printf("%s\n", thisEnv);
   }
   return 0;
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/a.out",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [
                {
                    "name": "ZET_ENABLE_PROGRAM_DEBUGGING", "value": "1"
                },
                {
                    "name": "IGC_EnableGTLocationDebugging", "value": "1"
                }
            ],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description": "Set Disassembly Flavor to Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

Terminal Output:

SHELL=/bin/bash
COLORTERM=truecolor
WSL2_GUI_APPS_ENABLED=1
TERM_PROGRAM_VERSION=1.77.1
WSL_DISTRO_NAME=Ubuntu
ZET_ENABLE_PROGRAM_DEBUGGING=1
...
DISPLAY=:0
SHLVL=2
IGC_EnableGTLocationDebugging=1