Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
679c0b4ae70b59d30f0b756cce770b8203ef7f02
[simgrid.git] / src / mc / mc_object_info.cpp
1 #include <stddef.h>
2
3 #include <xbt/dynar.h>
4
5 #include "mc_object_info.h"
6 #include "mc_private.h"
7
8 extern "C" {
9
10 dw_frame_t MC_file_object_info_find_function(mc_object_info_t info, const void *ip)
11 {
12   xbt_dynar_t dynar = info->functions_index;
13   mc_function_index_item_t base =
14       (mc_function_index_item_t) xbt_dynar_get_ptr(dynar, 0);
15   int i = 0;
16   int j = xbt_dynar_length(dynar) - 1;
17   while (j >= i) {
18     int k = i + ((j - i) / 2);
19     if (ip < base[k].low_pc) {
20       j = k - 1;
21     } else if (ip >= base[k].high_pc) {
22       i = k + 1;
23     } else {
24       return base[k].function;
25     }
26   }
27   return NULL;
28 }
29
30 dw_variable_t MC_file_object_info_find_variable_by_name(mc_object_info_t info, const char* name)
31 {
32   unsigned int cursor = 0;
33   dw_variable_t variable;
34   xbt_dynar_foreach(info->global_variables, cursor, variable){
35     if(!strcmp(name, variable->name))
36       return variable;
37   }
38
39   return NULL;
40 }
41
42 }