Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1 | //===-- SBModule.cpp --------------------------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "lldb/API/SBModule.h" |
Greg Clayton | 0996003 | 2010-09-10 18:31:35 +0000 | [diff] [blame] | 11 | #include "lldb/API/SBAddress.h" |
| 12 | #include "lldb/API/SBFileSpec.h" |
Greg Clayton | 226cce2 | 2013-07-08 22:22:41 +0000 | [diff] [blame] | 13 | #include "lldb/API/SBModuleSpec.h" |
Greg Clayton | c966054 | 2012-02-05 02:38:54 +0000 | [diff] [blame] | 14 | #include "lldb/API/SBProcess.h" |
Caroline Tice | dde9cff | 2010-09-20 05:20:02 +0000 | [diff] [blame] | 15 | #include "lldb/API/SBStream.h" |
Greg Clayton | fe356d3 | 2011-06-21 01:34:41 +0000 | [diff] [blame] | 16 | #include "lldb/API/SBSymbolContextList.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 17 | #include "lldb/Core/Module.h" |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 18 | #include "lldb/Core/Log.h" |
Greg Clayton | 1f74607 | 2012-08-29 21:13:06 +0000 | [diff] [blame] | 19 | #include "lldb/Core/Section.h" |
Greg Clayton | 38adbbb | 2010-10-31 19:57:43 +0000 | [diff] [blame] | 20 | #include "lldb/Core/StreamString.h" |
Greg Clayton | dea8cb4 | 2011-06-29 22:09:02 +0000 | [diff] [blame] | 21 | #include "lldb/Core/ValueObjectList.h" |
| 22 | #include "lldb/Core/ValueObjectVariable.h" |
Greg Clayton | 1f74607 | 2012-08-29 21:13:06 +0000 | [diff] [blame] | 23 | #include "lldb/Symbol/ObjectFile.h" |
Enrico Granata | 6f3533f | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 24 | #include "lldb/Symbol/SymbolVendor.h" |
Greg Clayton | 1f74607 | 2012-08-29 21:13:06 +0000 | [diff] [blame] | 25 | #include "lldb/Symbol/Symtab.h" |
Greg Clayton | dea8cb4 | 2011-06-29 22:09:02 +0000 | [diff] [blame] | 26 | #include "lldb/Symbol/VariableList.h" |
| 27 | #include "lldb/Target/Target.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 28 | |
| 29 | using namespace lldb; |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 30 | using namespace lldb_private; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 31 | |
| 32 | |
| 33 | SBModule::SBModule () : |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 34 | m_opaque_sp () |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 35 | { |
| 36 | } |
| 37 | |
| 38 | SBModule::SBModule (const lldb::ModuleSP& module_sp) : |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 39 | m_opaque_sp (module_sp) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 40 | { |
| 41 | } |
| 42 | |
Greg Clayton | 226cce2 | 2013-07-08 22:22:41 +0000 | [diff] [blame] | 43 | SBModule::SBModule(const SBModuleSpec &module_spec) : |
| 44 | m_opaque_sp () |
| 45 | { |
| 46 | ModuleSP module_sp; |
| 47 | Error error = ModuleList::GetSharedModule (*module_spec.m_opaque_ap, |
| 48 | module_sp, |
| 49 | NULL, |
| 50 | NULL, |
| 51 | NULL); |
| 52 | if (module_sp) |
| 53 | SetSP(module_sp); |
| 54 | } |
| 55 | |
Greg Clayton | efabb12 | 2010-11-05 23:17:00 +0000 | [diff] [blame] | 56 | SBModule::SBModule(const SBModule &rhs) : |
| 57 | m_opaque_sp (rhs.m_opaque_sp) |
| 58 | { |
| 59 | } |
| 60 | |
Greg Clayton | c966054 | 2012-02-05 02:38:54 +0000 | [diff] [blame] | 61 | SBModule::SBModule (lldb::SBProcess &process, lldb::addr_t header_addr) : |
| 62 | m_opaque_sp () |
| 63 | { |
| 64 | ProcessSP process_sp (process.GetSP()); |
| 65 | if (process_sp) |
Greg Clayton | c859e2d | 2012-02-13 23:10:39 +0000 | [diff] [blame] | 66 | { |
Greg Clayton | 39f7ee8 | 2013-02-01 21:38:35 +0000 | [diff] [blame] | 67 | m_opaque_sp = process_sp->ReadModuleFromMemory (FileSpec(), header_addr); |
| 68 | if (m_opaque_sp) |
| 69 | { |
| 70 | Target &target = process_sp->GetTarget(); |
| 71 | bool changed = false; |
Greg Clayton | 751caf6 | 2014-02-07 22:54:47 +0000 | [diff] [blame] | 72 | m_opaque_sp->SetLoadAddress(target, 0, true, changed); |
Greg Clayton | 39f7ee8 | 2013-02-01 21:38:35 +0000 | [diff] [blame] | 73 | target.GetImages().Append(m_opaque_sp); |
| 74 | } |
Greg Clayton | c859e2d | 2012-02-13 23:10:39 +0000 | [diff] [blame] | 75 | } |
Greg Clayton | c966054 | 2012-02-05 02:38:54 +0000 | [diff] [blame] | 76 | } |
| 77 | |
Greg Clayton | efabb12 | 2010-11-05 23:17:00 +0000 | [diff] [blame] | 78 | const SBModule & |
| 79 | SBModule::operator = (const SBModule &rhs) |
| 80 | { |
| 81 | if (this != &rhs) |
| 82 | m_opaque_sp = rhs.m_opaque_sp; |
| 83 | return *this; |
| 84 | } |
| 85 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 86 | SBModule::~SBModule () |
| 87 | { |
| 88 | } |
| 89 | |
| 90 | bool |
| 91 | SBModule::IsValid () const |
| 92 | { |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 93 | return m_opaque_sp.get() != NULL; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 94 | } |
| 95 | |
Jim Ingham | 5d3bca4 | 2011-12-19 20:39:44 +0000 | [diff] [blame] | 96 | void |
| 97 | SBModule::Clear() |
| 98 | { |
| 99 | m_opaque_sp.reset(); |
| 100 | } |
| 101 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 102 | SBFileSpec |
| 103 | SBModule::GetFileSpec () const |
| 104 | { |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 105 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 106 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 107 | SBFileSpec file_spec; |
Greg Clayton | c2ff931 | 2012-02-22 19:41:02 +0000 | [diff] [blame] | 108 | ModuleSP module_sp (GetSP ()); |
| 109 | if (module_sp) |
| 110 | file_spec.SetFileSpec(module_sp->GetFileSpec()); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 111 | |
| 112 | if (log) |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 113 | log->Printf ("SBModule(%p)::GetFileSpec () => SBFileSpec(%p)", |
| 114 | static_cast<void*>(module_sp.get()), |
| 115 | static_cast<const void*>(file_spec.get())); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 116 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 117 | return file_spec; |
| 118 | } |
| 119 | |
Greg Clayton | 2289fa4 | 2011-04-30 01:09:13 +0000 | [diff] [blame] | 120 | lldb::SBFileSpec |
| 121 | SBModule::GetPlatformFileSpec () const |
| 122 | { |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 123 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 124 | |
Greg Clayton | 2289fa4 | 2011-04-30 01:09:13 +0000 | [diff] [blame] | 125 | SBFileSpec file_spec; |
Greg Clayton | c2ff931 | 2012-02-22 19:41:02 +0000 | [diff] [blame] | 126 | ModuleSP module_sp (GetSP ()); |
| 127 | if (module_sp) |
| 128 | file_spec.SetFileSpec(module_sp->GetPlatformFileSpec()); |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 129 | |
Greg Clayton | 2289fa4 | 2011-04-30 01:09:13 +0000 | [diff] [blame] | 130 | if (log) |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 131 | log->Printf ("SBModule(%p)::GetPlatformFileSpec () => SBFileSpec(%p)", |
| 132 | static_cast<void*>(module_sp.get()), |
| 133 | static_cast<const void*>(file_spec.get())); |
| 134 | |
Greg Clayton | 2289fa4 | 2011-04-30 01:09:13 +0000 | [diff] [blame] | 135 | return file_spec; |
Greg Clayton | 2289fa4 | 2011-04-30 01:09:13 +0000 | [diff] [blame] | 136 | } |
| 137 | |
| 138 | bool |
| 139 | SBModule::SetPlatformFileSpec (const lldb::SBFileSpec &platform_file) |
| 140 | { |
| 141 | bool result = false; |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 142 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 143 | |
Greg Clayton | c2ff931 | 2012-02-22 19:41:02 +0000 | [diff] [blame] | 144 | ModuleSP module_sp (GetSP ()); |
| 145 | if (module_sp) |
Greg Clayton | 2289fa4 | 2011-04-30 01:09:13 +0000 | [diff] [blame] | 146 | { |
Greg Clayton | c2ff931 | 2012-02-22 19:41:02 +0000 | [diff] [blame] | 147 | module_sp->SetPlatformFileSpec(*platform_file); |
Greg Clayton | 2289fa4 | 2011-04-30 01:09:13 +0000 | [diff] [blame] | 148 | result = true; |
| 149 | } |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 150 | |
Greg Clayton | 2289fa4 | 2011-04-30 01:09:13 +0000 | [diff] [blame] | 151 | if (log) |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 152 | log->Printf ("SBModule(%p)::SetPlatformFileSpec (SBFileSpec(%p (%s)) => %i", |
| 153 | static_cast<void*>(module_sp.get()), |
| 154 | static_cast<const void*>(platform_file.get()), |
| 155 | platform_file->GetPath().c_str(), result); |
Greg Clayton | 2289fa4 | 2011-04-30 01:09:13 +0000 | [diff] [blame] | 156 | return result; |
| 157 | } |
| 158 | |
Greg Clayton | fbb7634 | 2013-11-20 21:07:01 +0000 | [diff] [blame] | 159 | lldb::SBFileSpec |
| 160 | SBModule::GetRemoteInstallFileSpec () |
| 161 | { |
| 162 | SBFileSpec sb_file_spec; |
| 163 | ModuleSP module_sp (GetSP ()); |
| 164 | if (module_sp) |
| 165 | sb_file_spec.SetFileSpec (module_sp->GetRemoteInstallFileSpec()); |
| 166 | return sb_file_spec; |
| 167 | } |
| 168 | |
| 169 | bool |
| 170 | SBModule::SetRemoteInstallFileSpec (lldb::SBFileSpec &file) |
| 171 | { |
| 172 | ModuleSP module_sp (GetSP ()); |
| 173 | if (module_sp) |
| 174 | { |
| 175 | module_sp->SetRemoteInstallFileSpec(file.ref()); |
| 176 | return true; |
| 177 | } |
| 178 | return false; |
| 179 | } |
Greg Clayton | 2289fa4 | 2011-04-30 01:09:13 +0000 | [diff] [blame] | 180 | |
| 181 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 182 | const uint8_t * |
| 183 | SBModule::GetUUIDBytes () const |
| 184 | { |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 185 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 186 | |
Greg Clayton | 4838131 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 187 | const uint8_t *uuid_bytes = NULL; |
Greg Clayton | c2ff931 | 2012-02-22 19:41:02 +0000 | [diff] [blame] | 188 | ModuleSP module_sp (GetSP ()); |
| 189 | if (module_sp) |
| 190 | uuid_bytes = (const uint8_t *)module_sp->GetUUID().GetBytes(); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 191 | |
| 192 | if (log) |
Greg Clayton | 4838131 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 193 | { |
| 194 | if (uuid_bytes) |
| 195 | { |
| 196 | StreamString s; |
Greg Clayton | c2ff931 | 2012-02-22 19:41:02 +0000 | [diff] [blame] | 197 | module_sp->GetUUID().Dump (&s); |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 198 | log->Printf ("SBModule(%p)::GetUUIDBytes () => %s", |
| 199 | static_cast<void*>(module_sp.get()), s.GetData()); |
Greg Clayton | 4838131 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 200 | } |
| 201 | else |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 202 | log->Printf ("SBModule(%p)::GetUUIDBytes () => NULL", |
| 203 | static_cast<void*>(module_sp.get())); |
Greg Clayton | 4838131 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 204 | } |
| 205 | return uuid_bytes; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 206 | } |
| 207 | |
| 208 | |
Johnny Chen | df2963e | 2011-04-01 00:35:55 +0000 | [diff] [blame] | 209 | const char * |
| 210 | SBModule::GetUUIDString () const |
| 211 | { |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 212 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Johnny Chen | df2963e | 2011-04-01 00:35:55 +0000 | [diff] [blame] | 213 | |
Jason Molenda | c16b4af | 2013-05-03 23:56:12 +0000 | [diff] [blame] | 214 | static char uuid_string_buffer[80]; |
| 215 | const char *uuid_c_string = NULL; |
| 216 | std::string uuid_string; |
Greg Clayton | c2ff931 | 2012-02-22 19:41:02 +0000 | [diff] [blame] | 217 | ModuleSP module_sp (GetSP ()); |
| 218 | if (module_sp) |
Jason Molenda | c16b4af | 2013-05-03 23:56:12 +0000 | [diff] [blame] | 219 | uuid_string = module_sp->GetUUID().GetAsString(); |
| 220 | |
| 221 | if (!uuid_string.empty()) |
| 222 | { |
| 223 | strncpy (uuid_string_buffer, uuid_string.c_str(), sizeof (uuid_string_buffer)); |
Sylvestre Ledru | 802a353 | 2014-08-19 12:13:14 +0000 | [diff] [blame] | 224 | uuid_string_buffer[sizeof (uuid_string_buffer) - 1] = '\0'; |
Jason Molenda | c16b4af | 2013-05-03 23:56:12 +0000 | [diff] [blame] | 225 | uuid_c_string = uuid_string_buffer; |
| 226 | } |
Johnny Chen | df2963e | 2011-04-01 00:35:55 +0000 | [diff] [blame] | 227 | |
| 228 | if (log) |
| 229 | { |
Jason Molenda | c16b4af | 2013-05-03 23:56:12 +0000 | [diff] [blame] | 230 | if (!uuid_string.empty()) |
Johnny Chen | df2963e | 2011-04-01 00:35:55 +0000 | [diff] [blame] | 231 | { |
| 232 | StreamString s; |
Greg Clayton | c2ff931 | 2012-02-22 19:41:02 +0000 | [diff] [blame] | 233 | module_sp->GetUUID().Dump (&s); |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 234 | log->Printf ("SBModule(%p)::GetUUIDString () => %s", |
| 235 | static_cast<void*>(module_sp.get()), s.GetData()); |
Johnny Chen | df2963e | 2011-04-01 00:35:55 +0000 | [diff] [blame] | 236 | } |
| 237 | else |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 238 | log->Printf ("SBModule(%p)::GetUUIDString () => NULL", |
| 239 | static_cast<void*>(module_sp.get())); |
Johnny Chen | df2963e | 2011-04-01 00:35:55 +0000 | [diff] [blame] | 240 | } |
| 241 | return uuid_c_string; |
| 242 | } |
| 243 | |
| 244 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 245 | bool |
| 246 | SBModule::operator == (const SBModule &rhs) const |
| 247 | { |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 248 | if (m_opaque_sp) |
| 249 | return m_opaque_sp.get() == rhs.m_opaque_sp.get(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 250 | return false; |
| 251 | } |
| 252 | |
| 253 | bool |
| 254 | SBModule::operator != (const SBModule &rhs) const |
| 255 | { |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 256 | if (m_opaque_sp) |
| 257 | return m_opaque_sp.get() != rhs.m_opaque_sp.get(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 258 | return false; |
| 259 | } |
| 260 | |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 261 | ModuleSP |
| 262 | SBModule::GetSP () const |
Greg Clayton | cac9c5f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 263 | { |
| 264 | return m_opaque_sp; |
| 265 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 266 | |
| 267 | void |
Greg Clayton | acdbe81 | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 268 | SBModule::SetSP (const ModuleSP &module_sp) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 269 | { |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 270 | m_opaque_sp = module_sp; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 271 | } |
| 272 | |
Greg Clayton | cac9c5f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 273 | SBAddress |
| 274 | SBModule::ResolveFileAddress (lldb::addr_t vm_addr) |
Greg Clayton | 0996003 | 2010-09-10 18:31:35 +0000 | [diff] [blame] | 275 | { |
Greg Clayton | cac9c5f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 276 | lldb::SBAddress sb_addr; |
Greg Clayton | c2ff931 | 2012-02-22 19:41:02 +0000 | [diff] [blame] | 277 | ModuleSP module_sp (GetSP ()); |
| 278 | if (module_sp) |
Greg Clayton | cac9c5f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 279 | { |
| 280 | Address addr; |
Greg Clayton | c2ff931 | 2012-02-22 19:41:02 +0000 | [diff] [blame] | 281 | if (module_sp->ResolveFileAddress (vm_addr, addr)) |
Greg Clayton | cac9c5f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 282 | sb_addr.ref() = addr; |
| 283 | } |
| 284 | return sb_addr; |
Greg Clayton | 0996003 | 2010-09-10 18:31:35 +0000 | [diff] [blame] | 285 | } |
| 286 | |
| 287 | SBSymbolContext |
| 288 | SBModule::ResolveSymbolContextForAddress (const SBAddress& addr, uint32_t resolve_scope) |
| 289 | { |
| 290 | SBSymbolContext sb_sc; |
Greg Clayton | c2ff931 | 2012-02-22 19:41:02 +0000 | [diff] [blame] | 291 | ModuleSP module_sp (GetSP ()); |
| 292 | if (module_sp && addr.IsValid()) |
| 293 | module_sp->ResolveSymbolContextForAddress (addr.ref(), resolve_scope, *sb_sc); |
Greg Clayton | 0996003 | 2010-09-10 18:31:35 +0000 | [diff] [blame] | 294 | return sb_sc; |
| 295 | } |
| 296 | |
Caroline Tice | dde9cff | 2010-09-20 05:20:02 +0000 | [diff] [blame] | 297 | bool |
| 298 | SBModule::GetDescription (SBStream &description) |
| 299 | { |
Greg Clayton | da7bc7d | 2011-11-13 06:57:31 +0000 | [diff] [blame] | 300 | Stream &strm = description.ref(); |
| 301 | |
Greg Clayton | c2ff931 | 2012-02-22 19:41:02 +0000 | [diff] [blame] | 302 | ModuleSP module_sp (GetSP ()); |
| 303 | if (module_sp) |
Caroline Tice | dde9cff | 2010-09-20 05:20:02 +0000 | [diff] [blame] | 304 | { |
Greg Clayton | c2ff931 | 2012-02-22 19:41:02 +0000 | [diff] [blame] | 305 | module_sp->GetDescription (&strm); |
Caroline Tice | dde9cff | 2010-09-20 05:20:02 +0000 | [diff] [blame] | 306 | } |
| 307 | else |
Greg Clayton | da7bc7d | 2011-11-13 06:57:31 +0000 | [diff] [blame] | 308 | strm.PutCString ("No value"); |
Caroline Tice | dde9cff | 2010-09-20 05:20:02 +0000 | [diff] [blame] | 309 | |
| 310 | return true; |
| 311 | } |
Greg Clayton | bbdabce | 2010-12-07 05:40:31 +0000 | [diff] [blame] | 312 | |
Johnny Chen | 873a7a4 | 2012-03-16 20:46:10 +0000 | [diff] [blame] | 313 | uint32_t |
| 314 | SBModule::GetNumCompileUnits() |
| 315 | { |
| 316 | ModuleSP module_sp (GetSP ()); |
| 317 | if (module_sp) |
| 318 | { |
| 319 | return module_sp->GetNumCompileUnits (); |
| 320 | } |
| 321 | return 0; |
| 322 | } |
| 323 | |
| 324 | SBCompileUnit |
| 325 | SBModule::GetCompileUnitAtIndex (uint32_t index) |
| 326 | { |
| 327 | SBCompileUnit sb_cu; |
| 328 | ModuleSP module_sp (GetSP ()); |
| 329 | if (module_sp) |
| 330 | { |
| 331 | CompUnitSP cu_sp = module_sp->GetCompileUnitAtIndex (index); |
| 332 | sb_cu.reset(cu_sp.get()); |
| 333 | } |
| 334 | return sb_cu; |
| 335 | } |
| 336 | |
Michael Sartain | a7499c9 | 2013-07-01 19:45:50 +0000 | [diff] [blame] | 337 | static Symtab * |
| 338 | GetUnifiedSymbolTable (const lldb::ModuleSP& module_sp) |
| 339 | { |
| 340 | if (module_sp) |
| 341 | { |
| 342 | SymbolVendor *symbols = module_sp->GetSymbolVendor(); |
| 343 | if (symbols) |
| 344 | return symbols->GetSymtab(); |
| 345 | } |
| 346 | return NULL; |
| 347 | } |
| 348 | |
Greg Clayton | bbdabce | 2010-12-07 05:40:31 +0000 | [diff] [blame] | 349 | size_t |
| 350 | SBModule::GetNumSymbols () |
| 351 | { |
Greg Clayton | c2ff931 | 2012-02-22 19:41:02 +0000 | [diff] [blame] | 352 | ModuleSP module_sp (GetSP ()); |
| 353 | if (module_sp) |
Greg Clayton | bbdabce | 2010-12-07 05:40:31 +0000 | [diff] [blame] | 354 | { |
Michael Sartain | a7499c9 | 2013-07-01 19:45:50 +0000 | [diff] [blame] | 355 | Symtab *symtab = GetUnifiedSymbolTable (module_sp); |
| 356 | if (symtab) |
| 357 | return symtab->GetNumSymbols(); |
Greg Clayton | bbdabce | 2010-12-07 05:40:31 +0000 | [diff] [blame] | 358 | } |
| 359 | return 0; |
| 360 | } |
| 361 | |
| 362 | SBSymbol |
| 363 | SBModule::GetSymbolAtIndex (size_t idx) |
| 364 | { |
| 365 | SBSymbol sb_symbol; |
Greg Clayton | c2ff931 | 2012-02-22 19:41:02 +0000 | [diff] [blame] | 366 | ModuleSP module_sp (GetSP ()); |
Michael Sartain | a7499c9 | 2013-07-01 19:45:50 +0000 | [diff] [blame] | 367 | Symtab *symtab = GetUnifiedSymbolTable (module_sp); |
| 368 | if (symtab) |
| 369 | sb_symbol.SetSymbol(symtab->SymbolAtIndex (idx)); |
Greg Clayton | bbdabce | 2010-12-07 05:40:31 +0000 | [diff] [blame] | 370 | return sb_symbol; |
| 371 | } |
Greg Clayton | fe356d3 | 2011-06-21 01:34:41 +0000 | [diff] [blame] | 372 | |
Greg Clayton | e14e192 | 2012-12-04 02:22:16 +0000 | [diff] [blame] | 373 | lldb::SBSymbol |
| 374 | SBModule::FindSymbol (const char *name, |
| 375 | lldb::SymbolType symbol_type) |
| 376 | { |
| 377 | SBSymbol sb_symbol; |
| 378 | if (name && name[0]) |
| 379 | { |
| 380 | ModuleSP module_sp (GetSP ()); |
Michael Sartain | a7499c9 | 2013-07-01 19:45:50 +0000 | [diff] [blame] | 381 | Symtab *symtab = GetUnifiedSymbolTable (module_sp); |
| 382 | if (symtab) |
| 383 | sb_symbol.SetSymbol(symtab->FindFirstSymbolWithNameAndType(ConstString(name), symbol_type, Symtab::eDebugAny, Symtab::eVisibilityAny)); |
Greg Clayton | e14e192 | 2012-12-04 02:22:16 +0000 | [diff] [blame] | 384 | } |
| 385 | return sb_symbol; |
| 386 | } |
| 387 | |
| 388 | |
| 389 | lldb::SBSymbolContextList |
| 390 | SBModule::FindSymbols (const char *name, lldb::SymbolType symbol_type) |
| 391 | { |
| 392 | SBSymbolContextList sb_sc_list; |
| 393 | if (name && name[0]) |
| 394 | { |
| 395 | ModuleSP module_sp (GetSP ()); |
Michael Sartain | a7499c9 | 2013-07-01 19:45:50 +0000 | [diff] [blame] | 396 | Symtab *symtab = GetUnifiedSymbolTable (module_sp); |
| 397 | if (symtab) |
Greg Clayton | e14e192 | 2012-12-04 02:22:16 +0000 | [diff] [blame] | 398 | { |
Michael Sartain | a7499c9 | 2013-07-01 19:45:50 +0000 | [diff] [blame] | 399 | std::vector<uint32_t> matching_symbol_indexes; |
| 400 | const size_t num_matches = symtab->FindAllSymbolsWithNameAndType(ConstString(name), symbol_type, matching_symbol_indexes); |
| 401 | if (num_matches) |
Greg Clayton | e14e192 | 2012-12-04 02:22:16 +0000 | [diff] [blame] | 402 | { |
Michael Sartain | a7499c9 | 2013-07-01 19:45:50 +0000 | [diff] [blame] | 403 | SymbolContext sc; |
| 404 | sc.module_sp = module_sp; |
| 405 | SymbolContextList &sc_list = *sb_sc_list; |
| 406 | for (size_t i=0; i<num_matches; ++i) |
Greg Clayton | e14e192 | 2012-12-04 02:22:16 +0000 | [diff] [blame] | 407 | { |
Michael Sartain | a7499c9 | 2013-07-01 19:45:50 +0000 | [diff] [blame] | 408 | sc.symbol = symtab->SymbolAtIndex (matching_symbol_indexes[i]); |
| 409 | if (sc.symbol) |
| 410 | sc_list.Append(sc); |
Greg Clayton | e14e192 | 2012-12-04 02:22:16 +0000 | [diff] [blame] | 411 | } |
| 412 | } |
| 413 | } |
| 414 | } |
| 415 | return sb_sc_list; |
| 416 | |
| 417 | } |
| 418 | |
| 419 | |
| 420 | |
Greg Clayton | cac9c5f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 421 | size_t |
| 422 | SBModule::GetNumSections () |
| 423 | { |
Greg Clayton | c2ff931 | 2012-02-22 19:41:02 +0000 | [diff] [blame] | 424 | ModuleSP module_sp (GetSP ()); |
| 425 | if (module_sp) |
Greg Clayton | cac9c5f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 426 | { |
Michael Sartain | a7499c9 | 2013-07-01 19:45:50 +0000 | [diff] [blame] | 427 | // Give the symbol vendor a chance to add to the unified section list. |
| 428 | module_sp->GetSymbolVendor(); |
Greg Clayton | 3046e66 | 2013-07-10 01:23:25 +0000 | [diff] [blame] | 429 | SectionList *section_list = module_sp->GetSectionList(); |
Michael Sartain | a7499c9 | 2013-07-01 19:45:50 +0000 | [diff] [blame] | 430 | if (section_list) |
| 431 | return section_list->GetSize(); |
Greg Clayton | cac9c5f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 432 | } |
| 433 | return 0; |
| 434 | } |
| 435 | |
| 436 | SBSection |
| 437 | SBModule::GetSectionAtIndex (size_t idx) |
| 438 | { |
| 439 | SBSection sb_section; |
Greg Clayton | c2ff931 | 2012-02-22 19:41:02 +0000 | [diff] [blame] | 440 | ModuleSP module_sp (GetSP ()); |
| 441 | if (module_sp) |
Greg Clayton | cac9c5f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 442 | { |
Michael Sartain | a7499c9 | 2013-07-01 19:45:50 +0000 | [diff] [blame] | 443 | // Give the symbol vendor a chance to add to the unified section list. |
| 444 | module_sp->GetSymbolVendor(); |
Greg Clayton | 3046e66 | 2013-07-10 01:23:25 +0000 | [diff] [blame] | 445 | SectionList *section_list = module_sp->GetSectionList (); |
Greg Clayton | cac9c5f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 446 | |
Michael Sartain | a7499c9 | 2013-07-01 19:45:50 +0000 | [diff] [blame] | 447 | if (section_list) |
| 448 | sb_section.SetSP(section_list->GetSectionAtIndex (idx)); |
Greg Clayton | cac9c5f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 449 | } |
| 450 | return sb_section; |
| 451 | } |
| 452 | |
Greg Clayton | 5569e64 | 2012-02-06 01:44:54 +0000 | [diff] [blame] | 453 | lldb::SBSymbolContextList |
Greg Clayton | fe356d3 | 2011-06-21 01:34:41 +0000 | [diff] [blame] | 454 | SBModule::FindFunctions (const char *name, |
Greg Clayton | 5569e64 | 2012-02-06 01:44:54 +0000 | [diff] [blame] | 455 | uint32_t name_type_mask) |
Greg Clayton | fe356d3 | 2011-06-21 01:34:41 +0000 | [diff] [blame] | 456 | { |
Greg Clayton | 5569e64 | 2012-02-06 01:44:54 +0000 | [diff] [blame] | 457 | lldb::SBSymbolContextList sb_sc_list; |
Greg Clayton | c2ff931 | 2012-02-22 19:41:02 +0000 | [diff] [blame] | 458 | ModuleSP module_sp (GetSP ()); |
| 459 | if (name && module_sp) |
Greg Clayton | fe356d3 | 2011-06-21 01:34:41 +0000 | [diff] [blame] | 460 | { |
Greg Clayton | 5569e64 | 2012-02-06 01:44:54 +0000 | [diff] [blame] | 461 | const bool append = true; |
Greg Clayton | fe356d3 | 2011-06-21 01:34:41 +0000 | [diff] [blame] | 462 | const bool symbols_ok = true; |
Sean Callanan | 9df05fb | 2012-02-10 22:52:19 +0000 | [diff] [blame] | 463 | const bool inlines_ok = true; |
Greg Clayton | c2ff931 | 2012-02-22 19:41:02 +0000 | [diff] [blame] | 464 | module_sp->FindFunctions (ConstString(name), |
| 465 | NULL, |
| 466 | name_type_mask, |
| 467 | symbols_ok, |
| 468 | inlines_ok, |
| 469 | append, |
| 470 | *sb_sc_list); |
Greg Clayton | fe356d3 | 2011-06-21 01:34:41 +0000 | [diff] [blame] | 471 | } |
Greg Clayton | 5569e64 | 2012-02-06 01:44:54 +0000 | [diff] [blame] | 472 | return sb_sc_list; |
Greg Clayton | fe356d3 | 2011-06-21 01:34:41 +0000 | [diff] [blame] | 473 | } |
| 474 | |
Greg Clayton | dea8cb4 | 2011-06-29 22:09:02 +0000 | [diff] [blame] | 475 | |
| 476 | SBValueList |
| 477 | SBModule::FindGlobalVariables (SBTarget &target, const char *name, uint32_t max_matches) |
| 478 | { |
| 479 | SBValueList sb_value_list; |
Greg Clayton | c2ff931 | 2012-02-22 19:41:02 +0000 | [diff] [blame] | 480 | ModuleSP module_sp (GetSP ()); |
| 481 | if (name && module_sp) |
Greg Clayton | dea8cb4 | 2011-06-29 22:09:02 +0000 | [diff] [blame] | 482 | { |
| 483 | VariableList variable_list; |
Greg Clayton | c2ff931 | 2012-02-22 19:41:02 +0000 | [diff] [blame] | 484 | const uint32_t match_count = module_sp->FindGlobalVariables (ConstString (name), |
| 485 | NULL, |
| 486 | false, |
| 487 | max_matches, |
| 488 | variable_list); |
Greg Clayton | dea8cb4 | 2011-06-29 22:09:02 +0000 | [diff] [blame] | 489 | |
| 490 | if (match_count > 0) |
| 491 | { |
Greg Clayton | dea8cb4 | 2011-06-29 22:09:02 +0000 | [diff] [blame] | 492 | for (uint32_t i=0; i<match_count; ++i) |
| 493 | { |
| 494 | lldb::ValueObjectSP valobj_sp; |
Greg Clayton | b9556ac | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 495 | TargetSP target_sp (target.GetSP()); |
| 496 | valobj_sp = ValueObjectVariable::Create (target_sp.get(), variable_list.GetVariableAtIndex(i)); |
Greg Clayton | dea8cb4 | 2011-06-29 22:09:02 +0000 | [diff] [blame] | 497 | if (valobj_sp) |
Enrico Granata | 85425d7 | 2013-02-07 18:23:56 +0000 | [diff] [blame] | 498 | sb_value_list.Append(SBValue(valobj_sp)); |
Greg Clayton | dea8cb4 | 2011-06-29 22:09:02 +0000 | [diff] [blame] | 499 | } |
| 500 | } |
| 501 | } |
| 502 | |
| 503 | return sb_value_list; |
| 504 | } |
Enrico Granata | 6f3533f | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 505 | |
Enrico Granata | bcd80b4 | 2013-01-16 18:53:52 +0000 | [diff] [blame] | 506 | lldb::SBValue |
| 507 | SBModule::FindFirstGlobalVariable (lldb::SBTarget &target, const char *name) |
| 508 | { |
| 509 | SBValueList sb_value_list(FindGlobalVariables(target, name, 1)); |
| 510 | if (sb_value_list.IsValid() && sb_value_list.GetSize() > 0) |
| 511 | return sb_value_list.GetValueAtIndex(0); |
| 512 | return SBValue(); |
| 513 | } |
| 514 | |
Enrico Granata | 6f3533f | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 515 | lldb::SBType |
Johnny Chen | 4efffd9 | 2011-12-19 20:16:22 +0000 | [diff] [blame] | 516 | SBModule::FindFirstType (const char *name_cstr) |
Enrico Granata | 6f3533f | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 517 | { |
Greg Clayton | fe42ac4 | 2011-08-03 22:57:10 +0000 | [diff] [blame] | 518 | SBType sb_type; |
Greg Clayton | c2ff931 | 2012-02-22 19:41:02 +0000 | [diff] [blame] | 519 | ModuleSP module_sp (GetSP ()); |
| 520 | if (name_cstr && module_sp) |
Enrico Granata | 6f3533f | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 521 | { |
Greg Clayton | fe42ac4 | 2011-08-03 22:57:10 +0000 | [diff] [blame] | 522 | SymbolContext sc; |
Greg Clayton | 84db910 | 2012-03-26 23:03:23 +0000 | [diff] [blame] | 523 | const bool exact_match = false; |
Greg Clayton | fe42ac4 | 2011-08-03 22:57:10 +0000 | [diff] [blame] | 524 | ConstString name(name_cstr); |
| 525 | |
Greg Clayton | b43165b | 2012-12-05 21:24:42 +0000 | [diff] [blame] | 526 | sb_type = SBType (module_sp->FindFirstType(sc, name, exact_match)); |
Greg Clayton | fe42ac4 | 2011-08-03 22:57:10 +0000 | [diff] [blame] | 527 | |
Greg Clayton | b43165b | 2012-12-05 21:24:42 +0000 | [diff] [blame] | 528 | if (!sb_type.IsValid()) |
Greg Clayton | 57ee306 | 2013-07-11 22:46:58 +0000 | [diff] [blame] | 529 | sb_type = SBType (ClangASTContext::GetBasicType (module_sp->GetClangASTContext().getASTContext(), name)); |
Enrico Granata | 6f3533f | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 530 | } |
Greg Clayton | fe42ac4 | 2011-08-03 22:57:10 +0000 | [diff] [blame] | 531 | return sb_type; |
Enrico Granata | 6f3533f | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 532 | } |
| 533 | |
Greg Clayton | b43165b | 2012-12-05 21:24:42 +0000 | [diff] [blame] | 534 | lldb::SBType |
| 535 | SBModule::GetBasicType(lldb::BasicType type) |
| 536 | { |
| 537 | ModuleSP module_sp (GetSP ()); |
| 538 | if (module_sp) |
Greg Clayton | 57ee306 | 2013-07-11 22:46:58 +0000 | [diff] [blame] | 539 | return SBType (ClangASTContext::GetBasicType (module_sp->GetClangASTContext().getASTContext(), type)); |
Greg Clayton | b43165b | 2012-12-05 21:24:42 +0000 | [diff] [blame] | 540 | return SBType(); |
| 541 | } |
| 542 | |
Enrico Granata | 6f3533f | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 543 | lldb::SBTypeList |
Johnny Chen | 4efffd9 | 2011-12-19 20:16:22 +0000 | [diff] [blame] | 544 | SBModule::FindTypes (const char *type) |
Enrico Granata | 6f3533f | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 545 | { |
Enrico Granata | 6f3533f | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 546 | SBTypeList retval; |
| 547 | |
Greg Clayton | c2ff931 | 2012-02-22 19:41:02 +0000 | [diff] [blame] | 548 | ModuleSP module_sp (GetSP ()); |
| 549 | if (type && module_sp) |
Enrico Granata | 6f3533f | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 550 | { |
Greg Clayton | fe42ac4 | 2011-08-03 22:57:10 +0000 | [diff] [blame] | 551 | SymbolContext sc; |
| 552 | TypeList type_list; |
Greg Clayton | 84db910 | 2012-03-26 23:03:23 +0000 | [diff] [blame] | 553 | const bool exact_match = false; |
Greg Clayton | fe42ac4 | 2011-08-03 22:57:10 +0000 | [diff] [blame] | 554 | ConstString name(type); |
Greg Clayton | b43165b | 2012-12-05 21:24:42 +0000 | [diff] [blame] | 555 | const uint32_t num_matches = module_sp->FindTypes (sc, |
| 556 | name, |
| 557 | exact_match, |
| 558 | UINT32_MAX, |
| 559 | type_list); |
Enrico Granata | 6f3533f | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 560 | |
Greg Clayton | b43165b | 2012-12-05 21:24:42 +0000 | [diff] [blame] | 561 | if (num_matches > 0) |
Greg Clayton | fe42ac4 | 2011-08-03 22:57:10 +0000 | [diff] [blame] | 562 | { |
Greg Clayton | b43165b | 2012-12-05 21:24:42 +0000 | [diff] [blame] | 563 | for (size_t idx = 0; idx < num_matches; idx++) |
| 564 | { |
| 565 | TypeSP type_sp (type_list.GetTypeAtIndex(idx)); |
| 566 | if (type_sp) |
| 567 | retval.Append(SBType(type_sp)); |
| 568 | } |
| 569 | } |
| 570 | else |
| 571 | { |
Greg Clayton | 57ee306 | 2013-07-11 22:46:58 +0000 | [diff] [blame] | 572 | SBType sb_type(ClangASTContext::GetBasicType (module_sp->GetClangASTContext().getASTContext(), name)); |
Greg Clayton | b43165b | 2012-12-05 21:24:42 +0000 | [diff] [blame] | 573 | if (sb_type.IsValid()) |
| 574 | retval.Append(sb_type); |
Greg Clayton | fe42ac4 | 2011-08-03 22:57:10 +0000 | [diff] [blame] | 575 | } |
Enrico Granata | 6f3533f | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 576 | } |
| 577 | |
| 578 | return retval; |
Greg Clayton | 3418c85 | 2011-08-10 02:10:13 +0000 | [diff] [blame] | 579 | } |
Greg Clayton | cac9c5f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 580 | |
Greg Clayton | 1f4db7d | 2014-01-23 21:38:34 +0000 | [diff] [blame] | 581 | lldb::SBType |
| 582 | SBModule::GetTypeByID (lldb::user_id_t uid) |
| 583 | { |
| 584 | ModuleSP module_sp (GetSP ()); |
| 585 | if (module_sp) |
| 586 | { |
| 587 | SymbolVendor* vendor = module_sp->GetSymbolVendor(); |
| 588 | if (vendor) |
| 589 | { |
| 590 | Type *type_ptr = vendor->ResolveTypeUID(uid); |
| 591 | if (type_ptr) |
| 592 | return SBType(type_ptr->shared_from_this()); |
| 593 | } |
| 594 | } |
| 595 | return SBType(); |
| 596 | } |
| 597 | |
Greg Clayton | f02500c | 2013-06-18 22:51:05 +0000 | [diff] [blame] | 598 | lldb::SBTypeList |
| 599 | SBModule::GetTypes (uint32_t type_mask) |
| 600 | { |
| 601 | SBTypeList sb_type_list; |
| 602 | |
| 603 | ModuleSP module_sp (GetSP ()); |
| 604 | if (module_sp) |
| 605 | { |
| 606 | SymbolVendor* vendor = module_sp->GetSymbolVendor(); |
| 607 | if (vendor) |
| 608 | { |
| 609 | TypeList type_list; |
| 610 | vendor->GetTypes (NULL, type_mask, type_list); |
| 611 | sb_type_list.m_opaque_ap->Append(type_list); |
| 612 | } |
| 613 | } |
| 614 | return sb_type_list; |
| 615 | } |
Greg Clayton | cac9c5f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 616 | |
| 617 | SBSection |
| 618 | SBModule::FindSection (const char *sect_name) |
| 619 | { |
| 620 | SBSection sb_section; |
| 621 | |
Greg Clayton | c2ff931 | 2012-02-22 19:41:02 +0000 | [diff] [blame] | 622 | ModuleSP module_sp (GetSP ()); |
| 623 | if (sect_name && module_sp) |
Greg Clayton | cac9c5f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 624 | { |
Michael Sartain | a7499c9 | 2013-07-01 19:45:50 +0000 | [diff] [blame] | 625 | // Give the symbol vendor a chance to add to the unified section list. |
| 626 | module_sp->GetSymbolVendor(); |
Greg Clayton | 3046e66 | 2013-07-10 01:23:25 +0000 | [diff] [blame] | 627 | SectionList *section_list = module_sp->GetSectionList(); |
Michael Sartain | a7499c9 | 2013-07-01 19:45:50 +0000 | [diff] [blame] | 628 | if (section_list) |
Greg Clayton | cac9c5f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 629 | { |
Michael Sartain | a7499c9 | 2013-07-01 19:45:50 +0000 | [diff] [blame] | 630 | ConstString const_sect_name(sect_name); |
| 631 | SectionSP section_sp (section_list->FindSectionByName(const_sect_name)); |
| 632 | if (section_sp) |
Greg Clayton | cac9c5f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 633 | { |
Michael Sartain | a7499c9 | 2013-07-01 19:45:50 +0000 | [diff] [blame] | 634 | sb_section.SetSP (section_sp); |
Greg Clayton | cac9c5f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 635 | } |
| 636 | } |
| 637 | } |
| 638 | return sb_section; |
| 639 | } |
| 640 | |
Greg Clayton | 13d1950 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 641 | lldb::ByteOrder |
| 642 | SBModule::GetByteOrder () |
| 643 | { |
Greg Clayton | c2ff931 | 2012-02-22 19:41:02 +0000 | [diff] [blame] | 644 | ModuleSP module_sp (GetSP ()); |
| 645 | if (module_sp) |
| 646 | return module_sp->GetArchitecture().GetByteOrder(); |
Greg Clayton | 13d1950 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 647 | return eByteOrderInvalid; |
| 648 | } |
| 649 | |
| 650 | const char * |
| 651 | SBModule::GetTriple () |
| 652 | { |
Greg Clayton | c2ff931 | 2012-02-22 19:41:02 +0000 | [diff] [blame] | 653 | ModuleSP module_sp (GetSP ()); |
| 654 | if (module_sp) |
Greg Clayton | 13d1950 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 655 | { |
Greg Clayton | c2ff931 | 2012-02-22 19:41:02 +0000 | [diff] [blame] | 656 | std::string triple (module_sp->GetArchitecture().GetTriple().str()); |
Greg Clayton | 13d1950 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 657 | // Unique the string so we don't run into ownership issues since |
| 658 | // the const strings put the string into the string pool once and |
| 659 | // the strings never comes out |
| 660 | ConstString const_triple (triple.c_str()); |
| 661 | return const_triple.GetCString(); |
| 662 | } |
| 663 | return NULL; |
| 664 | } |
| 665 | |
| 666 | uint32_t |
| 667 | SBModule::GetAddressByteSize() |
| 668 | { |
Greg Clayton | c2ff931 | 2012-02-22 19:41:02 +0000 | [diff] [blame] | 669 | ModuleSP module_sp (GetSP ()); |
| 670 | if (module_sp) |
| 671 | return module_sp->GetArchitecture().GetAddressByteSize(); |
Greg Clayton | 13d1950 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 672 | return sizeof(void*); |
| 673 | } |
| 674 | |
Greg Clayton | c2ff931 | 2012-02-22 19:41:02 +0000 | [diff] [blame] | 675 | |
| 676 | uint32_t |
| 677 | SBModule::GetVersion (uint32_t *versions, uint32_t num_versions) |
| 678 | { |
| 679 | ModuleSP module_sp (GetSP ()); |
| 680 | if (module_sp) |
Enrico Granata | 3467d80 | 2012-09-04 18:47:54 +0000 | [diff] [blame] | 681 | return module_sp->GetVersion(versions, num_versions); |
| 682 | else |
Greg Clayton | c2ff931 | 2012-02-22 19:41:02 +0000 | [diff] [blame] | 683 | { |
Enrico Granata | 3467d80 | 2012-09-04 18:47:54 +0000 | [diff] [blame] | 684 | if (versions && num_versions) |
| 685 | { |
| 686 | for (uint32_t i=0; i<num_versions; ++i) |
| 687 | versions[i] = UINT32_MAX; |
| 688 | } |
| 689 | return 0; |
Greg Clayton | c2ff931 | 2012-02-22 19:41:02 +0000 | [diff] [blame] | 690 | } |
Greg Clayton | c2ff931 | 2012-02-22 19:41:02 +0000 | [diff] [blame] | 691 | } |
| 692 | |