ROSE  0.9.6a
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GenericDynamicLinking.C
Go to the documentation of this file.
1 /* Generic Dynamic Linking */
2 #include "sage3basic.h"
3 #include "stringify.h"
4 
5 using namespace rose;
6 
10 {
11  return p_name;
12 }
13 void
15 {
16  if (s!=p_name) {
17  if (p_name) {
18  p_name->set_parent(NULL);
20  }
21  p_name = s;
22  if (p_name)
23  p_name->set_parent(this);
24  set_isModified(true);
25  }
26 }
27 
29 void
30 SgAsmGenericDLL::dump(FILE *f, const char *prefix, ssize_t idx) const
31 {
32  char p[4096];
33  if (idx>=0) {
34  sprintf(p, "%sDLL[%zd].", prefix, idx);
35  } else {
36  sprintf(p, "%sDLL.", prefix);
37  }
38  const int w = std::max(1, DUMP_FIELD_WIDTH-(int)strlen(p));
39 
40  fprintf(f, "%s%-*s = \"%s\"\n", p, w, "lib_name", p_name->get_string(true).c_str());
41  for (size_t i = 0; i < p_symbols.size(); i++)
42  fprintf(f, "%s%-*s = [%zd] \"%s\"\n", p, w, "symbol_name", i, escapeString(p_symbols[i]).c_str());
43 }
44 
46 // Symbols and symbol tables
48 
49 void
51 {
52  p_name = new SgAsmBasicString("");
53  p_name->set_parent(this);
54 }
55 
59 {
60  return p_name;
61 }
62 void
64 {
65  if (s!=p_name) {
66  if (p_name) {
67  p_name->set_parent(NULL);
69  }
70  p_name = s;
71  if (p_name)
72  p_name->set_parent(this);
73  set_isModified(true);
74  }
75 }
76 
77 std::string
79 {
80 #ifndef _MSC_VER
82 #else
83  ROSE_ASSERT(false);
84  return "";
85 #endif
86 }
87 
88 std::string
90 {
91 #ifndef _MSC_VER
93 #else
94  ROSE_ASSERT(false);
95  return "";
96 #endif
97 }
98 
99 std::string
101 {
102 #ifndef _MSC_VER
104 #else
105  ROSE_ASSERT(false);
106  return "";
107 #endif
108 }
109 
111 void
112 SgAsmGenericSymbol::dump(FILE *f, const char *prefix, ssize_t idx) const
113 {
114  char p[4096];
115  if (idx>=0) {
116  sprintf(p, "%sSymbol[%zd].", prefix, idx);
117  } else {
118  sprintf(p, "%sSymbol.", prefix);
119  }
120  const int w = std::max(1, DUMP_FIELD_WIDTH-(int)strlen(p));
121 
122  fprintf(f, "%s%-*s = \"%s\"\n", p, w, "name", p_name->get_string(true).c_str());
123 
124  const char *s_def_state = NULL;
125  switch (p_def_state) {
126  case SYM_UNDEFINED: s_def_state = "undefined"; break;
127  case SYM_TENTATIVE: s_def_state = "tentative"; break;
128  case SYM_DEFINED: s_def_state = "defined"; break;
129  }
130  fprintf(f, "%s%-*s = %s\n", p, w, "def_state", s_def_state);
131 
132  const char *s_bind = NULL;
133  switch (p_binding) {
134  case SYM_NO_BINDING: s_bind = "no-binding"; break;
135  case SYM_LOCAL: s_bind = "local"; break;
136  case SYM_GLOBAL: s_bind = "global"; break;
137  case SYM_WEAK: s_bind = "weak"; break;
138  }
139  fprintf(f, "%s%-*s = %s\n", p, w, "binding", s_bind);
140 
141  const char *s_type = NULL;
142  switch (p_type) {
143  case SYM_NO_TYPE: s_type = "no-type"; break;
144  case SYM_DATA: s_type = "data"; break;
145  case SYM_IFUNC: s_type = "ifunc"; break;
146  case SYM_FUNC: s_type = "function"; break;
147  case SYM_SECTION: s_type = "section"; break;
148  case SYM_FILE: s_type = "file"; break;
149  case SYM_TLS: s_type = "thread"; break;
150  case SYM_REGISTER: s_type = "register"; break;
151  case SYM_ARRAY: s_type = "array"; break;
152  case SYM_COMMON: s_type = "common"; break;
153  }
154  fprintf(f, "%s%-*s = %s\n", p, w, "type", s_type);
155  if (p_bound) {
156  fprintf(f, "%s%-*s = [%d] \"%s\"\n", p, w, "bound", p_bound->get_id(), p_bound->get_name()->get_string(true).c_str());
157  } else {
158  fprintf(f, "%s%-*s = none\n", p, w, "bound");
159  }
160 
161  fprintf(f, "%s%-*s = 0x%08"PRIx64, p, w, "value", p_value);
162  if (p_value > 9) {
163  fprintf(f, " (unsigned)%"PRIu64, p_value);
164  if ((int64_t)p_value < 0) fprintf(f, " (signed)%"PRId64, (int64_t)p_value);
165  }
166  fputc('\n', f);
167 
168  fprintf(f, "%s%-*s = %"PRIu64" bytes\n", p, w, "size", p_size);
169 }