编写一个定制的eclipse调试器 [英] Writing a custom eclipse debugger

查看:96
本文介绍了编写一个定制的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.

这听起来像是在运行调试器时,您将可以访问具有变量的对象,您可以在类中使用toString(),或使用详细格式化程序来显示所需信息的变体。

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()调用可以得到相当详细的嵌套到调用中,显示整个数组等。详细的格式化程序也可以是相当复杂的。

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天全站免登陆