我想调试Main调用的SharedLib。我有SharedLib和Main的来源。我用选项–g3编译和链接Main和SharedLib。变量PATH和LD_LIBRARY_PATH包括/ PathToSharedLib。我在NNN的 b FileOfSharedLib.c中设置了一个断点。
(gdb) file /PathToMain/Main
Reading symbols from /PathToMain/Main...done.
(gdb) set directories /PathToSourceOfSharedLib
(gdb) set solib-search-path /PathToSharedLib
(gdb) sharedlibrary SharedLib
No loaded shared libraries match the pattern `SharedLib`
(gdb) b FileOfSharedLib.c:NNN
No source file named FileOfSharedLib.c.
Make breakpoint pending on future shared library load? (y or [n]) y
(gdb) run
Run Code Online (Sandbox Code Playgroud)
它永远不会在Main多次调用的断点处停止。我在SharedLib的日志中通过printf语句看到了它。看起来gdb没有考虑SharedLib。
我检查了SharedLib和FileOfSharedLib.c:
(gdb) file /PathToSharedLib/SharedLib
Reading symbols from /PathToSharedLib/SharedLibl...done.
(gdb) b FileOfSharedLib.c:123 …Run Code Online (Sandbox Code Playgroud) 我收到以下错误:
2 smartcard.c: In member function ‘virtual bool cSmartCards::ParseLine(const char*, bool)’:
3 smartcard.c:1187:25: error: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive]
4 char *r=index(line,':');
5 ^
Run Code Online (Sandbox Code Playgroud)
代码是:
1184
1185 bool cSmartCards::ParseLine(const char *line, bool fromCache)
1186 {
1187 char *r=index(line,':');
1188 if(!r) return false;
Run Code Online (Sandbox Code Playgroud)
包括我 "string.h"
我怎样才能改写第1187行?
index()可以在string.h中找到.