How to debug WT-App within Linux (Ubuntu) - Question from a Windows-User
Added by Claudio White almost 7 years ago
Because of the user "Im At" which tells me in another thread weeks ago that he is using docker i did start creating an own docker Container with ubuntu, wt 4.0.3 (including boost and other Options recommended as described in the wt wiki) and using it on my host System with Windows.
I did also install geany as IDE in the docker image, but currently i do not using it (but the Docker Container can run Geany wit CygWin/X on the Windows-Host running by transfering Window with X11-Support - Could be helpful later using Geany as IDE running on my Windows-Host from the Linux Docker Container).
Currently i use on my Windows Host Visual Studio Code to edit my files in the Docker Container (linked my host filesystem to the docker file System).
I did successfully build wt Release and Debug libs and also i did successfully build my own small WT-App and this is running, i can access from my Windows-Host-Browser to the started WT-App in the docker Container.
And next big step is, how can i debug my WT-App running in the docker Container?
As Windows User using and running Visual Studio Community and creating a Windwos-WT-App it was easy for me Debugging my WT-App:-)
But now the WT-App is running in a docker Linux ubuntu Container, builded with debug Information but i am wondering...how can i debug now?
Do i have to install additional packages?
And/Or are there any possible g commands which i should use?
Can anyone help me what i have to do that i can start the WT-App and debug the WT-App within the ubuntu docker container, like setting a breakpoint and how to inspect the value of a variable?
Replies (8)
RE: How to debug WT-App within Linux (Ubuntu) - Question from a Windows-User - Added by Claudio White almost 7 years ago
I did install now gdb as Google told me that is "the" Debugger when using Linux and gcc/g:
apt-get update
apt-get install gdb
I found a short description how to use gcc/gdb: https://www.seas.upenn.edu/cets/answers/gcc.html
But currently i do not understand how i start my WT-App from commandline together with gdb?
My working commandline without gdb is this one (running from the Folder where i have my running app called wt_project.wt):
./wt_project.wt ---http-address=0.0.0.0 ---http-port=8099 ---docroot=. -c ../../../source/resources/wt_config.xml
But how must the command look when i start it together with gdb?
The following does not work:-(
gdb ./wt_project.wt ---http-address=0.0.0.0 ---http-port=8099 ---docroot=. -c ../../../source/resources/wt_config.xml
I get the error => gdb: unrecognized Option '---http-address=0.0.0.0'
RE: How to debug WT-App within Linux (Ubuntu) - Question from a Windows-User - Added by Claudio White almost 7 years ago
Ah...i found it out how to run with gdb:-)
gdb ./wt_project.wt
after that you will get the gdb prompt:
(gdb) r ---http-address=0.0.0.0 ---http-port=8099 ---docroot=. -c ../../../source/resources/wt_config.xml
Now the WT-App is running:-)
But hey...how can i set a breakpoint now?
I just see the Messages given from the started wt-app that wt-server is inialized but the gdb prompt is not avaliable.
So how can i break the wt-app and set a breakpoint??
RE: How to debug WT-App within Linux (Ubuntu) - Question from a Windows-User - Added by Claudio White almost 7 years ago
As described in the URL above before running the "r" command within the gdb prompt you have to set with the "b" command a breakpoint.
First:
(gdb) b main
Then:
(gdb) r ---http-address=0.0.0.0 ---http-port=8099 ---docroot=. -c ../../../source/resources/wt_config.xml
But this does not work, WT-App stops not on the breakpoint.
Is there more to do within the WT-App or is this the wrong way using gdb?
RE: How to debug WT-App within Linux (Ubuntu) - Question from a Windows-User - Added by lm at almost 7 years ago
You've been a busy bee! I have not and do not recommend debugging in the docker container; they're not really for that. Of course, if it's working for you, no problem.
I use gdb (actually cgdb) to debug WT applications. You found out how to invoke (r --http-address=0.0.0.0 --http-port...
), but you can do it in a more scriptable way with
gdb --args ./wt_project.wt --http-address=0.0.0.0 --http-port=8099...
b main
doesn't sound right: you need to provide an unambiguous signature. gdb performs tab completion, maybe try b main<tab>
to see if it will fill in the rest of your main function's signature? You can also provide b main.cpp:line_num
. If you're wanting to step into main, try start
?
Congratulations and good luck Claudio!
RE: How to debug WT-App within Linux (Ubuntu) - Question from a Windows-User - Added by Claudio White almost 7 years ago
Thank you again and again and again Im At) The bee is already overheated...
Are you an Employee/Developer of EmWeb?
I did now as you instruct the following steps:
Start Point is the usr/local/src/dummy/build/debug/source Folder of my wt-app "wt_project.wt"
root:/# gdb ---args ./wt_project.wt ---http-address=0.0.0.0 ---http-port=8099 ---docroot=. -c ../../../source/resources/wt_config.xml
(gdb) b main.cpp:33 => Breakpoint is set message successfully on /usr/local/src/dummy/source/main.cpp, line 33.
(gdb) start
But same problem, it does not stop on the breakpoint set.
Do you have another idea what could help?
RE: How to debug WT-App within Linux (Ubuntu) - Question from a Windows-User - Added by lm at almost 7 years ago
I'm not affiliated with redmine, emweb, nor WT in any way except as an enthusiastic user :-)
I think that should work. "start
" automatically sets a breakpoint on the first line of the main
function and runs to that line. b main.cpp:33
should also handle the breakpoint. That's really strange. When you compiled your ./wt_project.wt
, were you sure to include debugging symbols? (-g
to gcc or clang) I would think so because it says it set the breakpoint successfully, and lists your source file. I guess try issuing the breakpoint (b main.cpp:33
) then just "run
"? I'm not sure what else to suggest.
RE: How to debug WT-App within Linux (Ubuntu) - Question from a Windows-User - Added by Claudio White almost 7 years ago
After "run" starting the program a message is coming up with the start params and a second line with a warning.
First line:
Starting program: /usr/local/src/dummy/build/Debug/source/wt_project.wt ---http-address=0.0.0.0 ---http-port=8099 ---docroot=. -c ../../../source/resources/wt_config.xml
Second line:
Error disabling address space randomization: Operation not permitted
Starting with the third message line, the printf outputs are shown from my app...but instead of them the breakpoint should stop here before the output.
I found out now with Google (searched for the warning message), that this is known Problem:
https://forums.docker.com/t/gdb-breakpoints-dont-work-error-disabling-address-space-randomization/14365
https://stackoverflow.com/questions/35860527/warning-error-disabling-address-space-randomization-operation-not-permitted#comment62818827_35860527
I will have a detail look to it and hopefully there will be a solution, so it seems all the instructions above was correctly:-)
As i have the solution i will post here.
RE: How to debug WT-App within Linux (Ubuntu) - Question from a Windows-User - Added by Claudio White almost 7 years ago
Yes:-)
Adding
---security-opt seccomp=unconfined
to the docker run command and then your gdb instruction are working within the docker Container:-)
Once again, many thank for your Support!
Next i will try to work with Geany IDE and Debugging via setting up Geany...because now on commandline everything is working:-)