Skip to content

can not get variable #589

Closed
Closed
@EricCD-S

Description

@EricCD-S

i am trying to send "variables" request to get variable value, but i always get response like this:

{"success":true,"request_seq":7,"command":"variables","body":{"variables":[{"name":"arg0","value":"String[0]@12","type":"String[]","variablesReference":0,"namedVariables":0,"indexedVariables":0,"evaluateName":"arg0"}]},"seq":24,"type":"response"}

i guess it does not work as i want, here are my test code and my dap sequence, do i miss some settings?

code:
public class test {
public static void main(String[] args) {

    int number = 16;


    double squareRoot = calculateSquareRoot(number);


    for (int i = 0; i < 5; i++) {
        System.out.println("Iteration " + i + ": Square root of " + number + " is " + squareRoot);
    }


    if (squareRoot > 3) {
        System.out.println("The square root is greater than 3.");
    } else {
        System.out.println("The square root is less than or equal to 3.");
    }
}

public static double calculateSquareRoot(int number) {
    double result = Math.sqrt(number);
    return result;
}

}

dap sequence:
send:
Content-Length: 192

{"arguments":{"adapterID":"java","clientID":"debugger","clientName":"debugger","columnsStartAt1":true,"linesStartAt1":true,"pathFormat":"path"},"command":"initialize","seq":0,"type":"request"}

received:
Content-Length: 803

{"success":true,"request_seq":0,"command":"initialize","body":{"supportsConfigurationDoneRequest":true,"supportsHitConditionalBreakpoints":true,"supportsConditionalBreakpoints":true,"supportsEvaluateForHovers":true,"supportsCompletionsRequest":true,"supportsRestartFrame":true,"supportsSetVariable":true,"supportsRestartRequest":false,"supportTerminateDebuggee":true,"supportsDelayedStackTraceLoading":false,"supportsLogPoints":true,"supportsExceptionInfoRequest":true,"exceptionBreakpointFilters":[{"label":"Uncaught Exceptions","filter":"uncaught"},{"label":"Caught Exceptions","filter":"caught"}],"supportsDataBreakpoints":true,"supportsClipboardContext":true,"supportsFunctionBreakpoints":true,"supportsBreakpointLocationsRequest":true,"supportsStepInTargetsRequest":true},"seq":1,"type":"response"}

send:
Content-Length: 236

{"arguments":{"cwd":"C:/Users/user/Desktop/test","mainClass":"test","modulePaths":["C:/Users/user/Desktop/test"],"program":"C:\Users\user\Desktop\test\test.java","runtimeExecutable":"node"},"command":"launch","seq":1,"type":"request"}

received:
Content-Length: 109

{"event":"processid","body":{"processId":5916,"shellProcessId":-1,"type":"processid"},"seq":2,"type":"event"}

received:
Content-Length: 76

{"event":"initialized","body":{"type":"initialized"},"seq":3,"type":"event"}

received:
Content-Length: 77

{"success":true,"request_seq":1,"command":"launch","seq":4,"type":"response"}

send:
Content-Length: 211

{"arguments":{"breakpoints":[{"line":15}],"lines":[15],"source":{"name":"test.java","path":"C:\Users\user\Desktop\test\test.java"},"sourceModified":false},"command":"setBreakpoints","seq":2,"type":"request"}

received:
Content-Length: 158

{"success":true,"request_seq":2,"command":"setBreakpoints","body":{"breakpoints":[{"id":1,"verified":true,"line":15,"message":""}]},"seq":5,"type":"response"}

send:
Content-Length: 56

{"command":"configurationDone","seq":3,"type":"request"}

received:
Content-Length: 88

{"success":true,"request_seq":3,"command":"configurationDone","seq":6,"type":"response"}

received:
Content-Length: 98

{"event":"thread","body":{"reason":"started","threadId":8,"type":"thread"},"seq":7,"type":"event"}

received:
Content-Length: 98

{"event":"thread","body":{"reason":"started","threadId":1,"type":"thread"},"seq":8,"type":"event"}

received:
Content-Length: 154

{"event":"breakpoint","body":{"reason":"changed","breakpoint":{"id":1,"verified":true,"line":15,"message":""},"type":"breakpoint"},"seq":9,"type":"event"}

