debug cgi c++ application - c++

I am new to cgi and have an cgi C++ application to debug.
How can I set up the environment on my developer PC in order to debug in visual studio?
My app supports GET and POST method but I have no idea what to do to make it start up correctly.
The app is started through a link with some arguments like:
myApp.exe?mode=create&name=jack...
Any suggestions?
Thanks
juergen

If your parameters are usually sent as part of the URL, then they should be found in the QUERY_STRING environment variable. You normally get this by calling get_env("QUERY_STRING").
Before running, try setting the environment variable QUERY_STRING to contain mode=create&name=jack

Related

Need to install C/C++ sdk appdynamics for my C++ application

I was going through this appdynamics document page for the installation of C/C++ SDK.
C/C++ SDK installation on Linux
But since, i am doing this for the first time, i am not sure what is meant in the 3rd point.
I think i have to set the location in my LD_LIBRARY_PATH env variable and then invoke them by typing
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/appdynamics-cpp-sdk/lib
Can somebody explain, what needs to be done?
Yes - you need to set "/opt/appdynamics-cpp-sdk/lib" in your "LD_LIBRARY_PATH" environment variable to use the SDK as you have posted.
Generally this is put in a script used to build your application which you are wanting to instrument.

QNetworkAccessManager crash related to SSL

My Qt Windows desktop application crashes on first QNetworkAccessManager->get call. I get following error in the log.
Auto configuration failed
16100:error:02001015:system library:fopen:Is a directory:.\crypto\bio\bss_file.c:122:fopen('d:/openssl/ssl/openssl.cnf','rb')
16100:error:2006D002:BIO routines:BIO_new_file:system lib:.\crypto\bio\bss_file.c:127:
16100:error:0E078002:configuration file routines:DEF_LOAD:system lib:.\crypto\conf\conf_def.c:199:
It is something related to OpenSSL configuration, but I actually don't use (and don't need) SSL in my application. I know that OpenSSL library is loaded together with QNetworkAccessManager, but is there any way to disable it?
I can fix this problem by reinstalling openssl libraries like it is stated here, but this is not a good solution since I cannot force my customers to reinstall openssl on their systems because of my application. So I am looking for a better solution.
I already tried adding DEFINES += QT_NO_SSL into my project file but with no luck. Interesting here is that this is only happening after I deploy my application, it works smoothly from Qt Creator.
Important thing here is that I can manually manipulate crashing (on deploy systems) by modifying OPENSSL_CONF environment variable. If it does not exist or if it is set correctly, app won't crash, otherwise (env. variable is set to incorrect folder) app crashes.
Any ideas?

Pycharm debugger does not stop on breakpoints

