Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Make Snapshot::to_ignore a std::vector
[simgrid.git] / src / mc / mc_object_info.cpp
1 /* Copyright (c) 2014-2015. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #include <stddef.h>
8
9 #include <xbt/dynar.h>
10
11 #include "mc_object_info.h"
12 #include "mc_private.h"
13
14 extern "C" {
15
16 dw_frame_t MC_file_object_info_find_function(mc_object_info_t info, const void *ip)
17 {
18   xbt_dynar_t dynar = info->functions_index;
19   mc_function_index_item_t base =
20       (mc_function_index_item_t) xbt_dynar_get_ptr(dynar, 0);
21   int i = 0;
22   int j = xbt_dynar_length(dynar) - 1;
23   while (j >= i) {
24     int k = i + ((j - i) / 2);
25     if (ip < base[k].low_pc) {
26       j = k - 1;
27     } else if (ip >= base[k].high_pc) {
28       i = k + 1;
29     } else {
30       return base[k].function;
31     }
32   }
33   return NULL;
34 }
35
36 dw_variable_t MC_file_object_info_find_variable_by_name(mc_object_info_t info, const char* name)
37 {
38   unsigned int cursor = 0;
39   dw_variable_t variable;
40   xbt_dynar_foreach(info->global_variables, cursor, variable){
41     if(!strcmp(name, variable->name))
42       return variable;
43   }
44
45   return NULL;
46 }
47
48 }