Skip to content
Open
Show file tree
Hide file tree
Changes from 10 commits
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
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"files.associations": {
"iostream": "cpp"
}
}
15 changes: 11 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ else()
configure_native_kernel("/share/jupyter/kernels/xcpp17/")
configure_native_kernel("/share/jupyter/kernels/xcpp20/")
configure_native_kernel("/share/jupyter/kernels/xcpp23/")
configure_native_kernel("/share/jupyter/kernels/xcpp17-debugger/")
endif()

# Source files
Expand All @@ -193,6 +194,7 @@ set(XEUS_CPP_HEADERS
include/xeus-cpp/xmagics.hpp
include/xeus-cpp/xoptions.hpp
include/xeus-cpp/xpreamble.hpp
include/xeus-cpp/xdebugger.hpp
#src/xinspect.hpp
#src/xsystem.hpp
#src/xparser.hpp
Expand All @@ -207,6 +209,9 @@ set(XEUS_CPP_SRC
src/xparser.cpp
src/xutils.cpp
src/xmagics/os.cpp
src/xdebugger.cpp
src/xinternal_utils.cpp
src/xdebuglldb_client.cpp
)

if(NOT EMSCRIPTEN)
Expand Down Expand Up @@ -458,11 +463,13 @@ include(CMakePackageConfigHelpers)

set(XEUS_CPP_CMAKECONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" CACHE STRING "install path for xeus-cppConfig.cmake")

install(DIRECTORY ${XCPP_TAGFILES_DIR}
DESTINATION ${XEUS_CPP_DATA_DIR})
if(NOT EMSCRIPTEN)
install(DIRECTORY ${XCPP_TAGFILES_DIR}
DESTINATION ${XEUS_CPP_DATA_DIR})

install(DIRECTORY ${XCPP_TAGCONFS_DIR}
DESTINATION ${XEUS_CPP_CONF_DIR})
install(DIRECTORY ${XCPP_TAGCONFS_DIR}
DESTINATION ${XEUS_CPP_CONF_DIR})
endif()

# Install xeus-cpp and xeus-cpp-static
if (XEUS_CPP_BUILD_SHARED)
Expand Down
86 changes: 86 additions & 0 deletions include/xeus-cpp/xdebugger.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/************************************************************************************
* Copyright (c) 2023, xeus-cpp contributors *
* Copyright (c) 2023, Johan Mabille, Loic Gouarin, Sylvain Corlay, Wolf Vollprecht *
* *
* Distributed under the terms of the BSD 3-Clause License. *
* *
* The full license is in the file LICENSE, distributed with this software. *
************************************************************************************/

#ifndef XEUS_CPP_DEBUGGER_HPP
#define XEUS_CPP_DEBUGGER_HPP

Choose a reason for hiding this comment

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

warning: header guard does not follow preferred style [llvm-header-guard]

Suggested change
#define XEUS_CPP_DEBUGGER_HPP
#ifndef XEUS_CPP_XDEBUGGER_HPP
#define XEUS_CPP_XDEBUGGER_HPP


#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wattributes"
#endif

#include <map>
#include <mutex>

Choose a reason for hiding this comment

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

warning: included header map is not used directly [misc-include-cleaner]

Suggested change
#include <mutex>
#include <mutex>

#include <set>

Choose a reason for hiding this comment

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

warning: included header mutex is not used directly [misc-include-cleaner]

Suggested change
#include <set>
#include <set>

#include <string>

Choose a reason for hiding this comment

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

warning: included header set is not used directly [misc-include-cleaner]

Suggested change
#include <string>
#include <string>


#include "nlohmann/json.hpp"
#include "xeus-zmq/xdebugger_base.hpp"

Choose a reason for hiding this comment

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

warning: included header json.hpp is not used directly [misc-include-cleaner]

Suggested change
#include "xeus-zmq/xdebugger_base.hpp"
#include "xeus-zmq/xdebugger_base.hpp"

#include "xeus_cpp_config.hpp"

namespace xcpp
{
class xdebuglldb_client;

class XEUS_CPP_API debugger : public xeus::xdebugger_base

Choose a reason for hiding this comment

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

warning: class 'debugger' defines a destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]

    class XEUS_CPP_API debugger : public xeus::xdebugger_base
                       ^

{
public:

using base_type = xeus::xdebugger_base;

debugger(xeus::xcontext& context,

Choose a reason for hiding this comment

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

warning: no header providing "xeus::xcontext" is directly included [misc-include-cleaner]

include/xeus-cpp/xdebugger.hpp:12:

- #ifdef __GNUC__
+ #include <xeus/xeus_context.hpp>
+ #ifdef __GNUC__

const xeus::xconfiguration& config,

Choose a reason for hiding this comment

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

warning: no header providing "xeus::xconfiguration" is directly included [misc-include-cleaner]

include/xeus-cpp/xdebugger.hpp:12:

- #ifdef __GNUC__
+ #include <xeus/xkernel_configuration.hpp>
+ #ifdef __GNUC__

const std::string& user_name,
const std::string& session_id,
const nl::json& debugger_config);

Choose a reason for hiding this comment

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

warning: no header providing "nlohmann::json" is directly included [misc-include-cleaner]

include/xeus-cpp/xdebugger.hpp:12:

- #ifdef __GNUC__
+ #include <nlohmann/json_fwd.hpp>
+ #ifdef __GNUC__


virtual ~debugger();

Choose a reason for hiding this comment

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

warning: prefer using 'override' or (rarely) 'final' instead of 'virtual' [cppcoreguidelines-explicit-virtual-functions]

Suggested change
virtual ~debugger();
~debugger() override;


private:

nl::json inspect_variables_request(const nl::json& message);
nl::json stack_trace_request(const nl::json& message);
nl::json attach_request(const nl::json& message);
nl::json configuration_done_request(const nl::json& message);

nl::json variables_request_impl(const nl::json& message) override;

bool start_lldb();
bool start() override;
void stop() override;
xeus::xdebugger_info get_debugger_info() const override;

Choose a reason for hiding this comment

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

warning: function 'get_debugger_info' should be marked [[nodiscard]] [modernize-use-nodiscard]

Suggested change
xeus::xdebugger_info get_debugger_info() const override;
[[nodiscard]] xeus::xdebugger_info get_debugger_info() const override;

std::string get_cell_temporary_file(const std::string& code) const override;

Choose a reason for hiding this comment

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

warning: function 'get_cell_temporary_file' should be marked [[nodiscard]] [modernize-use-nodiscard]

Suggested change
std::string get_cell_temporary_file(const std::string& code) const override;
[[nodiscard]] std::string get_cell_temporary_file(const std::string& code) const override;


bool connect_to_lldb_tcp();
std::string send_dap_message(const nl::json& message);
std::string receive_dap_response();

xdebuglldb_client* p_debuglldb_client;

Choose a reason for hiding this comment

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

warning: invalid case style for private member 'p_debuglldb_client' [readability-identifier-naming]

Suggested change
xdebuglldb_client* p_debuglldb_client;
xdebuglldb_client* m_p_debuglldb_client;

std::string m_lldb_host;
std::string m_lldb_port;
std::string m_lldbdap_port;
nl::json m_debugger_config;
bool m_is_running;
int m_tcp_socket;
bool m_tcp_connected;
};

XEUS_CPP_API
std::unique_ptr<xeus::xdebugger> make_cpp_debugger(xeus::xcontext& context,

Choose a reason for hiding this comment

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

warning: no header providing "std::unique_ptr" is directly included [misc-include-cleaner]

include/xeus-cpp/xdebugger.hpp:12:

- #ifdef __GNUC__
+ #include <memory>
+ #ifdef __GNUC__

Choose a reason for hiding this comment

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

warning: no header providing "xeus::xdebugger" is directly included [misc-include-cleaner]

include/xeus-cpp/xdebugger.hpp:12:

- #ifdef __GNUC__
+ #include <xeus/xdebugger.hpp>
+ #ifdef __GNUC__

const xeus::xconfiguration& config,
const std::string& user_name,
const std::string& session_id,
const nl::json& debugger_config);
}

Choose a reason for hiding this comment

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

warning: namespace 'xcpp' not terminated with a closing comment [llvm-namespace-comment]

Suggested change
}
} // namespace xcpp
Additional context

