Search code examples
visual-studio-codecallstack

How can navigate a callstack from a log in Visual Studio Code?


If I have a log file (from a crash reporter), how can I make it so I can easily navigate the callstack in Visual Studio Code? It's just a list of files with line numbers:

c:\agent\build\source\game\game_sdl.cpp:1485 in StepFrame
c:\agent\build\source\game\game_sdl.cpp:1942 in game_sdl_main
c:\agent\build\source\sdl2\src\main\windows\SDL_windows_main.c:82 in main_getcmdline
c:\agent\build\source\sdl2\src\main\windows\SDL_windows_main.c:98 in main
...\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288 in __scrt_common_main_seh

I don't have a crash dump.

I have an answer for Visual Studio, but I'd like a solution for people on my team who use vscode. The extensions and options are completely different between VS and vscode, so I need a different solution. (There's no External Tools menu in vscode.)


Solution

  • In Visual Studio Code, you can setup commands as Tasks.

    Open your workspace tasks (Ctrl-Shift-p Open Workspace Tasks). Inside the "tasks": [] list, add this task:

                {
                    "label": "Dump Clipboard",
                    "type": "shell",
                    "command": "Powershell.exe",
                    "detail": "Send clipboard to Terminal -- make callstacks ctrl-clickable.",
                    "args": [
                        "Get-Clipboard"
                    ],
                    "problemMatcher": []
                },
    

    Now you can copy the part of the log containing the list of files and Ctrl-Shift-p Run Task Enter Dump Clipboard Enter to run the task. It will dump whatever was on your clipboard into the Terminal window. Jump to files (and lines) in the Terminal Window with Ctrl-click.