Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions include/xeus-python/xdebugger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ namespace xpyt
py::object m_pydebugger;
xeus::xthread m_client_runner;
bool m_copy_to_globals_available;

bool m_just_my_code = false;
bool m_filter_internal_frames = false;
std::vector<std::string> m_internal_modules;
};

XEUS_PYTHON_API
Expand Down
38 changes: 38 additions & 0 deletions src/xdebugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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>());
}
}
Copy link
Member

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


// 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>();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't seem this code path will ever be reached? I understand the debugger_config is only internal and it cannot be set from the outside, so those if condition will never be true?

}

debugger::~debugger()
Expand Down Expand Up @@ -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);
}

Expand Down
15 changes: 15 additions & 0 deletions src/xinterpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also do this for interpreter-raw

Copy link
Contributor Author

@arjxn-py arjxn-py Dec 10, 2025

Choose a reason for hiding this comment

The 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");

Expand Down
Loading