I have a flask project I am trying to debug (this was working absolutely ok till few hours ago) - When I debug the project, I see the following :
Connected to pydev debugger (build 135.1057)
/Users/vantani/cp/bin/python /Applications/PyCharm.app/helpers/pydev/pydevd.py --multiproc --save-
signatures --client 127.0.0.1 --port 49223 --file /Users/vantani/cp/unnamed/manage.py server
pydev debugger: process 484 is connecting
/Users/vantani/cp/lib/python2.7/site-packages/flask_cache/__init__.py:152: UserWarning: Flask-
Cache: CACHE_TYPE is set to null, caching is effectively disabled.
warnings.warn("Flask-Cache: CACHE_TYPE is set to null, "
* Running on http://127.0.0.1:5000/
* Restarting with reloader
pydev debugger: process 498 is connecting
As I said this setup was working fine. Now, the debugger does not stop at the breakpoint and the debugger window is empty. I see that there are two processes created by PyDev and I guess that is causing this issue. I have restarted my machine and there is only one pycharm process running.
Sometimes this might be caused by the fact that some other module is using the same tracing api (sys.settrace) as debugger, for instance Coverage.py. The solution would be to go to your Rub/Debug Configurations and add --no-cov flag to the Additional Arguments.
Alternatively you might want to delete all --cov in pytest settings (i.e. pytest.ini) or run tests with --no-cov flag, i.e.
pytest test.py --no-cov
It might be also caused by a bad filename, e.g. your file/directory has special characters or spaces in it. Try removing them or changing to e.g. underscore (_).
There is an issue with the debugger in PyCharm lately.
I'm on mac using PyCharm 2020.2 and while the debugger would stop at tests, it wouldn't stop when running the dev server for django.
For me disabling Gevent compatible option in Preferences > Build, Execution, Deployment has helped.
Worth noting that some suggest to enable some suggest to disable that option - so it's worth having a go at each and see if that helps your case.
Just need set flask's debug mode off, such as
app.run(debug=False)
I didn't have a flask project but I had the same problem. In my case I had to change the project-path! There were umlauts (ü,ä,ö) in it. By removing them the breakpoints worked again.
My problem is solved when I installed pydevd-pycharm
pip install pydevd-pycharm
Also here is a useful link for this problem.
github from jetbrains intellij-community
Check your python debugger settings, and clear your cache, This helped me
The following workaround should help. I had a same problem in a simple Python script. PyCharm debugger didn't stop on a simple breakpoint and just ran to the end.
Thanks to Gabriel's answer, I checked the path to my script and it had Russian letters. Because I use Russian Windows and it creates admin user named 'Administrator' using Russian letters.
I changed the Russian letters to use only English letters from the project-path (just copied PyCharm projects folder to the root of disk and reloaded my project from new place. Nothing else was changed!). And the debugger immediately started working just fine and stopped on breakpoints!
It looks like this a bug that PyCharm debuger can't work with different national letters in the path. It very common situation outside English-speaking countries.
For Sanic case.
Run go_fast(..auto_reload=False,..).
There is a long thread about this issue on JetBrains forums:
https://intellij-support.jetbrains.com/hc/en-us/community/posts/360008107400-PyCharm-2020-1-not-stopping-on-breakpoints-anymore-. Reading through that thread is like reading a black magic book, everyone has their own voodoo $^$#
I ran into this issue with 2021.1.1 CE and a brand new project. My solution was to change the default test runner to pytest. YMMV. If that thread is any indication, debugging might stop working if it rains tomorrow.
For me I deleted project from "recent projects in pycharm" then I opened project direct from repository. It works again.
Had the same issue recently (July 2021 PyCharms 2021.1.3 CE) for days trying everything I could find online would not work. Then found under File --> Manage IDE Settings --> Restore Default Setting, that fixed the issue for me.
For all those people that have the same problem, but can't resolve it, maybe this will work:
The problem could be, that pydev isn't connecting to its subprocess.
Check if the option "Attach to subprocess automatically while debugging?" in the debugger settings is set. You can find it in File > Settings > Build, Execution, Deployment > Python Debugger (current version of PyCharm)
Usually there is also a short hint in the console but I didn't notice it.
After removing debug_toolbar middleware the debugger is back to normal.
It's happening because of a third party module. I tried all the solutions listed and none worked for me.
I changed the interpreter that I'm using and it's working.
I had this issue when running remote interpreter from docker-compose. It disappeared when I set Working directory to my project root directory in Run/Debug Configuration. I also restarted Pycharm and invalidated caches.
I got it fixed by removing coverage config from pytest.ini
Not exactly the same case but, if you are using the Debug Server to debug a docker container, the only thing which made the breakpoint to stop for me is to set and environment variable for the container:
PYCHARM_DEBUG=True
PyCharm Version: 2022.2.2
For me PyCharm actually executed a different file. If you just clicked the run button... try if it makes a difference if you use
right click on file => Run 'xy'.
Or double check if your file full path to be executed is specified in "Script path" in the run configuration. I used to use the file name in "interpreter option" along with "working directory" specified. It would work that way.

Is it possible to have a Chromium browser inside of a plugin?

I'm trying to embed a chromium browser into my C++ plugin, which will be run inside of a host application. This is my first time working with chromium, so please forgive my ignorance.
I've got the program running to the point where cef is initialized and the browser is instantiated with no asserts or issues. However, the browser gets stuck loading things. I've noticed that during the instantiation of the browser, the host application raises an error about misused command line arguments. Is chromium trying to receive messages from the command line? If so, how can I receive those messages when my application is a plugin?
I can reproduce the host application's error by calling it from the command line with unknown arguments (Ex. "C:/HostApplication.exe -someRandomString").
"Chrome Frame" is very close to what you're describing: https://developers.google.com/chrome/chrome-frame/
The good news is, chrome frame, like the rest of Chromium project is open source, so check out the source: http://code.google.com/codesearch#OAMlx_jo-ck/src/chrome_frame/

Howto Debug CgiCC App

I develop a Win32 C++ cgi app for windows and linux and start from scratch.
I use CgiCC as lib and Visual Studio 2010 as IDE.
How can I debug that? When I instanziate my cgicc class the program holds and waits for CGI input I guess.
How can I set up an environment for my CGI input?
I set some environment variables like QUERY_STRING.
But I have no idea how to provide the values my cgi app would get while running on a webserver.
EDIT:
I am almost there.
I captured the traffic while browsing and wrote that content to a file.
Then I redirected stdin to that file: "< input.txt" as debug command line arguments in visual studio.
I set some environment variables under windows like CONTENT_LENGTH and CONTENT_TYPE.
after that I can read some content from my input like this:
cgicc::Cgicc cgi;
string u = cgi("user");
but i get an exception (reading from unallocated memory and exceptions like that) while doing this:
vector<FormFile, allocator<FormFile>> files = cgi.getFiles();
somehow not everthing if loaded correctly.
CGI apps receive their input via environment variables and standard input, so you can easily replicate the environment that a web server sets up for the CGI task.
As far as environment variables, here is a list of the environment variables that are part of the CGI protocol. I recommend that you set all of them, either by hand or better yet, by capturing the environment given to a working cgi app by a production web server. Since environment variables are inherited by child processes, if you set these up in your environment inside a Windows command prompt and then invoke the Visual Studio IDE from that same window then these variables will be available when your CGI application starts inside the debugger and also when you run it without debugging.
Getting a standard input replacement can be a bit more complex in your case, since you are working with a file upload form. This site contains a template that should get you started with the multipart/form-data format. The official document for file uploads via forms is RFC 1867.
I hope this helps.
Solved it by myself:
Build cgicc with the same visual studio version that I compile my project with.
Build cgicc as a static library instead of a dynamic library.
Setting the preprocessor define CGICC_EXPORTS in my project which activated __declspec(dllexport).
Then it worked!