PeterMcKinnis / WorstCaseStack

This program is used to do static stack analysis on C source code to determine the worst case stack usage for each function
BSD 3-Clause "New" or "Revised" License
84 stars 28 forks source link

"Error locating function" which exists and it is called #18

Open SP8EBC opened 10 months ago

SP8EBC commented 10 months ago

I've got an error like below

<__main__.CallGraph object at 0x7f7493927a00>
Traceback (most recent call last):
  File "/home/mateusz/Documents/___STM32/ParaTNC/STM32L476_ParaMETEO/__stackanalysis/WCS.py", line 430, in <module>
    main()
  File "/home/mateusz/Documents/___STM32/ParaTNC/STM32L476_ParaMETEO/__stackanalysis/WCS.py", line 409, in main
    call_graph.read_rtl(tu, rtl_ext)
  File "/home/mateusz/Documents/___STM32/ParaTNC/STM32L476_ParaMETEO/__stackanalysis/WCS.py", line 171, in read_rtl
    raise Exception(f"Error locating function {fxn_name} in {tu}")
Exception: Error locating function http_client_split_hostname_and_path in ./http_client.c

The thing is that the function it is complaining about exists (static) and it is called from few places in this translation unit. Below You have an output from GCC with a source of that function. __stackanalysis.zip

/**
 * This functions splits the URL string into hostname and path
 *
 * It return a split point index which in case of
 * http://pogoda.cc:8080/meteo_backend/station/z_gss_zar/summary
 * will return an index of '/' after 8080
 *
 *  */
static uint16_t http_client_split_hostname_and_path(char * input, uint16_t input_ln) {

    uint16_t out = 0xFFFF;

    uint16_t iterator = 7;

    // check if URL starts correctly
    if (*input == 'h' && *(input + 1) == 't'  && *(input + 2) == 't'  && *(input + 3) == 'p'  && *(input + 4) == ':'  && *(input + 5) == '/'  && *(input + 6) == '/') {
        for (; iterator < input_ln; iterator++) {
            if (*(input + iterator) == '/') {

                out = iterator;

                break;
            }
        }
    }

    return out;
}
PeterMcKinnis commented 9 months ago

Do you have a code base that can replicate the issue?

SP8EBC commented 8 months ago

Do you have a code base that can replicate the issue?

This function is located in this file: https://github.com/SP8EBC/ParaTNC/blob/master/system/src/http_client/http_client.c starting on line 92. Currently target STM32L476_ParaMETEO of that project is configured in way it generates all files required for WCS operation.