编写自定义 Eclipse 调试器 [英] Writing a custom eclipse debugger

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

问题描述

必须有某种方法可以解决这个问题,而无需编写全新的调试器.我目前正在研究在现有 java 调试器之上构建的方法.如果有人对如何获取 Java 调试器已有的信息(关于堆栈帧、变量、原始数据等)有任何想法,那将非常有帮助.

There must be some way I can approach this without writing a whole new debugger. I'm currently looking into ways to build on top of the existing java debugger. If anyone has any ideas on how to grab information the Java debugger already has (about stack frames, variables, raw data etc.), that would be really helpful.

--

我想要做的是我有这个基于 Java 的框架/API,我想编写一个针对我的框架定制的 Eclipse 插件调试器.这是一个简单的例子:

What I'm trying to do is I have this framework/API built on Java, and I would like to write an eclipse plugin debugger that is customized to my framework. Here is a simple example:

我有两个类,一个叫作用域,一个叫变量.范围包含变量映射.代码都在java中,但我使用这种范围变量关系几乎就像一种新语言,并且想要一个变量调试选项卡,它为我提供当前活动范围的列表以及当前存储在其中的变量.这是一些代码:

I have two classes, one called scope and one called variable. The scope holds a map of variables. The code is all in java, but I'm using this scope-variable relationship almost like a new language, and would like a variable debug tab that gives me a list of currently active scopes with the variables that are currently stored inside. Here is some code:

import java.util.Hashtable;

public class Scope {
    private Hashtable<String, Variable> variableList = new Hashtable<String, Variable>();

   // constructor 
    public Scope(){

    }

    public void put(String key, Variable v){
        variableList.put(key, v);
    }

    public Variable get(String key){
        return variableList.get(key);
    }


}

public class Variable {

    private String value;
    private String name;

    public Variable(String aName, String aValue){
        name = aName;
        value = aValue;
    }

    public String getValue(){
        return value;
    }

    public String getName(){
        return name;
    }

    public void setValue(String aValue){
        value = aValue;
    }
}

这显然是一个非常简单的例子,但我想完成与此类似的事情,我可以获得一个变量窗口,设置一个断点,并让一个调试器"列出我的活动范围对象和里面的变量对象.

This is obviously an extremely simple example, but I would like to accomplish something similar to this where I can get a variables window, set a breakpoint, and have a "debugger" list out my active scope objects and the variable objects inside.

我一直在努力阅读和理解:http://www.eclipse.org/articles/Article-Debugger/how-to.html

I've been trying to read and understand: http://www.eclipse.org/articles/Article-Debugger/how-to.html

而且它非常密集(以及非常过时),但我会尝试花一些时间来理解它.我只是想看看是否有人对如何解决此类问题有任何高级建议,因为我在 eclipse 中开发插件或制作调试器的经验很少.

and its pretty dense (as well as extremely outdated), but I will try to take some time to understand it. I just wanted to see if anyone had any high level recommendations on how to approach this type of problem, as I have little experience developing plugins in eclipse or making debuggers.

谢谢!

推荐答案

在 eclipse edc 调试器上工作过,听起来写一个完整的调试器并不是你想要的.

having worked on the eclipse edc debugger, it sounds like writing a whole debugger is not so much what you want.

听起来,在运行调试器时,您将可以访问具有您感兴趣的变量和范围的对象.

it sounds like while running the debugger, you will have access to the objects that have the variables and scopes you are interested in.

您可以在类本身中使用 toString() 或使用详细格式化程序来显示所需信息的变体.toString() 调用可以非常详细并嵌套到调用中、显示整个数组等.详细格式化程序也可以非常复杂.

you can use toString() in the classes themselves or use detail formatters to display a variation on the information you want. the toString() call can get quite detailed and nest into calls, show whole arrays, etc. detail formatters can also be quite complex.

参见 http://www.robertwloch.net/2012/01/eclipse-tips-tricks-detail-formatter/.这是几个 URL 中最好的一个(我与作者没有关联).

see http://www.robertwloch.net/2012/01/eclipse-tips-tricks-detail-formatter/ . it's the best of several URLs (i have no association with the author).

一旦您对变量和范围对象的输出感到满意,您应该能够添加监视表达式,它们将始终在您的表达式窗口中显示它们(因此您不必依赖堆栈帧中的局部变量你可能在).

once you are happy with the output of the Variable and Scope objects, you should be able to add watch expressions that will always show them in your expressions window (thus you don't have to rely on local variables in the stack frame you may be in).

这应该会为您提供您正在跟踪的框架中的变量和范围列表……希望无需编写整个 Eclipse 调试器插件即可.

this should then give you the list of Variables and Scopes from your framework that you are tracking … hopefully without having to write an entire eclipse debugger plugin to do so.

这篇关于编写自定义 Eclipse 调试器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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