JAVA JNI C调试 [英] JAVA JNI C Debugger

查看:378
本文介绍了JAVA JNI C调试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有调试器,它可以帮助调试Java程序JNI与C库一起?

Is there any debugger that helps debug a Java JNI program along with the C library?

我应该能够调试从静态无效的主要在Java中启动程序,并继续调试和地方破发点中的本地C函数,然后继续控制被从C转移到Java后的Java调试。

I should be able to debug the program starting from static void main in Java and continue to debug and place break points in the native c function and then continue to debug in Java after the control is transferred from C to Java.

推荐答案

一个Java虚拟机调试器是从本地code调试非常不同。目前还没有这样的成熟的解决方案为一体的,哪些是能够从Java无缝一步本地code和背面,同样的调试器。虽然这是一个非常刺激性的问题,这使得一些聪明的人尝试开发这样的解决方案,有undoubtely吨参与联合国想象的问题。我个人做以下列方式:

A Java Virtual Machine debugger is very different from native code debugger. There is currently no such MATURE solution as one and the same debugger which would be able to seamlessly step from Java to native code and back. While this is a very irritant problem which makes some smart people trying to develop such a solution, there is undoubtely tons of un-imaginable problems involved. I personally do it in the following way:


  1. 启动Java code在调试模式下,把一个断点在第一本机调用你有兴趣,你甚至可以实现一个静态的本地通话,不会做任何事情,但显著将使你的突破尽快。

  2. 火了本机调试。的这绝对是Eclipse的的相同的实例,给定两个prerequisities:你已经CDT安装和你的原生code的的方式编制,即调试信息是由CDT的理解。附加到爪哇(w.exe)运行Java code 过程。把一个断点在本地code。

  3. 当你需要通过JNI接口过渡,把尽量靠近调用入口/出口断点,你可以(或需要)。

  1. start your Java code in debug mode and put a breakpoint at the first native call you are interested in. You can even implement a static native call, which won't do anything significant but will enable you to break as soon as possible.
  2. fire up a native debugger. This absolutely can be the same instance of Eclipse, given two prerequisities: you have CDT installed and your native code was compiled in a way, that the debugging info is understood by CDT. Attach to the java(w.exe) process running your Java code. Put a breakpoint in the native code.
  3. Whenever you need to transition over JNI interfaces, put breakpoints as close to the call entry/exit as you can (or need).

这篇关于JAVA JNI C调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