[lldb-dev] [Bug 13855] New: Local variable has incorrect value

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Sep 15 06:29:26 PDT 2012


http://llvm.org/bugs/show_bug.cgi?id=13855

             Bug #: 13855
           Summary: Local variable has incorrect value
           Product: lldb
           Version: unspecified
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: All Bugs
        AssignedTo: lldb-dev at cs.uiuc.edu
        ReportedBy: MacAndor.Nullbit at gmail.com
    Classification: Unclassified


NS_INLINE void codeRepresentation(NSSet *set, NSMutableString *buffer) {
    if (set.count == 1) {
        OpBase<OpCodeEmulator> *op = [set anyObject];
        if (getRegisterObject(op)) {
            [buffer appendString:[getRegisterObject(op) stringRepresentation]];
        } else {
            [op printValueCode:buffer];
        }
    } else if (set.count > 1) {
        OpBase<OpCodeEmulator> *op = [set anyObject];
        [buffer appendString:[getRegisterObject(op) stringRepresentation]]; //
<--debugger breakpoint sees "op = nil", while it has a value
    } else {
        @throw [NSException exceptionWithName:@"Getting code represenrarion
from empty set!"
                                       reason:nil
                                     userInfo:nil];
    }
}

Solution:
NS_INLINE void codeRepresentation(NSSet *set, NSMutableString *buffer) {
    OpBase<OpCodeEmulator> *op = [set anyObject]; //put the variable in parent
scope
    if (set.count == 1) {
        if (getRegisterObject(op)) {
            [buffer appendString:[getRegisterObject(op) stringRepresentation]];
        } else {
            [op printValueCode:buffer];
        }
    } else if (set.count > 1) {
        [buffer appendString:[getRegisterObject(op) stringRepresentation]]; //
<--debugger breakpoint sees valid value
    } else {
        @throw [NSException exceptionWithName:@"Getting code represenrarion
from empty set!"
                                       reason:nil
                                     userInfo:nil];
    }
}

Solution #2:
NS_INLINE void codeRepresentation(NSSet *set, NSMutableString *buffer) {
    if (set.count == 1) {
        OpBase<OpCodeEmulator> *op_a = [set anyObject]; //Rename op to op_a
        if (getRegisterObject(op_a)) {
            [buffer appendString:[getRegisterObject(op_a)
stringRepresentation]];
        } else {
            [op printValueCode:buffer];
        }
    } else if (set.count > 1) {
        OpBase<OpCodeEmulator> *op_b = [set anyObject]; //Rename op to op_b
        [buffer appendString:[getRegisterObject(op_b) stringRepresentation]];
// <--debugger breakpoint sees valid value
    } else {
        @throw [NSException exceptionWithName:@"Getting code represenrarion
from empty set!"
                                       reason:nil
                                     userInfo:nil];
    }
}

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the lldb-dev mailing list