• AVR Freaks

Hot!XC8 __cyg_profile_func_enter

Author
DungeonLords
New Member
  • Total Posts : 9
  • Reward points : 0
  • Joined: 2019/05/05 08:41:21
  • Location: 0
  • Status: offline
2019/09/01 21:13:42 (permalink)
0

XC8 __cyg_profile_func_enter

I try to use __cyg_profile_func_enter and __cyg_profile_func_exit to log every function in my code. And it is works.
 
But _delay_ms(1) broke: "error: __builtin_avr_delay_cycles expects a compile time integer constant"
 
In avr-gcc the same problem https://www.avrfreaks.net...n-pointer-size-problem
 
Full code in zip.
#1

3 Replies Related Threads

    ric
    Super Member
    • Total Posts : 24282
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: XC8 __cyg_profile_func_enter 2019/09/01 21:28:15 (permalink)
    -1 (1)
    The correct name is __delay_ms().
    Did you mean to only put one leading underscore in your post?
    This is a macro, not a function.
     
    I assume from the error that you are compiling for an AVR part. Wouldn't hurt to mention that.
    I've struck out my comment about the name, as that macro is only available for PIC processors.
    The AVR user guide doesn't mention _delay_ms() at all, only __builtin_avr_delay_cycles()
     
    Edit#2.
    avr-libc-user-manual.pdf does document _delay_ms(), and mentions that you must #define F_CPU to use it.
    I can't see a define for F_CPU in your code.
     
     
    post edited by ric - 2019/09/01 21:45:22

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #2
    du00000001
    Just Some Member
    • Total Posts : 3175
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: XC8 __cyg_profile_func_enter 2019/09/02 02:31:43 (permalink)
    +1 (1)
    @ DungeonLords
     
    Now, what do you expect?
    The delay() "functions" (in whatever spelling) are more like makros. If your cyg* cannot handle these, tell it to spare them.

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #3
    DungeonLords
    New Member
    • Total Posts : 9
    • Reward points : 0
    • Joined: 2019/05/05 08:41:21
    • Location: 0
    • Status: offline
    Re: XC8 __cyg_profile_func_enter 2019/09/07 01:31:20 (permalink)
    0
    du00000001
    @ DungeonLords
     
    Now, what do you expect?
    The delay() "functions" (in whatever spelling) are more like makros. If your cyg* cannot handle these, tell it to spare them.


    I expect that I can log every function.
    I think the problem is because __builtin_avr_delay_cycles() is built-in (intrinsic) function. And there is some problem to add prologue and epilogue to built-in function.
     
    There is full code of not working project with -finstrument-functions at linker:

    #include <avr/io.h>
    #include <stdint.h>
    #include <stdlib.h>
    #include <stdio.h>
    #include <limits.h>
    #include <util/delay.h>

    int main(void){
        DDRA|=(1<<PA2);
        while(1){
            for(volatile uint16_t i=UINT_MAX;i>0;i--);
            _delay_ms(1);  //comment this to 'solve' problem
        }
    }

    void __cyg_profile_func_enter (void *func,  void *caller) __attribute__((no_instrument_function));
    void __cyg_profile_func_enter (void *func,  void *caller)
    {
        PORTA^=(1<<PA2);
    }

    void __cyg_profile_func_exit (void *func, void *caller) __attribute__((no_instrument_function));
    void __cyg_profile_func_exit (void *func, void *caller)
    {
    }

     
    P.S. 2ric F_CPU is define in linker, _delay_ms() is util/delay.h function for loop delay that known by every avr developer. _delay_ms contains the problem function __builtin_avr_delay_cycles(). I can do like for(volatile uint16_t i=UINT_MAX;i>0;i--) instead of _delay_ms(123456). But this is not usefull and I do not know how translate loop into ms. Because 1 loop iteration != 1 tick of F_CPU.
    post edited by DungeonLords - 2019/09/07 06:33:54
    #4
    Jump to:
    © 2019 APG vNext Commercial Version 4.5