include/xeus-cpp/xdebugger.hpp:26: namespace 'xcpp' starts here

namespace xcpp
          ^


#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif

#endif
2 changes: 2 additions & 0 deletions include/xeus-cpp/xinterpreter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ namespace xcpp

void shutdown_request_impl() override;

nl::json internal_request_impl(const nl::json& content) override;

nl::json get_error_reply(
const std::string& ename,
const std::string& evalue,
Expand Down
20 changes: 20 additions & 0 deletions share/jupyter/kernels/xcpp17-debugger/kernel.json.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"display_name": "C++17-Debugger",
"env": {
"PATH":"@XEUS_CPP_PATH@",
"LD_LIBRARY_PATH":"@XEUS_CPP_LD_LIBRARY_PATH@"
},
"argv": [
"@XEUS_CPP_KERNELSPEC_PATH@xcpp",
"-f",
"{connection_file}",
"-gdwarf-4",
"-O0",
"-resource-dir", "@XEUS_CPP_RESOURCE_DIR@",
"-I", "@XEUS_CPP_INCLUDE_DIR@",
"-std=c++17"
],
"language": "cpp",
"metadata": {"debugger": true
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions share/jupyter/kernels/xcpp17-debugger/logo-svg.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion share/jupyter/kernels/xcpp17-omp/kernel.json.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
"-std=c++17"@XEUS_CPP_OMP@
],
"language": "cpp",
"metadata": {"debugger": false
"metadata": {"debugger": true
}
}
2 changes: 1 addition & 1 deletion share/jupyter/kernels/xcpp17/kernel.json.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
"-std=c++17"
],
"language": "cpp",
"metadata": {"debugger": false
"metadata": {"debugger": true
}
}
2 changes: 1 addition & 1 deletion share/jupyter/kernels/xcpp17/wasm_kernel.json.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
],
"language": "cpp",
"metadata": {
"debugger": false,
"debugger": true,
"shared": {
"libclangCppInterOp.so": "lib/libclangCppInterOp.so"
}
Expand Down
70 changes: 32 additions & 38 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,18 @@
#include <unistd.h>
#endif

#include "nlohmann/json.hpp"
#include "xeus/xhelper.hpp"
#include <xeus/xkernel.hpp>
#include <xeus/xkernel_configuration.hpp>

#include "xeus/xkernel.hpp"
#include "xeus/xkernel_configuration.hpp"
#include "xeus-zmq/xzmq_context.hpp"
#include <xeus-zmq/xserver_zmq.hpp>

#include "xeus-zmq/xserver_zmq.hpp"
#include "xeus-cpp/xeus_cpp_config.hpp"
#include "xeus-cpp/xinterpreter.hpp"
#include "xeus-cpp/xutils.hpp"
#include "xeus-cpp/xdebugger.hpp"

namespace nl = nlohmann;

int main(int argc, char* argv[])
{
Expand Down Expand Up @@ -58,6 +60,12 @@ int main(int argc, char* argv[])
#endif
signal(SIGINT, xcpp::stop_handler);

// Debugger configuration for LLDB-DAP
nl::json debugger_config;

Choose a reason for hiding this comment

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

warning: no header providing "nlohmann::json" is directly included [misc-include-cleaner]

src/main.cpp:9:

- #include <string>
+ #include <nlohmann/json_fwd.hpp>
+ #include <string>

debugger_config["lldb"]["initCommands"] = {
"settings set plugin.jit-loader.gdb.enable on"
};

std::string file_name = xeus::extract_filename(argc, argv);
auto interpreter = std::make_unique<xcpp::interpreter>(argc, argv);
std::unique_ptr<xeus::xcontext> context = xeus::make_zmq_context();
Expand All @@ -77,13 +85,14 @@ int main(int argc, char* argv[])
xeus::make_console_logger(
xeus::xlogger::msg_type,
xeus::make_file_logger(xeus::xlogger::content, "xeus.log")
)
),
xcpp::make_cpp_debugger,
debugger_config
);

