-
Notifications
You must be signed in to change notification settings - Fork 79
Implement debugger options just_my_code and internal frame filtering
#677
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,6 +60,7 @@ namespace xpyt | |
| , m_debugpy_port("") | ||
| , m_debugger_config(debugger_config) | ||
| { | ||
| std::cout << "Debugger Config: " << m_debugger_config << std::endl; | ||
| m_debugpy_port = xeus::find_free_port(100, 5678, 5900); | ||
| register_request_handler("inspectVariables", std::bind(&debugger::inspect_variables_request, this, _1), false); | ||
| register_request_handler("richInspectVariables", std::bind(&debugger::rich_inspect_variables_request, this, _1), false); | ||
|
|
@@ -68,6 +69,25 @@ namespace xpyt | |
| register_request_handler("copyToGlobals", std::bind(&debugger::copy_to_globals_request, this, _1), true); | ||
| register_request_handler("modules", std::bind(&debugger::modules, this, _1), false); | ||
|
|
||
| // Load internal module paths from debugger_config | ||
| if (m_debugger_config.contains("internalModulePaths")) | ||
| { | ||
| for (const auto& p : m_debugger_config["internalModulePaths"]) | ||
| { | ||
| m_internal_modules.push_back(p.get<std::string>()); | ||
| } | ||
| } | ||
|
|
||
| // Load options | ||
| if (m_debugger_config.contains("justMyCode")) | ||
| { | ||
| m_just_my_code = m_debugger_config["justMyCode"].get<bool>(); | ||
| } | ||
|
|
||
| if (m_debugger_config.contains("filterInternalFrames")) | ||
| { | ||
| m_filter_internal_frames = m_debugger_config["filterInternalFrames"].get<bool>(); | ||
| } | ||
|
||
| } | ||
|
|
||
| debugger::~debugger() | ||
|
|
@@ -176,6 +196,24 @@ namespace xpyt | |
| {"port", std::stoi(m_debugpy_port)} | ||
| }; | ||
| new_message["arguments"]["logToFile"] = true; | ||
|
|
||
| // Add DebugStdLib when not just-my-code | ||
| if (!m_just_my_code) | ||
| { | ||
| new_message["arguments"]["debugOptions"] = {"DebugStdLib"}; | ||
| } | ||
|
|
||
| // Dynamic skip rules | ||
| if (m_filter_internal_frames) | ||
| { | ||
| nl::json rules = nl::json::array(); | ||
| for (const auto& path : m_internal_modules) | ||
| { | ||
| rules.push_back({{"path", path}, {"include", false}}); | ||
| } | ||
| new_message["arguments"]["rules"] = rules; | ||
| } | ||
|
|
||
| return forward_message(new_message); | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -81,6 +81,21 @@ namespace xpyt | |
|
|
||
| instanciate_ipython_shell(); | ||
|
|
||
| py::dict modules = sys.attr("modules"); | ||
| std::vector<std::string> internal_mod_paths; | ||
| internal_mod_paths.reserve(len(modules)); | ||
|
|
||
| for (auto item : modules) | ||
| { | ||
| py::object mod = py::reinterpret_borrow<py::object>(item.second); | ||
| if (py::hasattr(mod, "__file__")) | ||
| { | ||
| std::string path = mod.attr("__file__").cast<std::string>(); | ||
| internal_mod_paths.push_back(path); | ||
| } | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should also do this for interpreter-raw
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done as a part of 40d3beb |
||
|
|
||
|
|
||
| m_ipython_shell_app.attr("initialize")(use_jedi_for_completion()); | ||
| m_ipython_shell = m_ipython_shell_app.attr("shell"); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this?
I don't see an equivalent of this in the ipykernel PR