This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

uVision2 User Functions get wrong values

My Client has uVision2 v2.07.

I want to write a uVision2 Debugger User Function which will run to a breakpoint and then display program data values.

eg:

FUNC void test ( void ) {
exec( "G" );
printf( "%02X\n", myVar );
}

This should GO to a previously-defined breakpoint, then display the value of myVar.

myVar is a 'static' local variable inside a function; the breakpoint is inside the same function.

Unfortunately, the *wrong* value of myVar is displayed - usually the value from *before* the GO!!!

The same problem arises if the User Debug Function tries to examine values, or use 'exec' to display values via EVAL, etc.

Does anyone else have this problem?
Does anyone know how to fix it?

Obviously this renders the uVision2 Debugger User Functions virtually useless for automatic testing if the values displayed cannot be relied upon!


Parents
  • Set a breakpoint on the instruction where you want to print the value.

    Use the Debug Menu to open the Breakpoints... Dialog.

    Add the printf( "%02X\n", myVar ) as the command for the breakpoint you just added.

    Now, whenever you reach that breakpoint, the debugger will automatically print the value of myVar.

    Keil Support

Reply
  • Set a breakpoint on the instruction where you want to print the value.

    Use the Debug Menu to open the Breakpoints... Dialog.

    Add the printf( "%02X\n", myVar ) as the command for the breakpoint you just added.

    Now, whenever you reach that breakpoint, the debugger will automatically print the value of myVar.

    Keil Support

Children
  • But why doesn't the User Function print the correct values?
    Are you saying that this is a real bug/limitation in User Functions?

    I quote from the uVision2 manual, "You may create functions that ... log memory contents to a file ..."

    I am trying to develop some automatic test harnesses using uVision2 User Functions.
    Therefore the User Functions need access to the program variables to test for Pass/Fail conditions.
    This is impossible if the values read by User Functions are incorrect!

  • The problem with the FUNC is that it does not DELAY and WAIT for the break point.

    FUNC void test ( void ) {
    exec( "G" );
    printf( "%02X\n", myVar );
    }
    

    This function executes the Go command and then immediately executes a printf which prints the value of myVar. This is how the FUNC was designed.

    This all happens instantaneously (for the most part). The printf is not delayed until the breakpoint.

    Keil Support

  • Ah ha!
    That figures.

    The next question, of course, is *how* to make the FUNC wait for the breakpoint?

    Obviously, to write an automatic test harness, it needs to be able to setup preconditions, run to the required point, then test for pass/fail result.

  • There is no way to make a FUNC in the deubgger "wait" for a breakpoint.

    If you need to write a debugger function that waits for a while, take a look at the SIGNAL functions.

    Why do you need to have a FUNC that does this...

    FUNC void test ( void ) {
    exec( "G" );
    /*** WAIT FOR THE BREAKPOINT ***/
    printf( "%02X\n", myVar );
    }

    When assigning the printf call to the breakpoint does EXACTLY what it appears you are trying to do?

    If you need to do more than just print a value, you can create a separate FUNC for each breakpoint. For example:

    FUNC void bp_1 ( void ) {
    /*** Execute for Breakpoint #1 ***/
    printf( "%02X\n", myVar );
    /*** Do other useful stuff here ***/
    }
    

    FUNC void bp_2 ( void ) {
    /*** Execute for Breakpoint #2 ***/
    printf( "%02X\n", yourVar );
    /*** Do other useful stuff here ***/
    }
    

    Then, when you define each breakpoint, you can call the bp_1 () and bp_2 () functions.

    Keil Support