diff --git a/cnd.debugger.common2/src/org/netbeans/modules/cnd/debugger/common2/debugger/options/Bundle.properties b/cnd.debugger.common2/src/org/netbeans/modules/cnd/debugger/common2/debugger/options/Bundle.properties --- a/cnd.debugger.common2/src/org/netbeans/modules/cnd/debugger/common2/debugger/options/Bundle.properties +++ b/cnd.debugger.common2/src/org/netbeans/modules/cnd/debugger/common2/debugger/options/Bundle.properties @@ -326,6 +326,13 @@ ACSD_balloon_eval_on=Turn on balloon expression evaluation ACSD_balloon_eval_off=Turn off balloon expression evaluation +LABEL_args_values_in_stack=Show arguments values in Call Stack and Debugging View windows +ACSD_args_values_in_stack=Show arguments values in Call Stack and Debugging View windows +MNEM_args_values_in_stack=S +ACSD_args_values_in_stack_on=Turn on Show arguments values in Call Stack and Debugging View windows +ACSD_args_values_in_stack_off=Turn off Show arguments values in Call Stack and Debugging View windows + + LABEL_save_breakpoints=Save and Restore Breakpoints ACSD_save_breakpoints=Save and restore breakpoints MNEM_save_breakpoints=S diff --git a/cnd.debugger.common2/src/org/netbeans/modules/cnd/debugger/common2/debugger/options/DebuggerOption.java b/cnd.debugger.common2/src/org/netbeans/modules/cnd/debugger/common2/debugger/options/DebuggerOption.java --- a/cnd.debugger.common2/src/org/netbeans/modules/cnd/debugger/common2/debugger/options/DebuggerOption.java +++ b/cnd.debugger.common2/src/org/netbeans/modules/cnd/debugger/common2/debugger/options/DebuggerOption.java @@ -691,6 +691,14 @@ "on", // NOI18N //default value false, // is engine option radio_or_check, false, true); //type + + public static final DebuggerOption ARGS_VALUES_IN_STACK = + new DebuggerOption( // NOI18N + "args_values_in_stack", // NOI18N //name + new String[] {"on", "off"}, // NOI18N //values + "on", // NOI18N //default value + false, // is engine option + radio_or_check, false, true); //type public static final DebuggerOption SESSION_REUSE = diff --git a/cnd.debugger.common2/src/org/netbeans/modules/cnd/debugger/common2/debugger/options/GlobalOptionSet.java b/cnd.debugger.common2/src/org/netbeans/modules/cnd/debugger/common2/debugger/options/GlobalOptionSet.java --- a/cnd.debugger.common2/src/org/netbeans/modules/cnd/debugger/common2/debugger/options/GlobalOptionSet.java +++ b/cnd.debugger.common2/src/org/netbeans/modules/cnd/debugger/common2/debugger/options/GlobalOptionSet.java @@ -95,6 +95,7 @@ DebuggerOption.TRACE_SPEED, DebuggerOption.RUN_AUTOSTART, DebuggerOption.BALLOON_EVAL, + DebuggerOption.ARGS_VALUES_IN_STACK, }; diff --git a/cnd.debugger.common2/src/org/netbeans/modules/cnd/debugger/common2/debugger/options/GlobalOptionsSubPanel.java b/cnd.debugger.common2/src/org/netbeans/modules/cnd/debugger/common2/debugger/options/GlobalOptionsSubPanel.java --- a/cnd.debugger.common2/src/org/netbeans/modules/cnd/debugger/common2/debugger/options/GlobalOptionsSubPanel.java +++ b/cnd.debugger.common2/src/org/netbeans/modules/cnd/debugger/common2/debugger/options/GlobalOptionsSubPanel.java @@ -65,13 +65,15 @@ DebuggerOption.FINISH_SESSION.createUI(), DebuggerOption.SESSION_REUSE.createUI(), DebuggerOption.BALLOON_EVAL.createUI(), - }; + DebuggerOption.ARGS_VALUES_IN_STACK.createUI(), + }; OptionUI[] panels = { //DebuggerOption.SUPPRESS_STARTUP_MESSAGE.createUI(), DebuggerOption.TRACE_SPEED.createUI(), DebuggerOption.FINISH_SESSION.createUI(), DebuggerOption.RUN_AUTOSTART.createUI(), DebuggerOption.BALLOON_EVAL.createUI(), + DebuggerOption.ARGS_VALUES_IN_STACK.createUI(), }; if (NativeDebuggerManager.isStandalone() || NativeDebuggerManager.isPL()) { @@ -136,7 +138,7 @@ setBorder(new javax.swing.border.EtchedBorder()); } - protected void setup(OptionUI[] panels) { + protected void setup(OptionUI[] panels) { UISet.add(panels); OptionUI.fillPanel(this, panels); } diff --git a/cnd.debugger.gdb2/src/org/netbeans/modules/cnd/debugger/gdb2/GdbDebuggerImpl.java b/cnd.debugger.gdb2/src/org/netbeans/modules/cnd/debugger/gdb2/GdbDebuggerImpl.java --- a/cnd.debugger.gdb2/src/org/netbeans/modules/cnd/debugger/gdb2/GdbDebuggerImpl.java +++ b/cnd.debugger.gdb2/src/org/netbeans/modules/cnd/debugger/gdb2/GdbDebuggerImpl.java @@ -1979,7 +1979,7 @@ System.out.println("tid_no " + currentThreadId); // NOI18N System.out.println("frame " + frame.toString()); // NOI18N } - GdbFrame f = new GdbFrame(this, frame, null, null); + GdbFrame f = new GdbFrame(this, frame, null); //if (index != -1) //threads[index] = new GdbThread(this, threadUpdater, tid_no, f); @@ -2066,7 +2066,7 @@ String id = thrList.getConstValue("id"); //NOI18N String name = thrList.getConstValue("target-id"); //NOI18N MIValue frame = thrList.valueOf(MI_FRAME);// frame entry - GdbFrame f = new GdbFrame(GdbDebuggerImpl.this, frame, null, null); + GdbFrame f = new GdbFrame(GdbDebuggerImpl.this, frame, null); f.setCurrent(true); // in order to let Thread make some updates | GDB response contains only current frame String state = thrList.getConstValue("state"); // NOI18N GdbThread gdbThread = new GdbThread(GdbDebuggerImpl.this, threadUpdater, id, name, new Frame[]{f}, state); @@ -2115,13 +2115,13 @@ result = (MIResult) results.get(i++); if (result.matches(MI_FRAME)) { MIValue frame = result.value(); - f = new GdbFrame(GdbDebuggerImpl.this, frame, null, null); + f = new GdbFrame(GdbDebuggerImpl.this, frame, null); } } else if (result.matches(MI_FRAME)) { name = "Thread ".concat(id); //NOI18N MIValue frame = result.value(); - f = new GdbFrame(GdbDebuggerImpl.this, frame, null, null); + f = new GdbFrame(GdbDebuggerImpl.this, frame, null); f.setCurrent(true); // in order to let Thread make some updates | GDB response contains only current frame } @@ -2239,7 +2239,7 @@ if (item.matches(MI_FRAME)) { MIValue frame = item.value(); - GdbFrame gdbFrame = new GdbFrame(GdbDebuggerImpl.this, frame, null, gdbThread); + GdbFrame gdbFrame = new GdbFrame(GdbDebuggerImpl.this, frame, gdbThread); if (gdbFrame.getNumber().equals(frameNo)) { gdbFrame.setCurrent(true); } @@ -2260,10 +2260,13 @@ MICommand cmd = new MiCommandImpl(peculiarity.stackListFramesCommand(id)) { @Override - protected void onDone(final MIRecord frames) { - + protected void onDone(final MIRecord framesRecord) { + //do not ask for arguments here + //it is too time expensive and too earlier // "1" means get both arg's name and value - String args_command = "-stack-list-arguments 1 --thread " + id; // NOI18N + String stack_list_args_param = + DebuggerOption.ARGS_VALUES_IN_STACK.isEnabled(NativeDebuggerManager.get().globalOptions()) ? "1" :"0"; + String args_command = "-stack-list-arguments " + stack_list_args_param + " --thread " + id; // NOI18N MICommand cmd3 = new MiCommandImpl(args_command) { @@ -2282,7 +2285,7 @@ } } - MITList results = frames.results(); + MITList results = framesRecord.results(); MITList stack_list = (MITList) results.valueOf("stack"); // NOI18N int size = stack_list.size(); @@ -2293,12 +2296,15 @@ MIResult frame = (MIResult) stack_list.get(vx); // try to find frame arguments + //no args here + //do not ask it ever MIResult frameArgs = null; if (args_list != null && vx < args_list.size()) { frameArgs = (MIResult) args_list.get(vx); } - GdbFrame gdbFrame = new GdbFrame(GdbDebuggerImpl.this, frame.value(), frameArgs, gdbThread); // TODO arguments request + GdbFrame gdbFrame = + new GdbFrame(GdbDebuggerImpl.this, frame.value(), frameArgs, gdbThread); // TODO arguments request if (gdbFrame.getNumber().equals(frameNo)) { gdbFrame.setCurrent(true); } @@ -2363,14 +2369,11 @@ System.out.println("registerStackModel " + model); // NOI18N } stackUpdater.addListener(model); - if (model != null) { - get_frames = true; -// if (state().isProcess && !state().isRunning) { -// showStackFrames(); -// } - } else { - get_frames = false; - } + get_frames = model != null; + if (get_frames && state().isProcess && !state().isRunning ) { + requestStack(); + } + } @Override @@ -2468,7 +2471,7 @@ private void visitCurrentSrc(GdbFrame f, MIRecord srcRecord) { MITList srcTuple = srcRecord.results(); if (f == null) - f = new GdbFrame(this, null, null, null); + f = new GdbFrame(this, null, null); // create a non-visited location because it may be assigned to // homeLoc @@ -2533,7 +2536,12 @@ * framerecords: what we got from -stack-list-frames = stack * args: what we got from -stack-list-arguments 1 = stack-args */ - private void setStackWithArgs(MIRecord framerecords, MIRecord args) { + //mromashova_bz#269898: we will not do this call ever with the 1 (names and values) + //it is too expensive to get all arguments for all frames even for one particular thread + //and the only need is Debuggin View, but we will show arg names only without values + private void setStackWithArgs(MIRecord framerecords + , MIRecord args + ) { MITList argsresults; MITList args_list = null; String stringframes; @@ -2585,9 +2593,14 @@ * for whole stack * framerecords: what we got from -stack-list-frames */ - private void setStack(final MIRecord framerecords) { + private void setStack(final MIRecord framerecords) { + //mromashova_bz#269898: // "1" means get both arg's name and value - String args_command = "-stack-list-arguments 1"; // NOI18N + String stack_list_args_param = + get_frames && DebuggerOption.ARGS_VALUES_IN_STACK.isEnabled(NativeDebuggerManager.get().globalOptions()) + ? "1" :"0"; + + String args_command = "-stack-list-arguments " + stack_list_args_param; // NOI18N MICommand cmd = new MiCommandImpl(args_command) { @@ -3789,21 +3802,24 @@ */ private void setLocals(boolean update_var, MIRecord locals) { MITList localsresults = locals.results(); - MITList locals_list = (MITList) localsresults.valueOf("locals"); // NOI18N + MITList locals_list = (MITList) localsresults.valueOf("variables"); // NOI18N int size = locals_list.size(); int local_count = size; List param_list = null; int params_count = 0; - // paramaters - GdbFrame cf = getCurrentFrame(); - if (cf != null) { - param_list = cf.getArgsList(); - if (param_list != null) { - params_count = param_list.size(); - } - } + //mromashova_bz#269898: we will use "-stack-list-variables --no-values" not "-stack-list-locals --no-values" + //and frame will never keep args +// // paramaters +// GdbFrame cf = getCurrentFrame(); +// if (cf != null) { +// //ask for the args as we will not ask now +// param_list = cf.getArgsList(); +// if (param_list != null) { +// params_count = param_list.size(); +// } +// } local_count += params_count; if (Log.Variable.mi_vars) { @@ -3820,6 +3836,9 @@ if (peculiarity.isLocalsOutputUnusual()) { localItem = ((MITList) localItem).get(0); } + if (localItem instanceof MITList) { + localItem = ((MITList) localItem).get(0); + } MIResult localvar = (MIResult) localItem; String var_name = localvar.value().asConst().value(); GdbVariable gv = variableBag.get(var_name, @@ -3978,12 +3997,14 @@ // For the scenario that stack view is closed and local view // is open, we need frame params info from here. - if (get_locals && frameValue != null) { - // needs to get args info - // frameValue include args info - guiStackFrames = new GdbFrame[] {new GdbFrame(this, frameValue, null, null)}; - } - + //mromashova_bz#269898: the above is incorrect anymore + //when locals are requested we will get arguments (names and values, no need for this) +// if (get_locals && frameValue != null) { +// // needs to get args info +// // frameValue include args info +// guiStackFrames = new GdbFrame[] {new GdbFrame(this, frameValue, null)}; +// } + if (srcResults != null) { boolean visited = false; stack = srcResults.valueOf("stack").asList(); // NOI18N @@ -4243,6 +4264,29 @@ gdb.sendCommand(cmd); } } + + //call this when Call Stack window is opened + private void requestStack() { + MICommand cmd = + new MiCommandImpl(peculiarity.stackListFramesCommand(currentThreadId)) { + @Override + protected void onDone(MIRecord record) { + setStack(record); + finish(); + } + @Override + protected void onError(MIRecord record) { +// if (get_frames) { +// setStack(record); +// } +//should show some message here I think + finish(); + } + + + }; + gdb.sendCommand(cmd); + } protected void requestStack(final MIRecord stopRecord) { MICommand cmd = @@ -5750,10 +5794,10 @@ @Override protected void onDone(MIRecord record) { - GdbFrame currentFrame = getCurrentFrame(); - if (currentFrame != null) { - currentFrame.varUpdated(var.getFullName(), value); - } +// GdbFrame currentFrame = getCurrentFrame(); +// if (currentFrame != null) { +// currentFrame.varUpdated(var.getFullName(), value); +// } updateMIVar(); finish(); } diff --git a/cnd.debugger.gdb2/src/org/netbeans/modules/cnd/debugger/gdb2/GdbFrame.java b/cnd.debugger.gdb2/src/org/netbeans/modules/cnd/debugger/gdb2/GdbFrame.java --- a/cnd.debugger.gdb2/src/org/netbeans/modules/cnd/debugger/gdb2/GdbFrame.java +++ b/cnd.debugger.gdb2/src/org/netbeans/modules/cnd/debugger/gdb2/GdbFrame.java @@ -46,19 +46,26 @@ import java.util.ArrayList; import java.util.List; -import org.netbeans.modules.cnd.debugger.gdb2.mi.MIResult; import org.netbeans.modules.cnd.debugger.gdb2.mi.MIValue; import org.netbeans.modules.cnd.debugger.gdb2.mi.MITList; import org.netbeans.modules.cnd.debugger.common2.debugger.Frame; import org.netbeans.modules.cnd.debugger.common2.debugger.Thread; +import org.netbeans.modules.cnd.debugger.gdb2.mi.MIResult; public final class GdbFrame extends Frame { private MITList MIframe; private final List argsArray = new ArrayList(); private String fullname; + + public GdbFrame(GdbDebuggerImpl debugger, MIValue frame, + Thread thread) { + this(debugger, frame, null, thread); + } - public GdbFrame(GdbDebuggerImpl debugger, MIValue frame, MIResult frameargs, Thread thread) { + public GdbFrame(GdbDebuggerImpl debugger, MIValue frame, + MIResult frameargs, + Thread thread) { super(debugger, thread); if (frame == null) { return; @@ -77,9 +84,9 @@ fullname = MIframe.getConstValue("fullname", null); // NOI18N MITList args_list = (MITList) MIframe.valueOf("args"); // NOI18N - if (args_list != null && frameargs != null) { - System.out.println("GdbFrame Impossible "); // NOI18N - } +// if (args_list != null && frameargs != null) { +// System.out.println("GdbFrame Impossible "); // NOI18N +// } // handle args info if (frameargs != null) { @@ -93,16 +100,25 @@ int args_count = args_list.size(); // iterate through args list for (int vx=0; vx < args_count; vx++) { - MIValue arg = (MIValue)args_list.get(vx); if (vx != 0) { sb.append(", "); // NOI18N - } - sb.append( arg.asTuple().getConstValue("name")); // NOI18N - MIValue value = arg.asTuple().valueOf("value"); // NOI18N - if (value != null) { - argsArray.add(new GdbLocal(arg)); - sb.append("="); // NOI18N - sb.append(value.asConst().value()); + } + if (args_list.get(vx) instanceof MIValue) { + MIValue arg = (MIValue)args_list.get(vx); + + sb.append( arg.asTuple().getConstValue("name")); // NOI18N + MIValue value = arg.asTuple().valueOf("value"); // NOI18N + if (value != null) { + argsArray.add(new GdbLocal(arg)); + sb.append("="); // NOI18N + sb.append(value.asConst().value()); + } + } else if (args_list.get(vx) instanceof MIResult) { + //mromashova_bz#269898: + //we have the list of names, no values at all + //which is correct!! as we will never call -stack-list-arguments 1 + //to get values, will call -stack-list-arguments 0 to get args names only + sb.append(((MIResult)args_list.get(vx)).value().asConst().value()); } } } @@ -121,10 +137,14 @@ public MITList getMIframe() { return MIframe; } + + public String getLevel() { + return frameno; + } - public List getArgsList() { - return argsArray; - } +// public List getArgsList() { +// return argsArray; +// } @Override public String getFullPath() { @@ -135,11 +155,11 @@ return fullname; } - void varUpdated(String name, String value) { - for (GdbLocal var : argsArray) { - if (var.getName().equals(name)) { - var.setValue(value); - } - } - } +// void varUpdated(String name, String value) { +// for (GdbLocal var : argsArray) { +// if (var.getName().equals(name)) { +// var.setValue(value); +// } +// } +// } } diff --git a/cnd.debugger.gdb2/src/org/netbeans/modules/cnd/debugger/gdb2/GdbVersionPeculiarity.java b/cnd.debugger.gdb2/src/org/netbeans/modules/cnd/debugger/gdb2/GdbVersionPeculiarity.java --- a/cnd.debugger.gdb2/src/org/netbeans/modules/cnd/debugger/gdb2/GdbVersionPeculiarity.java +++ b/cnd.debugger.gdb2/src/org/netbeans/modules/cnd/debugger/gdb2/GdbVersionPeculiarity.java @@ -239,7 +239,7 @@ } public String stackListLocalsCommand() { - return "-stack-list-locals --no-values"; // NOI18N + return "-stack-list-variables --no-values"; // NOI18N } public boolean isSupported() {