I have a custom shell that I can run C++ applications in. I start the shell from a bash prompt and then run my C++ code. I want to emulate this behavior with Eclipse, particularly for debugging. I can't seem to figure this out.
I could write a simple bash script that kicks off the custom shell and runs my application but Eclipse does not let me debug when I do this.
Is there a way to achieve this functionality?
Please keep in mind eclipse can set environment variables for running/debugging job.
If your shell is more complicated than that, please provide more details about your shell.
But I'm not optimistic about it.
Btw, you can always attach an existing process for debugging.
Related
There are tools that enable one to run a console command or a console application as a daemon. To "daemonize" it, so to say.
Is there a way to run a daemon as a regular console application?
I'm coding in KDevelop and don't see any options for daemon debugging.
Thanks !
It's reasonably normal to add a special debugging mode to daemons to enable this. That is, add in a command-line option to disable the daemonizing step, having the program run in the foreground. Then it is is simple to run the daemon under gdb.
I'm not aware of any generic way to do this. Maybe it could be done somehow with LD_PRELOAD interception, which would be cool -- but it's simpler to just modify the source.
For debugging a running daemon you can use the gdb attach command. However this is not very good for debugging daemon startup, as you'll have to race to attach in time.
The linux kernel doesn't support any way to "pre-attach" to the next instance of a program, but I wrote a hack to do it via SystemTap that you can find here.
When I normally run my application from the command line it looks like this:
However, when I schedule the command using the crontab (or the "at" command), the window looks like this:
The command that I schedule is as follows: "export DISPLAY=:0.0 && myprogram". I use Ubuntu 12.04 64-bit.
Any idea how to get the nice appearance for the scheduled window? Thank you.
I think that when you run the program using the crontab the program is running with other environmet. Environment that don't have the configurations you already do.
For instance, in your user space you said QT theme that you want it looks like GNOME.
This can happend if the user root runs the app since root has a different environment, hence different setting for QT gui themes/appareance.
Possible solution, try to specify the environment which will run the app.
Another solution could be select the theme programatically, here you have a discussion about the subject.
Test: Try running the app yourself as root, and compare result. Don't use sudo. Try with su -c.
Program started from crontab has different environment. So you can create a shell script that sources your profile, for example using bash:
#!/bin/bash
source ~/.profile
export DISPLAY=:0.0
exec myprogram
And run that from crontab. If you do not normally use bash, you may need to use script with shell that you use.
Alternative would be to investigate your profile and find out, what difference in environment changes window appearance. Then export that variable in such script, or put it directly into crontab job, like you do for variable DISPLAY.
I am developing a Django app or two using pydev as my IDE. I like it a lot :) However, I recently got really excited about Docker and am using Docker and Fig to serve my application now. My problem is that I would like to run my tests in this build environment- seems like this is kinda the point after all!
I know how to actually do it.
fig run web python3 /code/manage.py test
would run the tests. If I didn't want to use the Django runner, I could run
fig run web python3 /code/myapp/tests.py
Either way though, I cannot figure out how to issue that command from the IDE. All of the run configurations point to the configured python.exe ... does anyone know if there is a way to replace that with a fully customized command?
Well, the PyDev launch configuration is really targeted towards running Python, but there are alternatives to running it through other ways:
Create an external tool run (run > external tools > external tools configuration): You should be able to run anything you want from there... the downside is that this isn't really integrated into PyDev, so, if you have stack-traces they won't be clickable (and you won't be able to debug either).
Create a launcher script which in turn uses subprocess to launch the command you want... if you redirect things tracebacks should be clickable. The downside is that you won't be able to create a debug session either -- but you can still use the remote debugging in this case (http://pydev.org/manual_adv_remote_debugger.html)
Improve PyDev to do that better... (i.e.: get the code: http://pydev.org/developers.html and add docker support to a project through fig -- it should be something close to org.python.pydev.django which has special integration for running in django -- with some tweaks to the start command line, even starting in debug mode directly can work here)... if you decide to go that route, you can create a feature request at https://sw-brainwy.rhcloud.com/tracker/PyDev/ and ask code-related stuff and I'll help :)
Possibly you can create a custom executable which acts like Python but in reality just forwards things to other places (i.e.: to fig run) -- I haven't actually tested this, but in theory it should work (in the past there was work to support dummy 'python' runners such as that -- i.e.: for supporting http://cctbx.sourceforge.net/ -- so, it should work -- but you still have to create this launcher script for your use case to pass things to fig run). If the work is done properly, the debugger could work here too.
I have a C++ project that is called in Python (via boost-python) and I want to debug the C++ code from python process. How can I do that? In Windows with Visual Studio I can use the functionality attach to process. How to achieve the same in Eclipse?
Thanks
For me it works great just adding a debug configuration in C/C++ for the program /usr/bin/python (or whatever search path you have to the python interpreter) and then put the python program you want to run as the arguments. Put the breakpoints you want in the C-code and you should be all set for running the debug configuration and opening the debug perspective.
If it still does not work you may also check that you are using Legacy (or Standard) Process Launcher. For some reason the GDB process launcher does not seem to work here.
Currently the gdb console of Eclipse just connects the stdin/stdout between the java gui and the underlying gdb process, hence many gdb shell features are missing, e.g. tab-autocomplete, command history etc.
I want to know if there is an enhanced console for fast gdb interacting. I really like the frequently used gdb commands like "print" and "call" etc. IMHO, "print" command is superiors sometimes than Eclipse "Expression watcher" because it only execute once and the later will be evaluated any time and be crash-prone.
If you think there is no need to use gdb console, then what's you best-practise in terms of gdb UI to eclipse UI transfer.
There doesn't seem to be any gdb-specific plugin, beside the initial gdb integration initiated with Eclipse3.4.
And the current list of gdb bugs doesn't include your missing features.
If you're writing c/++, why not just find the eclipse-generated elf and use gdb via the shell?