std::clog << "Starting xcpp kernel...\n\n"
"If you want to connect to this kernel from an other client, you can use"
" the "
+ file_name + " file."
" the " + file_name + " file."
<< std::endl;

kernel.start();
Expand All @@ -99,7 +108,9 @@ int main(int argc, char* argv[])
xeus::make_console_logger(
xeus::xlogger::msg_type,
xeus::make_file_logger(xeus::xlogger::content, "xeus.log")
)
),
xcpp::make_cpp_debugger,
debugger_config
);

std::cout << "Getting config" << std::endl;
Expand All @@ -109,37 +120,20 @@ int main(int argc, char* argv[])
" and paste the following content inside of a `kernel.json` file. And then run for example:\n\n"
"# jupyter console --existing kernel.json\n\n"
"kernel.json\n```\n{\n"
" \"transport\": \""
+ config.m_transport
+ "\",\n"
" \"ip\": \""
+ config.m_ip
+ "\",\n"
" \"control_port\": "
+ config.m_control_port
+ ",\n"
" \"shell_port\": "
+ config.m_shell_port
+ ",\n"
" \"stdin_port\": "
+ config.m_stdin_port
+ ",\n"
" \"iopub_port\": "
+ config.m_iopub_port
+ ",\n"
" \"hb_port\": "
+ config.m_hb_port
+ ",\n"
" \"signature_scheme\": \""
+ config.m_signature_scheme
+ "\",\n"
" \"key\": \""
+ config.m_key
+ "\"\n"
"}\n```\n";
" \"transport\": \"" + config.m_transport + "\",\n"
" \"ip\": \"" + config.m_ip + "\",\n"
" \"control_port\": " + config.m_control_port + ",\n"
" \"shell_port\": " + config.m_shell_port + ",\n"
" \"stdin_port\": " + config.m_stdin_port + ",\n"
" \"iopub_port\": " + config.m_iopub_port + ",\n"
" \"hb_port\": " + config.m_hb_port + ",\n"
" \"signature_scheme\": \"" + config.m_signature_scheme + "\",\n"
" \"key\": \"" + config.m_key + "\"\n"
"}\n```"
<< std::endl;

Choose a reason for hiding this comment

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

warning: do not use 'std::endl' with streams; use '\n' instead [performance-avoid-endl]

Suggested change
<< std::endl;
<< '\n';


kernel.start();
}

return 0;
}
}
Loading
Loading