LoginSignup
18
13

More than 3 years have passed since last update.

VSCodeでライブラリの中身まで入ってデバッグする設定

Posted at

TL;DR

launch.jsonのconfigurationに「"justMyCode":false」を追加します。

"justMyCode": false

背景

オープンソースのライブラリでエラーメッセージが適応される範囲がでかすぎ、自分でソースコードを当たらないといけないときが多々あります。
GitHubがジャンプ機能を搭載してくれて、GitHub上でプログラムの流れを手動でおっていくのもなくはないんですが、デバッグツールを使ったほうが圧倒的に早いです。

やり方

VSCodeを開いて、F1(もしくはCtrl+Shift+Rか、クリックするか)でconsoleを開き、

Debug: Open launch.json

と打ってlaunch.jsonを開きます。configurationの下に"justMyCode": falseと追加します。

{
    // 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": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "justMyCode": false #ここを追加
        }
    ],
}

ちなみにjsonはコメントアウトできないので実際は#以下はかいてはいけません。

また、最初にGUIでやる方法も試しましたが、上手く動いてくれませんでした。
もしかしたらpythonだけかもしれないです。

breakpointを好きに置いて変数の中身確認しながら巨人の作ったライブラリを堪能しましょう。

参考

18
13
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
18
13