Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
7fc980821e116c757c4de96a70a40520eeb77b11
[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 namespace simgrid {
15 namespace mc {
16
17 // Type
18
19 Type::Type()
20 {
21   this->type = 0;
22   this->id = 0;
23   this->byte_size = 0;
24   this->element_count = 0;
25   this->is_pointer_type = 0;
26   this->subtype = nullptr;
27   this->full_type = nullptr;
28 }
29
30 // Type
31
32 Variable::Variable()
33 {
34   this->dwarf_offset = 0;
35   this->global = 0;
36   this->type = nullptr;
37   this->address = nullptr;
38   this->start_scope = 0;
39   this->object_info = nullptr;
40 }
41
42 // Frame
43
44 Frame::Frame()
45 {
46   this->tag = 0;
47   this->low_pc = nullptr;
48   this->high_pc = nullptr;
49   this->id = 0;
50   this->abstract_origin_id = 0;
51   this->object_info = nullptr;
52 }
53
54 // ObjectInformations
55
56 mc_frame_t ObjectInformation::find_function(const void *ip) const
57 {
58   xbt_dynar_t dynar = this->functions_index;
59   mc_function_index_item_t base =
60       (mc_function_index_item_t) xbt_dynar_get_ptr(dynar, 0);
61   int i = 0;
62   int j = xbt_dynar_length(dynar) - 1;
63   while (j >= i) {
64     int k = i + ((j - i) / 2);
65     if (ip < base[k].low_pc) {
66       j = k - 1;
67     } else if (ip >= base[k].high_pc) {
68       i = k + 1;
69     } else {
70       return base[k].function;
71     }
72   }
73   return nullptr;
74 }
75
76 simgrid::mc::Variable* ObjectInformation::find_variable(const char* name) const
77 {
78   for (simgrid::mc::Variable& variable : this->global_variables)
79     if(variable.name == name)
80       return &variable;
81   return nullptr;
82 }
83
84 }
85 }