How get value of variable that has been optimized out?

gdb optimized out
value may have been optimized out
gdb core dump optimized out
core optimized out
nptr optimized out
netbeans debugger optimized out

Some variables can be "optimized out" during Javascript execution. Thus values of such variables are not available for inspection while debugging (User documentation). Variables view shows (optimized away) message and console throws following error if the variable is tried to be evaluated:

Error: variable has been optimized out

Is there any way to enforce evaluation of such variable or disable this optimization in Firefox?

Use the variable in a way that prevents this optimisation.

function NOP() {}

// then in the optimised code

    // debugging here should now show `myvar`

Value optimized out. Reverse debugging to the rescue!, Find out how reverse-debugging can make you feel better. you need to be fluent in assembly-level debugging, and then you just have a tedious and when the variable is set, until some later time when its value becomes optimized out. In other words, the instruction at address 0x51d hasn't been executed yet​, and the  To view the "optimized-out" value of a variable during debugging, you need to turn off gcccompiler optimization, either on a per-variable basis, or program-wide. Solution One If you are interested in a particular variable in gdb, you can delare the variable as "volatile" and recompile the code.

When a variable has been "optimized away," it just means that it's not being modified in the context of the current scope. Hence, the JavaScript engine has done some optimization magic and stashed that variable out of the way for the time being. For example, say you're using lodash to iterate over a collection of some kind.

var parentThingy = [];
var childThingy = [];
_.each (collectionThingy, function(data){

    // parentThingy is not being modified inside this callback
    // so it will be "optimized away" while you are inside this
    // function scope.

    var transformed;
    if (data.someFlag) {
        transformed = transformDataSomehow(data);

    // childThingy is being modified, so you will be able to
    // see its value in the debugger.

    if (transformed) {

// Now that you've exited the callback scope, you will be able to see
// the value of parentThingy again.

if (childThingy.length > 1){

You could use the NOP suggestion to force parentThingy to be visible in the callback scope, but since you're not modifying parentThingy inside that callback, you don't need to see it. It hasn't changed and won't change. It's not relevant to the code you're currently debugging. Once you've exited the callback's scope parentThingy will be visible to the debugger again.

FYI: this isn't a Firefox thing. Chrome does the same thing, it just uses different verbiage to indicate the variable is irrelevant to the current scope.

variables optimized out when debugging – IDEs Support (IntelliJ , Hi! On high optimization levels, the compiler can eliminate intermediate values, as you have seen here. Please see this stackoverflow  When I try to print the variable with the lower-case letters, I get "Value has been optimized out." After searching online, I found it's related to an optimization flag. Typically, the problem is solved with using -O0, but it's already compiled with that flag.

If you need to debug this variable, then you have to set the breakpoint at a place inside the function where this variable is declared.

Lets say you need to debugg the variable


function(value) {
   // If you set the breakpoint somewhere here it is OK {

       // If you set the breakpoint here you will get a Error: variable has been optimized out



Viewing a variable thats "<optimized out>" · Issue #14488 · dart-lang , return y + 1; // Break here: The debugger shows x = <optimized out> If the original submitter believes that the value has been incorrectly  Re: Variables being optimized out JoMe_264151 Aug 27, 2015 3:21 AM ( in response to DaHu_285096 ) When variables are put into registers for optimization you will not see a correct value in the debugger.

Error: variable mygif has been optimized out, While I never got such a message, your issue (based on the shared code) is most likely the fact you are trying to use the import identifier in your  I have been having trouble with this optimizing out of variables in several projects and it seems I do not understand when this happens. In the last case I had a variable defined within scope of a procedure (method) that retrieved info from a serial port buffer and used the value to store a record in SPI flash IC.

941287, Since it's optimized out, we don't have access to the value anymore, right? I don't think we need to have a detailed message, but something short and sweet that Frame.eval, and 'varname' is an extant binding that's been optimized out,  $1 = <value optimized out> (gdb) set found=0. Left operand of assignment is not an lvalue. Why after executing line 903 it again executes the same for 905 908 910? Another things is found is a bool-type variable, so why it is showing value optimized out? I am not able to set the value of found as well.

Debugging with gdb - Examining the Stack, Some variables can be "optimized out" during Javascript execution. Thus values of such variables are not available for inspection while  New-Variable : Cannot overwrite variable ShowXenAppTable because the variable has been optimized. Try using the New-Variable or Set-Variable cmdlet (without any aliases), or dot-source the command that you are using to set the

  • Can you provide example JS code that will trigger this optimization?
  • Show us the actual code that leads to this.
  • I would strongly disagree with the statement "you don't need to see it". If you're developing code, and you're experimentally poking around different values to try to debug something, it is totally possible that you need to see it. To have no option to see it, except via a hacky NOP() trick is ... frustrating