-
Notifications
You must be signed in to change notification settings - Fork 89
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
How to debug bundles with GDB #706
Comments
“b function” also can not find |
Add Debugging a bundle is no different than debugging any other shared libraries opened by Before posting an issue, please take time to consider whether it is really a Celix issue. |
You forget to run your program (I saw no gdb This is different from debugging an ordinary executable. In such case, after gdb started, the loader has already done its job for the executable and all associated linked shared libraries, thus you can set break point at once. |
I changed my mind and thought about it from a different angle, that the problem might not be completely unrelated to Celix. A first-time user may indeed set a breakpoint and be surprised to find that the debugger does not know where to set the break point (and thus leaves it pending). It might be helpful to beginners if there was a mention in the documentation of how to set up breakpoints for a bundle. |
My test case link: "CtrlConsumer.h" can find and set break point successfully , but "plc_main.c" can not ? tony@LAPTOP-4AFLJE2J: For help, type "help". 0 ACTIVE Celix Framework Celix/Framework 2 ACTIVE Apache Celix Shell TUI Celix/Shell 3 ACTIVE PlcCtrlBundle 4 ACTIVE RteBundle -> StartPLC localPCtrl address:0x5555555a7420 |
Of course you can't. I saw no usage of //Ctrl bundle服务提供者和使用者
#include "celix/BundleActivator.h"
#include "CtrlImpl.h"
extern "C"
{
#include "plc_main.h"
}
class PlcCtrlBundle
{
public:
//构造函数,初始化成员变量registration
explicit PlcCtrlBundle(std::shared_ptr<celix::BundleContext> ctx) :
registration{createPlcService(ctx)}
{
std::cout << "启动plc service bundle" << std::endl;
}
private:
static std::shared_ptr<celix::ServiceRegistration> createPlcService(std::shared_ptr<celix::BundleContext>& ctx)
{
//绑定,赋值
int seed = 42;
std::cout << "注册plc service bundle" << std::endl;
//注册服务
return ctx->registerService<ACEPHERE_RUNTIME::ICtrl>(std::make_shared<ACEPHERE_RUNTIME::CtrlImpl>(seed))
.addProperty("seed", seed)
.build();
}
//作为服务端
const std::shared_ptr<celix::ServiceRegistration> registration;
};
CELIX_GEN_CXX_BUNDLE_ACTIVATOR(PlcCtrlBundle) |
But I don't think it has anything to do with debugger plc_main.c . startPLC of plc_mian.c has been call and print in terminal , but also prompt: |
You only add If you follow my advice earlier, then all C and C++ will have It turns out to be an RTFM issue, totally unrelated to Celix. Sigh. |
I mistakenly thought that just adding C++was enough . Because only the C++compilation options were set during compilation |
When I build my process , CMakeLists.txt also add set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
But when I run exe with gdb and set break , can not find my source file .
Does the bundle not support GDB debugging or does it require specific settings ?
r$ gdb ./MyContainer
GNU gdb (Ubuntu 12.1-0ubuntu1~22.04) 12.1
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
https://www.gnu.org/software/gdb/bugs/.
Find the GDB manual and other documentation resources online at:
http://www.gnu.org/software/gdb/documentation/.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./MyContainer...
(gdb) b plc_main.c:8
No source file named plc_main.c.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (plc_main.c:8) pending.
NOTE: This issue is caused by an incorrect way of setting up the debug build for a mixed C/C++ CMake project.
The text was updated successfully, but these errors were encountered: