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

Locate end of function from within a UV2 debug function

I need to use a debug function to check the results of a function call. Is there any way to determine the address of the end of the function from within a debug function (or any other way to determine that the function has or is about to return)? I can get the start address easily by using \module\function, but the end seems to be more elusive. The SCOPE directive gets me close in that it will allow me to hard code the end address, but I would rather be able to determine it at runtime so I don't have to update the debug every time I compile.

Thanks

  • Is there any way to determine the address of the end of the function from within a debug function

    Not as far as I know.

    However, if this is just one or two functions you can create a simple assembler stub that calls the function. Then, you can set a breakpoint on the return to the assembler routine. For example, if your routine is named BOB...

    1. Rename the function BOB to BOB1.
    2. Create an assembler routine as follows:

    BOB:  LCALL BOB1
          RET
    

    3. Set a breakpoint on the RET in the assembler routine.

    Jon

  • you can create a simple assembler stub that calls the function

    Why does it need to be assembler (if you do not optimize to the hilt, which you wouldnot do for debug anyhow)?

    Erik

  • Why does it need to be assembler...

    Well, I guess it doesn't BUT it will be a lot simpler to do in assembly.

    If you write a the stub in C, then you'll probably have to deal with prototype mismatches and have to make the prototypes match and un-stack and re-stack the arguments to pass them to the final function. Writing this 2-line assembly stub is simpler, quick to do, requires no C machinations, and works 100% of the time (regardless of optimizer or any other settings).

    Jon

  • Ok, that makes sense, however do not forget that it may need a '_' if variables are involved.

    Erik