received:
Content-Length: 130

{"event":"stopped","body":{"threadId":1,"reason":"breakpoint","allThreadsStopped":false,"type":"stopped"},"seq":10,"type":"event"}

received:
Content-Length: 183

{"event":"output","body":{"category":"stdout","output":"Iteration 0: Square root of 16 is 4.0\r\n","variablesReference":0,"line":0,"column":0,"type":"output"},"seq":11,"type":"event"}

received:
Content-Length: 183

{"event":"output","body":{"category":"stdout","output":"Iteration 1: Square root of 16 is 4.0\r\n","variablesReference":0,"line":0,"column":0,"type":"output"},"seq":12,"type":"event"}

received:
Content-Length: 183

{"event":"output","body":{"category":"stdout","output":"Iteration 2: Square root of 16 is 4.0\r\n","variablesReference":0,"line":0,"column":0,"type":"output"},"seq":13,"type":"event"}

received:
Content-Length: 183

{"event":"output","body":{"category":"stdout","output":"Iteration 3: Square root of 16 is 4.0\r\n","variablesReference":0,"line":0,"column":0,"type":"output"},"seq":14,"type":"event"}

received:
Content-Length: 183

{"event":"output","body":{"category":"stdout","output":"Iteration 4: Square root of 16 is 4.0\r\n","variablesReference":0,"line":0,"column":0,"type":"output"},"seq":15,"type":"event"}

received:
Content-Length: 100

{"event":"thread","body":{"reason":"started","threadId":10,"type":"thread"},"seq":16,"type":"event"}

received:
Content-Length: 100

{"event":"thread","body":{"reason":"started","threadId":11,"type":"thread"},"seq":17,"type":"event"}

received:
Content-Length: 99

{"event":"thread","body":{"reason":"exited","threadId":11,"type":"thread"},"seq":18,"type":"event"}

received:
Content-Length: 99

{"event":"thread","body":{"reason":"exited","threadId":10,"type":"thread"},"seq":19,"type":"event"}

send:
Content-Length: 46

{"command":"threads","seq":4,"type":"request"}

received:
Content-Length: 447

{"success":true,"request_seq":4,"command":"threads","body":{"threads":[{"id":1,"name":"Thread [main]"},{"id":2,"name":"Thread [Reference Handler]"},{"id":3,"name":"Thread [Finalizer]"},{"id":4,"name":"Thread [Signal Dispatcher]"},{"id":5,"name":"Thread [Attach Listener]"},{"id":6,"name":"Thread [JVMCI-native CompilerThread0]"},{"id":7,"name":"Thread [Common-Cleaner]"},{"id":8,"name":"Thread [Notification Thread]"}]},"seq":20,"type":"response"}

send:
Content-Length: 76

{"arguments":{"threadId":1},"command":"stackTrace","seq":5,"type":"request"}

received:
Content-Length: 192

{"event":"telemetry","body":{"name":"dap","properties":{"command":"stackTrace","duration":3,"decompileSupport":"OFF","isDecompilerInvoked":"false"},"type":"telemetry"},"seq":21,"type":"event"}

received:
Content-Length: 182

{"success":true,"request_seq":5,"command":"stackTrace","body":{"stackFrames":[{"id":1,"line":15,"column":1,"name":"test.main(String[])"}],"totalFrames":1},"seq":22,"type":"response"}

send:
Content-Length: 71

{"arguments":{"frameId":1},"command":"scopes","seq":6,"type":"request"}

received:
Content-Length: 156

{"success":true,"request_seq":6,"command":"scopes","body":{"scopes":[{"name":"Local","variablesReference":2,"expensive":false}]},"seq":23,"type":"response"}

send:
Content-Length: 85

{"arguments":{"variablesReference":2},"command":"variables","seq":7,"type":"request"}

received:
Content-Length: 246

{"success":true,"request_seq":7,"command":"variables","body":{"variables":[{"name":"arg0","value":"String[0]@12","type":"String[]","variablesReference":0,"namedVariables":0,"indexedVariables":0,"evaluateName":"arg0"}]},"seq":24,"type":"response"}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions