I am trying to write some mex code but it is painful to debug it on the console with gbd. Is it possible to use Eclipse or the GUI of Matlab? If these are not feasible methods, what is the best way of writing mex code that provides good debug capabilities?
Debugging C/C++ MEX files in gdb is already comprehensively covered in the official documentation, so my suggestion is to try and integrate gdb with Eclipse CDT.
There's plenty of information out there about how to do it properly, so I'm not going to repeat everything here. The best tutorial I know is IBM's two-part guide, "Interfacing with the CDT debugger":
Part 1: Understand the C/C++ debugger interface - covers the high-level basics.
Part 2: Accessing gdb with the Eclipse CDT and MI - explains how to make Eclipse work with gdb.
I think part 2 is what you really need. Basically, you have to install a plug-in and configure it in Eclipse.
There are also quite a few related questions about this even here on StackOverflow:
How do I use GDB in Eclipse for C/C++ Debugging?
How to install GDB debugger to Eclipse CDT
Debugging with Eclipse CDT and GDB
How can I enter commands to a gdb prompt while debugging with Eclipse CDT?
I haven't tried it out yet, so I hope this works.
On Windows platform:
The best way (to my experience) to debug a mex code is to use Visual studio.
Here's a link on how to do it.
Other platforms (Linux/Mac):
I'm afraid I haven't find any good way to do so apart from gdb (which is not fun at all).
Update (2018):
Recently, Mathworks released a blog post describing how to use Visual Studio Code to debug mex code.
I haven't tried it myself, but it seems like a nice cross-platform solution for debugging mex files.
Here is my solution which works in Ubuntu 12.04, Matlab R2012b, and Eclipse IDE for C/C++ Developers Kepler Release.
In Eclipse open "Debug Configurations" from the run tab. Then make a new "C/C++ Application".
In the "Main"-tab write the correct path to the matlab executable in the "C/C++ Application" (mine is "/usr/local/MATLAB/R2012b/bin/glnxa64/MATLAB" NOTE: not MATLABPATH/bin/matlab).
In the "Arguments"-tab add "-nojvm" as program arguments.
In the "Environment"-tab add variable "MATLAB_DEBUG" with value "gdb"
Press "Apply" and "Debug"
A "Matlab console" will open in the "Console" view.
Write "dbmex on" in this console. This enables debugging.
Run the mex file! (Matlab will stop at loading of each new mex file)
Have fun debugging! :-)
Related
It seems that LLDB plugin for Eclipse is still not developed yet, but this article claims that one can debug a program with LLDB-MI driver in Linux. However described way of integrating Eclipse and LLDB doesn't work for me (I always get "command --exec-continue not recognized" error message) and it looks suspicious that embedding LLDB-MI to Eclipse may be so easy.
Could anyone point me to curren materials on this topic? Google shows me only old Eclipse-bug-tracking threads.
There is a project called lldbmi2 that provides most of the functionality one would need. I know it's been developed primarily for the Mac and I don't know if it's been tested on Linux. It's not perfect, but I've been using it on the Mac for months and I'm pleased with its functionality.
See https://github.com/freedib/lldbmi2
I installed the Intel Fortran Composer XE from this link on my Debian Linux system, which includes the Intel Fortran Compiler. I installed it to opt/intel/composer_xe_2013_sp1.0.080, but now I'm not sure how to run it. I followed the instructions in this question to install the environment variables, but now I'm trying to run the IDE.
Does Intel Fortran on Linux not come with an IDE? On Windows everyone talks about integrating it with Visual Studio, so do I need to integrate it with Eclipse (somehow?), or what? Can someone point me to resources telling me about this? I don't see information anywhere, so I feel like... I'm just supposed to know and that this is a really stupid question. What is the composer if not an IDE? Is the composer different from the compiler?
You need to source two files into your environment (and possibly specify your architecture)
source /opt/intel/composer_xe_2013_sp1.0.080/bin/compilervars.sh intel64
source /opt/intel/composer_xe_2013_sp1.0.080/bin/compilervars_arch.sh intel64
To find out what architectures are supported run
/opt/intel/composer_xe_2013_sp1.0.080/bin/compilervars.sh
without any arguments
You can create a file named /etc/profile.d/intel.sh, and insert these lines into it. after editing you should log out and log in back again, then try
which icc
which ifort
echo $LD_LIBRARY_PATH
To see if your environment knows the correct location of everything
If you cannot edit files under /etc (no super user privileges), just add these two 'source' lines into your ~/.bashrc, then log out and log in again
Just put source compilervars.sh to jour .profile or /etc/profile.d. No need to create symlinks for everything.
As to IDE, there is no own IDE in Intel Composer. People even don't use IDE's that much on Linux, when they are used to vi, emacs, kate or whatever.
Intel Parallel Studio comes with eclipse plug-in for C++, but not for Fortran. You may use Photran as a Fortran Eclipse plugin.
In response to Part A about using ifort, you need to create a symbolic link to ifort:
ln -s path/to/ifort /usr/bin/ifort
Then you should be able to just type ifort code.f90 into your terminal and have an executable.
As to Part B about an IDE: my $0.02 is that they as a whole are a dime a dozen. I usually use a text editor or terminal (I'm a nano user). I don't know squat about Intel's IDE, but Steve Lionel has been hanging around SO lately, so he might be able to better serve you on this note.
Here's an excellent article by Intel on Using IntelĀ® C++ Compiler with the Eclipse* IDE on Linux*. Hope this helps. I'm amazed people think they can get by with no debugger on Linux. They must be writing some very flat, mono-threaded code. Also, here's a good expose on the features of the debugger. It's about time SOMEBODY went beyond GDB and provided a reasonable debugging environment in Linux. IntelĀ® Debugger for Linux* (IDB)
I would like to step through some code in wireshark to see how a few things work. I've read some of the Wireshark Build Environment guide but it seems a lot of info is missing. I've never done any programming in linux before so bear with me here.
What is the best IDE to use for debugging Wireshark in Linux? If there isn't one, then how do you debug without an IDE? I've really only developed in Visual Studio so I've been spoiled by it's ease of use.
You can use Eclipse as a full-fledged IDE with debugging capabilities. Or you can debug from command line using gdb. Or you can use DDD, which is a GUI front end for gdb.
I recently discovered Nemerle and F#, but I can't find any way to debug my applications.
MonoDevelop 2.6 lacks support of Nemerle and F#, 2.4.2 and earlier crashes because of newer gnome-sharp lib is installed (I'm running up-to-date Arch Linux kernel-3.0 64-bit). Command-line mono debugger refuses to start saying "platform not supported". So few questions about this situation:
It is possible to debug mono applications using gdb without going on low-level (inside vm or so) ?
How comfortable to use F# REPL for interactive development without debugger (compared to Common Lisp or Haskell's GHCi)?
I use the F# Interactive environment to write F# code most of the time. Even with Visual Studio, the F# Interactive environment doesn't (reasonably) support debugger, so I mainly rely on the ability to easily run something interactively and see if it works - if it doesn't, it is usually easy to split into sub-components that can be tried interactively too. The great thing about F# Interactive, compared to for example GHCi, is that you can use it to evaluate pretty much anything - including type declarations.
The F# plugin for MonoDevelop 2.4 doesn't currently support debugging of compiled F# applications. I was able to use command line Mono debugger (mdb, I think), but that was on 32bit system.
I'm not sure why MonoDevelop doesn't correctly pick F# debug symbols, so this is most likely some basic bug. There are a few poeple working on F# plugin for MD 2.6, so that should hopefully be available soon. If anybody wanted to investigate why the debugging doesn't work, that would be great...
Nemerle has great IDE support under Windows with Visual Studio and #Develop, better than F#, but there is nothing for Linux, as far as I know.
You can easily debug Nemerle in MonoDevelop.
Just convert pdb to mono format using pdb2mdb tool: http://www.mono-project.com/Guide:Debugger
Than just debug your application, and you get correct locations.
I even managed to debug Nemerle compiler using this trick.
About Linux and Nemerle :
Nemerle got Vim bindings, Kwrite/Kate and some other editors got ntive Nemerle support. You can also add compiler option to any editors in Linux. Nemerle compiler is just works !
Nemerle MonoDevelop support in developing but really slow. F# got outdated MonodeVelop support as #Tomas said but what about new MonoDevelop ? PowerPack ? F# 3 ? That is complex task I think so.
Nemerle is OpenSource project. And I'm not sure about F# 3. I like F# but it's always behind the Microsoft hand. You are free to try both.
I am developing a cross-platform application in C++ in VS2005. I already know how to run a remote process on a windows box, attach it, and debug from my VS.
Is there a way to do debug a running process on Linux for example? What about other *nix platforms such as Solaris or AIX? I can do emacs+gdb, but if this can be done from VS I'd prefer that.
VS2005 and g++ use create completely different debugging symbols. You do realize you'll have to compile the application on linux with g++? (or some other *nix compiler, but not VS2005). So because it's compiled with a different compiler, there's really no way to debug it inside VS2005.
OK, everything I said was essentially true, but it looks like there is a program that will allow you to run gdb inside Visual Studio. Check it out here.