JNI c++ Netbeans Debugging - c++

I have a java application that communicates with JNI C++ application. My java application is in eclipse while I am using netbeans for C++ with mingw64 bit compiler. I can not seem to debug JNI part of the application.
I load dll in java application. From netbeans I go to Debug->Attach Debugger select javaw.exe that makes my eclipse stuck and I get exception in eclipse IDE:
org.eclipse.jdi.TimeoutException. Timeout occurred while waiting for packet. occurred creating step request
Is my debugging procedure correct? How does one configure netbeans to debug a JNI application.

This could be because your debugger is stopping all your threads when attaching, and not letting them resume properly afterwards (Not sure why this happens. It seems to only happen on some computers, and work fine on others).
A way to around this that worked for me is - In your C++ debugger configurations, in the debugger tab, tick the "Non-stop mode" checkbox. This will stop your debugger from stopping your threads, and the timeout should stop happening.

Related

"Program File does not exist" while trying to debug with Eclipse/OpenOCD

I recently got a nrf51 bluetooth module and I am trying to debug it with Eclipse Mars. I installed the required toolchain as well as OpenOCD (I am using STLink v2 to debug the board).
While running openOCD and arm-none-eabi-gdb in console, everything works fine. The OpenOCD server starts up and I am able to connect with the gdb tool.
However, when trying to start a debug session with Eclipse, it throws the error "Exception occurred during launch. Reason: Program file does not exist". The build process finishes normally. It's the first time I used Eclipse for C/C++ development and the first time after years I used Eclipse at all so I don't even have an idea what could be wrong.
I tried messing around with the project settings without luck. Can anyone give me a hint?
I should mention, I used an already existing Makefile since I tried compiling one of the nordic SDK examples. I Changed it so the resulting files are ready for debugging.
In past I've used Segger's Jlink programmer and the JlinkExe (A pre-built binary) for Linux platform to program Nordic Bluetooth module such as NRF51 and it worked seamlessly. There are some very good documentation on using GNU toolchain with NRF51 series SOC and in case you get your hands on Segger's Jlink, I would recommend you to use that for programming. Meanwhile, this thread in the Nordic's developer zone seem to be very much similar to your problem. Maybe you'll be find some clues there.

Eclipse will not stop at breakpoint and puts thread state into Running: User Request

Recently, Eclipse SDK decided to kill my brain cells.
Out of the blue, it just stopped pausing at breakpoints. I do see it hit the breakpoint, but right then window loses focus and in the thread/callstack window it shows
MyApp [C/C++ Application]
MyApp [18556][cores:1]
Thread [2] (Running : Container)
Thread [1] (Running : User Request)
gdb
I see when i hits my breakpoint and it takes a blink of an eye before it goes into above state. My app stops responding and working and i have to kill it.
My app is a non GUI application which runs in linux as a background task, it reads and writes files, performs communication through COM and TCP/UDP. No user input is ever requested or anything like that.
There are tons of people who have problems with eclipse having problems with breakpoints, however they all are about java projects and or windows version of eclipse and none of the provided solutions work for me.
So far i have:
Rebuilt index.
Cleaned and rebuild project.
Deleted all debug files, makefile, binary and built again.
Cleared all breakpoints.
Made sure it was not set to ignore breakpoints.
and probably more which i already forgot.
Eclipse version is 4.2.1
Linux: Arch linux which was not updated for like 2 years now.
Project is C++.
What other information do i need to provide?
How can i solve this problem. I can't debug my application :(
I resolved this problem in this way: "Run" -> "Debug Configuration" -> select you configuration -> Debugger.
Then check the checkbox which shows "Use external console for inferior (open a new console window for input/output)".

How to debug host code in mixed cuda C++ program?

My work platforms are VS2010 and Nsight 3.1.
With Nsight, breakpoints can be set in cuda kernel and the debugger works well. If the breakpoints are set in host code, Nsight just ignores them.
I don't know if it is possible to set breakpoints in host code and use the debugger provided by VS2010. I tried, but the program stops when it meets the first cudaMalloc function. Could someone please tell me how to debug host code in a mixed cuda and c++ program?
Thanks a lot.
I'm afraid you could not debug both CUDA and c++ program in on VS. Here is a workaround. Hope it could help you
Launch a Windows command line. Set NSIGHT_CUDA_DEBUGGER=1
In this command line, execute your CUDA application (Here I suppose it's a long-term execution).
Open a VS. Tools menu ->Attach to Process. Choose transport as Nsight CPU Debugger and attach to your application. Then you could debug CUDA code
Open another VS. Choose transport as Default. Attach to the application then you could debug C++ code
Please pay attention, if the application is suspended by a VS, it could not be debugged by the other VS. You must resume current one and then switch to the other.

Debugging embedded device

I work on an embedded device on powerPC with WindRiver linux.
Almost always we debug using the logs. Sometimes gdb, which is really helpful.
But, the process I debug runs with more than 70 threads.
Using commands to move through the code is a cumbersome process, installing a GUI front end is not an option.
Is there any way that I can have an IDE like ECLIPSE, Netbeans to debug the process, which is running on this embedded device?
Is there any way that I can have an IDE like ECLIPSE, Netbeans
Yes. Many people debug embedded devices with Eclipse, by using gdbserver.

JNI function not getting invoked

I need to debug JNI issue of a team member. The problem is in a Java app interfacing a USB connected hardware using JNI. He mentions that JNI functions implemented in a C++ dll are not getting called by Java app. Also he specifically mentioned that it is a not an unsatisified link error problem, which was the first thing I would suspect.
The strange thing is that the Java App works fine on his development system and the JNI calls are being made properly. However on the target machine of the QA team, the Java app does not seem to work.
The DLL (32-bit) was generated using VS2010 and the target machine was WinXP/Win 7 32-bit system. I would rule out DLL method signature issue since DLL was recognised on the development system. As mentioned, it was not link issue.
What could be the issue in JNI methods not getting invoked at all? Could this be a problem with redistributables? How to debug (using JVM options) and ascertain the problem?
Standard debugging procedure:
set breakpoint in Java
run to breakpoint
attach debugger to java executable (visual studio attach by process ID)
set breakpoint in JNI.
continue Java program.