Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[Dltk-dev] debugger is a bit fragile..

Hi,

all commands that are send to the debug process are a bit fragile..
If they somehow go wrong somehow a exception happens then everything start to hang because in the eclipse side
we keep waiting for it and so on.

For example the ContextGet command i already do now this:



        StringBuffer properties = new StringBuffer();
        try
        {
            int level = Integer.parseInt((String) options.get("-d"));
            int context = Integer.parseInt((String) options.get("-c"));
            DBGPDebugFrame stackFrame = this.debugger.getStackManager().getStackFrame(level);
            Scriptable this1 = stackFrame.getThis();
            if (this1 != null && context == LOCAL_CONTEXT_ID) {
                this.debugger.printProperty("this", "this", this1, properties, 0, false);
            }
           
            Scriptable scriptable = stackFrame.getThis();
            HashSet doubles = new HashSet();
            if (context == GLOBAL_CONTEXT_ID)
            {
                sendAllIds(properties, stackFrame, scriptable.getParentScope(),doubles,true);
            }
            else if (context == LOCAL_CONTEXT_ID)
            {
                String[] propertyIds = stackFrame.getParametersAndVars();
                for (int a = 0; a < propertyIds.length; a++) {
                    String id = propertyIds[a].toString();
                    Object value = stackFrame.getValue(a);
                    if (!(value instanceof Function)) // HACK because ShowFunctionsAction doesnt work because of the lazy behavior of plugins in Eclipse
                    {
                        this.debugger.printProperty(id, id, value, properties, 0, true);
                    }
       
                }
                sendAllIds(properties, stackFrame, scriptable,doubles,false);
            }
        }
        catch (Throwable t)
        {
            // never let the debugger crash. the printResponse below has to go on.
            t.printStackTrace();
        }
        this.debugger.printResponse("<response command=\"context_get\"\r\n"
                + "status=\"starting\"" + " reason=\"ok\""
                + " transaction_id=\"" + options.get("-i") + "\">\r\n"
                + properties + "</response>\r\n" + "");
   
        StringBuffer properties = new StringBuffer();
        try
        {
            int level = Integer.parseInt((String) options.get("-d"));
            int context = Integer.parseInt((String) options.get("-c"));
            DBGPDebugFrame stackFrame = this.debugger.getStackManager().getStackFrame(level);
            Scriptable this1 = stackFrame.getThis();
            if (this1 != null && context == LOCAL_CONTEXT_ID) {
                this.debugger.printProperty("this", "this", this1, properties, 0, false);
            }
           
            Scriptable scriptable = stackFrame.getThis();
            HashSet doubles = new HashSet();
            if (context == GLOBAL_CONTEXT_ID)
            {
                sendAllIds(properties, stackFrame, scriptable.getParentScope(),doubles,true);
            }
            else if (context == LOCAL_CONTEXT_ID)
            {
                String[] propertyIds = stackFrame.getParametersAndVars();
                for (int a = 0; a < propertyIds.length; a++) {
                    String id = propertyIds[a].toString();
                    Object value = stackFrame.getValue(a);
                    if (!(value instanceof Function)) // HACK because ShowFunctionsAction doesnt work because of the lazy behavior of plugins in Eclipse
                    {
                        this.debugger.printProperty(id, id, value, properties, 0, true);
                    }
       
                }
                sendAllIds(properties, stackFrame, scriptable,doubles,false);
            }
        }
        catch (Throwable t)   <<<<<<<<<<<<<<<<
        {
            // never let the debugger crash. the printResponse below has to go on.
            t.printStackTrace();
        }
        this.debugger.printResponse("<response command=\"context_get\"\r\n"
                + "status=\"starting\"" + " reason=\"ok\""
                + " transaction_id=\"" + options.get("-i") + "\">\r\n"
                + properties + "</response>\r\n" + "");
   

But cant we make this somehow a bit better?

i also made the thread that reads in the commands like that:

                        try
                        {
                            object.parseAndExecute(result, options);
                        }
                        catch (Throwable t)
                        {
                            t.printStackTrace();
                        }

so that that will go on no matter what

But now i guess in eclipse side it will be keep waiting?

isnt it possible to have something like this in the thread that reads in the commands:

                        try
                        {
                            object.parseAndExecute(result, options);
                        }
                        catch (Throwable t)
                        {
                            object.sendExceptionClose(); // Or what ever name?
                        }

and that shouldnt bomb out and always try to send the closing or result string that the eclipse side expects?

johan





Back to the top