Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1 | //===-- SBTarget.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 | |
Eli Friedman | 7a62c8b | 2010-06-09 07:44:37 +0000 | [diff] [blame] | 10 | #include "lldb/API/SBTarget.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 11 | |
Greg Clayton | b344843 | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 12 | #include "lldb/lldb-public.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 13 | |
Greg Clayton | 917c000 | 2011-06-29 22:09:02 +0000 | [diff] [blame] | 14 | #include "lldb/API/SBDebugger.h" |
| 15 | #include "lldb/API/SBBreakpoint.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 16 | #include "lldb/API/SBFileSpec.h" |
Greg Clayton | 917c000 | 2011-06-29 22:09:02 +0000 | [diff] [blame] | 17 | #include "lldb/API/SBListener.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 18 | #include "lldb/API/SBModule.h" |
Jim Ingham | cc63746 | 2011-09-13 00:29:56 +0000 | [diff] [blame] | 19 | #include "lldb/API/SBSourceManager.h" |
Greg Clayton | 917c000 | 2011-06-29 22:09:02 +0000 | [diff] [blame] | 20 | #include "lldb/API/SBProcess.h" |
Caroline Tice | 98f930f | 2010-09-20 05:20:02 +0000 | [diff] [blame] | 21 | #include "lldb/API/SBStream.h" |
Greg Clayton | 4ed315f | 2011-06-21 01:34:41 +0000 | [diff] [blame] | 22 | #include "lldb/API/SBSymbolContextList.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 23 | #include "lldb/Breakpoint/BreakpointID.h" |
| 24 | #include "lldb/Breakpoint/BreakpointIDList.h" |
| 25 | #include "lldb/Breakpoint/BreakpointList.h" |
| 26 | #include "lldb/Breakpoint/BreakpointLocation.h" |
| 27 | #include "lldb/Core/Address.h" |
| 28 | #include "lldb/Core/AddressResolver.h" |
| 29 | #include "lldb/Core/AddressResolverName.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 30 | #include "lldb/Core/ArchSpec.h" |
| 31 | #include "lldb/Core/Debugger.h" |
| 32 | #include "lldb/Core/Disassembler.h" |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 33 | #include "lldb/Core/Log.h" |
Greg Clayton | 49ce896 | 2012-08-29 21:13:06 +0000 | [diff] [blame] | 34 | #include "lldb/Core/Module.h" |
| 35 | #include "lldb/Core/ModuleSpec.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 36 | #include "lldb/Core/RegularExpression.h" |
| 37 | #include "lldb/Core/SearchFilter.h" |
Greg Clayton | 49ce896 | 2012-08-29 21:13:06 +0000 | [diff] [blame] | 38 | #include "lldb/Core/Section.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 39 | #include "lldb/Core/STLUtils.h" |
Greg Clayton | 917c000 | 2011-06-29 22:09:02 +0000 | [diff] [blame] | 40 | #include "lldb/Core/ValueObjectList.h" |
| 41 | #include "lldb/Core/ValueObjectVariable.h" |
| 42 | #include "lldb/Host/FileSpec.h" |
Greg Clayton | cd54803 | 2011-02-01 01:31:41 +0000 | [diff] [blame] | 43 | #include "lldb/Host/Host.h" |
Greg Clayton | 917c000 | 2011-06-29 22:09:02 +0000 | [diff] [blame] | 44 | #include "lldb/Interpreter/Args.h" |
Greg Clayton | 49ce896 | 2012-08-29 21:13:06 +0000 | [diff] [blame] | 45 | #include "lldb/Symbol/ObjectFile.h" |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 46 | #include "lldb/Symbol/SymbolVendor.h" |
Greg Clayton | 917c000 | 2011-06-29 22:09:02 +0000 | [diff] [blame] | 47 | #include "lldb/Symbol/VariableList.h" |
Jim Ingham | 4722b10 | 2012-03-06 00:37:27 +0000 | [diff] [blame] | 48 | #include "lldb/Target/LanguageRuntime.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 49 | #include "lldb/Target/Process.h" |
| 50 | #include "lldb/Target/Target.h" |
| 51 | #include "lldb/Target/TargetList.h" |
| 52 | |
| 53 | #include "lldb/Interpreter/CommandReturnObject.h" |
| 54 | #include "../source/Commands/CommandObjectBreakpoint.h" |
| 55 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 56 | |
| 57 | using namespace lldb; |
| 58 | using namespace lldb_private; |
| 59 | |
| 60 | #define DEFAULT_DISASM_BYTE_SIZE 32 |
| 61 | |
Greg Clayton | 98ca1e6 | 2012-02-24 20:59:25 +0000 | [diff] [blame] | 62 | SBLaunchInfo::SBLaunchInfo (const char **argv) : |
| 63 | m_opaque_sp(new ProcessLaunchInfo()) |
Greg Clayton | 0a8dcac | 2012-02-24 05:03:03 +0000 | [diff] [blame] | 64 | { |
Greg Clayton | 98ca1e6 | 2012-02-24 20:59:25 +0000 | [diff] [blame] | 65 | m_opaque_sp->GetFlags().Reset (eLaunchFlagDebug | eLaunchFlagDisableASLR); |
| 66 | if (argv && argv[0]) |
| 67 | m_opaque_sp->GetArguments().SetArguments(argv); |
Greg Clayton | 0a8dcac | 2012-02-24 05:03:03 +0000 | [diff] [blame] | 68 | } |
| 69 | |
Greg Clayton | 66c2e19 | 2012-03-07 23:52:51 +0000 | [diff] [blame] | 70 | SBLaunchInfo::~SBLaunchInfo() |
| 71 | { |
| 72 | } |
| 73 | |
| 74 | lldb_private::ProcessLaunchInfo & |
| 75 | SBLaunchInfo::ref () |
| 76 | { |
| 77 | return *m_opaque_sp; |
| 78 | } |
| 79 | |
| 80 | |
Greg Clayton | 0a8dcac | 2012-02-24 05:03:03 +0000 | [diff] [blame] | 81 | uint32_t |
| 82 | SBLaunchInfo::GetUserID() |
| 83 | { |
| 84 | return m_opaque_sp->GetUserID(); |
| 85 | } |
| 86 | |
| 87 | uint32_t |
| 88 | SBLaunchInfo::GetGroupID() |
| 89 | { |
| 90 | return m_opaque_sp->GetGroupID(); |
| 91 | } |
| 92 | |
| 93 | bool |
| 94 | SBLaunchInfo::UserIDIsValid () |
| 95 | { |
| 96 | return m_opaque_sp->UserIDIsValid(); |
| 97 | } |
| 98 | |
| 99 | bool |
| 100 | SBLaunchInfo::GroupIDIsValid () |
| 101 | { |
| 102 | return m_opaque_sp->GroupIDIsValid(); |
| 103 | } |
| 104 | |
| 105 | void |
| 106 | SBLaunchInfo::SetUserID (uint32_t uid) |
| 107 | { |
| 108 | m_opaque_sp->SetUserID (uid); |
| 109 | } |
| 110 | |
| 111 | void |
| 112 | SBLaunchInfo::SetGroupID (uint32_t gid) |
| 113 | { |
| 114 | m_opaque_sp->SetGroupID (gid); |
| 115 | } |
| 116 | |
Greg Clayton | 0a8dcac | 2012-02-24 05:03:03 +0000 | [diff] [blame] | 117 | uint32_t |
| 118 | SBLaunchInfo::GetNumArguments () |
| 119 | { |
| 120 | return m_opaque_sp->GetArguments().GetArgumentCount(); |
| 121 | } |
| 122 | |
| 123 | const char * |
| 124 | SBLaunchInfo::GetArgumentAtIndex (uint32_t idx) |
| 125 | { |
| 126 | return m_opaque_sp->GetArguments().GetArgumentAtIndex(idx); |
| 127 | } |
| 128 | |
| 129 | void |
| 130 | SBLaunchInfo::SetArguments (const char **argv, bool append) |
| 131 | { |
| 132 | if (append) |
| 133 | { |
| 134 | if (argv) |
| 135 | m_opaque_sp->GetArguments().AppendArguments(argv); |
| 136 | } |
| 137 | else |
| 138 | { |
| 139 | if (argv) |
| 140 | m_opaque_sp->GetArguments().SetArguments(argv); |
| 141 | else |
| 142 | m_opaque_sp->GetArguments().Clear(); |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | uint32_t |
| 147 | SBLaunchInfo::GetNumEnvironmentEntries () |
| 148 | { |
| 149 | return m_opaque_sp->GetEnvironmentEntries().GetArgumentCount(); |
| 150 | } |
| 151 | |
| 152 | const char * |
| 153 | SBLaunchInfo::GetEnvironmentEntryAtIndex (uint32_t idx) |
| 154 | { |
| 155 | return m_opaque_sp->GetEnvironmentEntries().GetArgumentAtIndex(idx); |
| 156 | } |
| 157 | |
| 158 | void |
| 159 | SBLaunchInfo::SetEnvironmentEntries (const char **envp, bool append) |
| 160 | { |
| 161 | if (append) |
| 162 | { |
| 163 | if (envp) |
| 164 | m_opaque_sp->GetEnvironmentEntries().AppendArguments(envp); |
| 165 | } |
| 166 | else |
| 167 | { |
| 168 | if (envp) |
| 169 | m_opaque_sp->GetEnvironmentEntries().SetArguments(envp); |
| 170 | else |
| 171 | m_opaque_sp->GetEnvironmentEntries().Clear(); |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | void |
| 176 | SBLaunchInfo::Clear () |
| 177 | { |
| 178 | m_opaque_sp->Clear(); |
| 179 | } |
| 180 | |
| 181 | const char * |
| 182 | SBLaunchInfo::GetWorkingDirectory () const |
| 183 | { |
| 184 | return m_opaque_sp->GetWorkingDirectory(); |
| 185 | } |
| 186 | |
| 187 | void |
| 188 | SBLaunchInfo::SetWorkingDirectory (const char *working_dir) |
| 189 | { |
| 190 | m_opaque_sp->SetWorkingDirectory(working_dir); |
| 191 | } |
| 192 | |
| 193 | uint32_t |
| 194 | SBLaunchInfo::GetLaunchFlags () |
| 195 | { |
| 196 | return m_opaque_sp->GetFlags().Get(); |
| 197 | } |
| 198 | |
| 199 | void |
| 200 | SBLaunchInfo::SetLaunchFlags (uint32_t flags) |
| 201 | { |
| 202 | m_opaque_sp->GetFlags().Reset(flags); |
| 203 | } |
| 204 | |
| 205 | const char * |
| 206 | SBLaunchInfo::GetProcessPluginName () |
| 207 | { |
| 208 | return m_opaque_sp->GetProcessPluginName(); |
| 209 | } |
| 210 | |
| 211 | void |
| 212 | SBLaunchInfo::SetProcessPluginName (const char *plugin_name) |
| 213 | { |
| 214 | return m_opaque_sp->SetProcessPluginName (plugin_name); |
| 215 | } |
| 216 | |
| 217 | const char * |
| 218 | SBLaunchInfo::GetShell () |
| 219 | { |
| 220 | return m_opaque_sp->GetShell(); |
| 221 | } |
| 222 | |
| 223 | void |
| 224 | SBLaunchInfo::SetShell (const char * path) |
| 225 | { |
| 226 | m_opaque_sp->SetShell (path); |
| 227 | } |
| 228 | |
| 229 | uint32_t |
| 230 | SBLaunchInfo::GetResumeCount () |
| 231 | { |
| 232 | return m_opaque_sp->GetResumeCount(); |
| 233 | } |
| 234 | |
| 235 | void |
| 236 | SBLaunchInfo::SetResumeCount (uint32_t c) |
| 237 | { |
| 238 | m_opaque_sp->SetResumeCount (c); |
| 239 | } |
| 240 | |
| 241 | bool |
| 242 | SBLaunchInfo::AddCloseFileAction (int fd) |
| 243 | { |
| 244 | return m_opaque_sp->AppendCloseFileAction(fd); |
| 245 | } |
| 246 | |
| 247 | bool |
| 248 | SBLaunchInfo::AddDuplicateFileAction (int fd, int dup_fd) |
| 249 | { |
| 250 | return m_opaque_sp->AppendDuplicateFileAction(fd, dup_fd); |
| 251 | } |
| 252 | |
| 253 | bool |
| 254 | SBLaunchInfo::AddOpenFileAction (int fd, const char *path, bool read, bool write) |
| 255 | { |
| 256 | return m_opaque_sp->AppendOpenFileAction(fd, path, read, write); |
| 257 | } |
| 258 | |
| 259 | bool |
| 260 | SBLaunchInfo::AddSuppressFileAction (int fd, bool read, bool write) |
| 261 | { |
| 262 | return m_opaque_sp->AppendSuppressFileAction(fd, read, write); |
| 263 | } |
| 264 | |
| 265 | |
| 266 | SBAttachInfo::SBAttachInfo () : |
Greg Clayton | 66c2e19 | 2012-03-07 23:52:51 +0000 | [diff] [blame] | 267 | m_opaque_sp (new ProcessAttachInfo()) |
Greg Clayton | 0a8dcac | 2012-02-24 05:03:03 +0000 | [diff] [blame] | 268 | { |
| 269 | } |
| 270 | |
| 271 | SBAttachInfo::SBAttachInfo (lldb::pid_t pid) : |
Greg Clayton | 66c2e19 | 2012-03-07 23:52:51 +0000 | [diff] [blame] | 272 | m_opaque_sp (new ProcessAttachInfo()) |
Greg Clayton | 0a8dcac | 2012-02-24 05:03:03 +0000 | [diff] [blame] | 273 | { |
| 274 | m_opaque_sp->SetProcessID (pid); |
| 275 | } |
| 276 | |
| 277 | SBAttachInfo::SBAttachInfo (const char *path, bool wait_for) : |
Greg Clayton | 66c2e19 | 2012-03-07 23:52:51 +0000 | [diff] [blame] | 278 | m_opaque_sp (new ProcessAttachInfo()) |
Greg Clayton | 0a8dcac | 2012-02-24 05:03:03 +0000 | [diff] [blame] | 279 | { |
| 280 | if (path && path[0]) |
| 281 | m_opaque_sp->GetExecutableFile().SetFile(path, false); |
| 282 | m_opaque_sp->SetWaitForLaunch (wait_for); |
| 283 | } |
| 284 | |
| 285 | SBAttachInfo::SBAttachInfo (const SBAttachInfo &rhs) : |
Greg Clayton | 66c2e19 | 2012-03-07 23:52:51 +0000 | [diff] [blame] | 286 | m_opaque_sp (new ProcessAttachInfo()) |
Greg Clayton | 0a8dcac | 2012-02-24 05:03:03 +0000 | [diff] [blame] | 287 | { |
| 288 | *m_opaque_sp = *rhs.m_opaque_sp; |
| 289 | } |
| 290 | |
Greg Clayton | 66c2e19 | 2012-03-07 23:52:51 +0000 | [diff] [blame] | 291 | SBAttachInfo::~SBAttachInfo() |
| 292 | { |
| 293 | } |
| 294 | |
| 295 | lldb_private::ProcessAttachInfo & |
| 296 | SBAttachInfo::ref () |
| 297 | { |
| 298 | return *m_opaque_sp; |
| 299 | } |
| 300 | |
Greg Clayton | 0a8dcac | 2012-02-24 05:03:03 +0000 | [diff] [blame] | 301 | SBAttachInfo & |
| 302 | SBAttachInfo::operator = (const SBAttachInfo &rhs) |
| 303 | { |
| 304 | if (this != &rhs) |
| 305 | *m_opaque_sp = *rhs.m_opaque_sp; |
| 306 | return *this; |
| 307 | } |
| 308 | |
| 309 | lldb::pid_t |
| 310 | SBAttachInfo::GetProcessID () |
| 311 | { |
| 312 | return m_opaque_sp->GetProcessID(); |
| 313 | } |
| 314 | |
| 315 | void |
| 316 | SBAttachInfo::SetProcessID (lldb::pid_t pid) |
| 317 | { |
| 318 | m_opaque_sp->SetProcessID (pid); |
| 319 | } |
| 320 | |
| 321 | |
| 322 | uint32_t |
| 323 | SBAttachInfo::GetResumeCount () |
| 324 | { |
| 325 | return m_opaque_sp->GetResumeCount(); |
| 326 | } |
| 327 | |
| 328 | void |
| 329 | SBAttachInfo::SetResumeCount (uint32_t c) |
| 330 | { |
| 331 | m_opaque_sp->SetResumeCount (c); |
| 332 | } |
| 333 | |
| 334 | const char * |
| 335 | SBAttachInfo::GetProcessPluginName () |
| 336 | { |
| 337 | return m_opaque_sp->GetProcessPluginName(); |
| 338 | } |
| 339 | |
| 340 | void |
| 341 | SBAttachInfo::SetProcessPluginName (const char *plugin_name) |
| 342 | { |
| 343 | return m_opaque_sp->SetProcessPluginName (plugin_name); |
| 344 | } |
| 345 | |
| 346 | void |
| 347 | SBAttachInfo::SetExecutable (const char *path) |
| 348 | { |
| 349 | if (path && path[0]) |
| 350 | m_opaque_sp->GetExecutableFile().SetFile(path, false); |
| 351 | else |
| 352 | m_opaque_sp->GetExecutableFile().Clear(); |
| 353 | } |
| 354 | |
| 355 | void |
| 356 | SBAttachInfo::SetExecutable (SBFileSpec exe_file) |
| 357 | { |
| 358 | if (exe_file.IsValid()) |
| 359 | m_opaque_sp->GetExecutableFile() = exe_file.ref(); |
| 360 | else |
| 361 | m_opaque_sp->GetExecutableFile().Clear(); |
| 362 | } |
| 363 | |
| 364 | bool |
| 365 | SBAttachInfo::GetWaitForLaunch () |
| 366 | { |
| 367 | return m_opaque_sp->GetWaitForLaunch(); |
| 368 | } |
| 369 | |
| 370 | void |
| 371 | SBAttachInfo::SetWaitForLaunch (bool b) |
| 372 | { |
| 373 | m_opaque_sp->SetWaitForLaunch (b); |
| 374 | } |
| 375 | |
Jim Ingham | 3a458eb | 2012-07-20 21:37:13 +0000 | [diff] [blame] | 376 | bool |
| 377 | SBAttachInfo::GetIgnoreExisting () |
| 378 | { |
| 379 | return m_opaque_sp->GetIgnoreExisting(); |
| 380 | } |
| 381 | |
| 382 | void |
| 383 | SBAttachInfo::SetIgnoreExisting (bool b) |
| 384 | { |
| 385 | m_opaque_sp->SetIgnoreExisting (b); |
| 386 | } |
| 387 | |
Greg Clayton | 0a8dcac | 2012-02-24 05:03:03 +0000 | [diff] [blame] | 388 | uint32_t |
Greg Clayton | 80efa5e | 2012-02-24 23:56:06 +0000 | [diff] [blame] | 389 | SBAttachInfo::GetUserID() |
| 390 | { |
| 391 | return m_opaque_sp->GetUserID(); |
| 392 | } |
| 393 | |
| 394 | uint32_t |
| 395 | SBAttachInfo::GetGroupID() |
| 396 | { |
| 397 | return m_opaque_sp->GetGroupID(); |
| 398 | } |
| 399 | |
| 400 | bool |
| 401 | SBAttachInfo::UserIDIsValid () |
| 402 | { |
| 403 | return m_opaque_sp->UserIDIsValid(); |
| 404 | } |
| 405 | |
| 406 | bool |
| 407 | SBAttachInfo::GroupIDIsValid () |
| 408 | { |
| 409 | return m_opaque_sp->GroupIDIsValid(); |
| 410 | } |
| 411 | |
| 412 | void |
| 413 | SBAttachInfo::SetUserID (uint32_t uid) |
| 414 | { |
| 415 | m_opaque_sp->SetUserID (uid); |
| 416 | } |
| 417 | |
| 418 | void |
| 419 | SBAttachInfo::SetGroupID (uint32_t gid) |
| 420 | { |
| 421 | m_opaque_sp->SetGroupID (gid); |
| 422 | } |
| 423 | |
| 424 | uint32_t |
Greg Clayton | 0a8dcac | 2012-02-24 05:03:03 +0000 | [diff] [blame] | 425 | SBAttachInfo::GetEffectiveUserID() |
| 426 | { |
| 427 | return m_opaque_sp->GetEffectiveUserID(); |
| 428 | } |
| 429 | |
| 430 | uint32_t |
| 431 | SBAttachInfo::GetEffectiveGroupID() |
| 432 | { |
| 433 | return m_opaque_sp->GetEffectiveGroupID(); |
| 434 | } |
| 435 | |
| 436 | bool |
| 437 | SBAttachInfo::EffectiveUserIDIsValid () |
| 438 | { |
| 439 | return m_opaque_sp->EffectiveUserIDIsValid(); |
| 440 | } |
| 441 | |
| 442 | bool |
| 443 | SBAttachInfo::EffectiveGroupIDIsValid () |
| 444 | { |
| 445 | return m_opaque_sp->EffectiveGroupIDIsValid (); |
| 446 | } |
| 447 | |
| 448 | void |
| 449 | SBAttachInfo::SetEffectiveUserID (uint32_t uid) |
| 450 | { |
| 451 | m_opaque_sp->SetEffectiveUserID(uid); |
| 452 | } |
| 453 | |
| 454 | void |
| 455 | SBAttachInfo::SetEffectiveGroupID (uint32_t gid) |
| 456 | { |
| 457 | m_opaque_sp->SetEffectiveGroupID(gid); |
| 458 | } |
| 459 | |
| 460 | lldb::pid_t |
| 461 | SBAttachInfo::GetParentProcessID () |
| 462 | { |
| 463 | return m_opaque_sp->GetParentProcessID(); |
| 464 | } |
| 465 | |
| 466 | void |
| 467 | SBAttachInfo::SetParentProcessID (lldb::pid_t pid) |
| 468 | { |
| 469 | m_opaque_sp->SetParentProcessID (pid); |
| 470 | } |
| 471 | |
| 472 | bool |
| 473 | SBAttachInfo::ParentProcessIDIsValid() |
| 474 | { |
| 475 | return m_opaque_sp->ParentProcessIDIsValid(); |
| 476 | } |
| 477 | |
| 478 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 479 | //---------------------------------------------------------------------- |
| 480 | // SBTarget constructor |
| 481 | //---------------------------------------------------------------------- |
Greg Clayton | c3b61d2 | 2010-12-15 05:08:08 +0000 | [diff] [blame] | 482 | SBTarget::SBTarget () : |
| 483 | m_opaque_sp () |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 484 | { |
| 485 | } |
| 486 | |
| 487 | SBTarget::SBTarget (const SBTarget& rhs) : |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 488 | m_opaque_sp (rhs.m_opaque_sp) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 489 | { |
| 490 | } |
| 491 | |
| 492 | SBTarget::SBTarget(const TargetSP& target_sp) : |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 493 | m_opaque_sp (target_sp) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 494 | { |
| 495 | } |
| 496 | |
Greg Clayton | 538eb82 | 2010-11-05 23:17:00 +0000 | [diff] [blame] | 497 | const SBTarget& |
| 498 | SBTarget::operator = (const SBTarget& rhs) |
| 499 | { |
| 500 | if (this != &rhs) |
| 501 | m_opaque_sp = rhs.m_opaque_sp; |
| 502 | return *this; |
| 503 | } |
| 504 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 505 | //---------------------------------------------------------------------- |
| 506 | // Destructor |
| 507 | //---------------------------------------------------------------------- |
| 508 | SBTarget::~SBTarget() |
| 509 | { |
| 510 | } |
| 511 | |
Jim Ingham | 5a15e69 | 2012-02-16 06:50:00 +0000 | [diff] [blame] | 512 | const char * |
| 513 | SBTarget::GetBroadcasterClassName () |
| 514 | { |
| 515 | return Target::GetStaticBroadcasterClass().AsCString(); |
| 516 | } |
| 517 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 518 | bool |
| 519 | SBTarget::IsValid () const |
| 520 | { |
Filipe Cabecinhas | f7d782b | 2012-05-19 09:59:08 +0000 | [diff] [blame] | 521 | return m_opaque_sp.get() != NULL && m_opaque_sp->IsValid(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 522 | } |
| 523 | |
| 524 | SBProcess |
| 525 | SBTarget::GetProcess () |
| 526 | { |
| 527 | SBProcess sb_process; |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 528 | ProcessSP process_sp; |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 529 | TargetSP target_sp(GetSP()); |
| 530 | if (target_sp) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 531 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 532 | process_sp = target_sp->GetProcessSP(); |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 533 | sb_process.SetSP (process_sp); |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 534 | } |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 535 | |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 536 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 537 | if (log) |
| 538 | { |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 539 | log->Printf ("SBTarget(%p)::GetProcess () => SBProcess(%p)", |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 540 | target_sp.get(), process_sp.get()); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 541 | } |
| 542 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 543 | return sb_process; |
| 544 | } |
| 545 | |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 546 | SBDebugger |
| 547 | SBTarget::GetDebugger () const |
| 548 | { |
| 549 | SBDebugger debugger; |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 550 | TargetSP target_sp(GetSP()); |
| 551 | if (target_sp) |
| 552 | debugger.reset (target_sp->GetDebugger().shared_from_this()); |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 553 | return debugger; |
| 554 | } |
| 555 | |
Jim Ingham | b5871fe | 2011-03-31 00:01:24 +0000 | [diff] [blame] | 556 | SBProcess |
| 557 | SBTarget::LaunchSimple |
| 558 | ( |
| 559 | char const **argv, |
| 560 | char const **envp, |
| 561 | const char *working_directory |
| 562 | ) |
| 563 | { |
| 564 | char *stdin_path = NULL; |
| 565 | char *stdout_path = NULL; |
| 566 | char *stderr_path = NULL; |
| 567 | uint32_t launch_flags = 0; |
| 568 | bool stop_at_entry = false; |
| 569 | SBError error; |
| 570 | SBListener listener = GetDebugger().GetListener(); |
| 571 | return Launch (listener, |
| 572 | argv, |
| 573 | envp, |
| 574 | stdin_path, |
| 575 | stdout_path, |
| 576 | stderr_path, |
| 577 | working_directory, |
| 578 | launch_flags, |
| 579 | stop_at_entry, |
| 580 | error); |
| 581 | } |
Greg Clayton | de915be | 2011-01-23 05:56:20 +0000 | [diff] [blame] | 582 | |
| 583 | SBProcess |
| 584 | SBTarget::Launch |
| 585 | ( |
Greg Clayton | 271a5db | 2011-02-03 21:28:34 +0000 | [diff] [blame] | 586 | SBListener &listener, |
Greg Clayton | de915be | 2011-01-23 05:56:20 +0000 | [diff] [blame] | 587 | char const **argv, |
| 588 | char const **envp, |
| 589 | const char *stdin_path, |
| 590 | const char *stdout_path, |
| 591 | const char *stderr_path, |
| 592 | const char *working_directory, |
| 593 | uint32_t launch_flags, // See LaunchFlags |
| 594 | bool stop_at_entry, |
| 595 | lldb::SBError& error |
| 596 | ) |
| 597 | { |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 598 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 599 | |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 600 | SBProcess sb_process; |
| 601 | ProcessSP process_sp; |
| 602 | TargetSP target_sp(GetSP()); |
| 603 | |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 604 | if (log) |
Greg Clayton | 3f5ee7f | 2010-10-29 04:59:35 +0000 | [diff] [blame] | 605 | { |
Greg Clayton | de915be | 2011-01-23 05:56:20 +0000 | [diff] [blame] | 606 | log->Printf ("SBTarget(%p)::Launch (argv=%p, envp=%p, stdin=%s, stdout=%s, stderr=%s, working-dir=%s, launch_flags=0x%x, stop_at_entry=%i, &error (%p))...", |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 607 | target_sp.get(), |
Greg Clayton | de915be | 2011-01-23 05:56:20 +0000 | [diff] [blame] | 608 | argv, |
| 609 | envp, |
| 610 | stdin_path ? stdin_path : "NULL", |
| 611 | stdout_path ? stdout_path : "NULL", |
| 612 | stderr_path ? stderr_path : "NULL", |
| 613 | working_directory ? working_directory : "NULL", |
| 614 | launch_flags, |
| 615 | stop_at_entry, |
| 616 | error.get()); |
Greg Clayton | 3f5ee7f | 2010-10-29 04:59:35 +0000 | [diff] [blame] | 617 | } |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 618 | |
| 619 | if (target_sp) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 620 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 621 | Mutex::Locker api_locker (target_sp->GetAPIMutex()); |
Greg Clayton | 1a3083a | 2010-10-06 03:53:16 +0000 | [diff] [blame] | 622 | |
Greg Clayton | 7c330d6 | 2011-01-27 01:01:10 +0000 | [diff] [blame] | 623 | if (getenv("LLDB_LAUNCH_FLAG_DISABLE_ASLR")) |
| 624 | launch_flags |= eLaunchFlagDisableASLR; |
| 625 | |
Greg Clayton | 180546b | 2011-04-30 01:09:13 +0000 | [diff] [blame] | 626 | StateType state = eStateInvalid; |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 627 | process_sp = target_sp->GetProcessSP(); |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 628 | if (process_sp) |
Greg Clayton | 28d5fcc | 2011-01-27 06:44:37 +0000 | [diff] [blame] | 629 | { |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 630 | state = process_sp->GetState(); |
Greg Clayton | 180546b | 2011-04-30 01:09:13 +0000 | [diff] [blame] | 631 | |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 632 | if (process_sp->IsAlive() && state != eStateConnected) |
Greg Clayton | 180546b | 2011-04-30 01:09:13 +0000 | [diff] [blame] | 633 | { |
| 634 | if (state == eStateAttaching) |
| 635 | error.SetErrorString ("process attach is in progress"); |
| 636 | else |
| 637 | error.SetErrorString ("a process is already being debugged"); |
Greg Clayton | 180546b | 2011-04-30 01:09:13 +0000 | [diff] [blame] | 638 | return sb_process; |
| 639 | } |
Greg Clayton | 28d5fcc | 2011-01-27 06:44:37 +0000 | [diff] [blame] | 640 | } |
| 641 | |
Greg Clayton | 180546b | 2011-04-30 01:09:13 +0000 | [diff] [blame] | 642 | if (state == eStateConnected) |
| 643 | { |
| 644 | // If we are already connected, then we have already specified the |
| 645 | // listener, so if a valid listener is supplied, we need to error out |
| 646 | // to let the client know. |
| 647 | if (listener.IsValid()) |
| 648 | { |
| 649 | error.SetErrorString ("process is connected and already has a listener, pass empty listener"); |
Greg Clayton | 180546b | 2011-04-30 01:09:13 +0000 | [diff] [blame] | 650 | return sb_process; |
| 651 | } |
| 652 | } |
| 653 | else |
Greg Clayton | c5f728c | 2010-10-06 22:10:17 +0000 | [diff] [blame] | 654 | { |
Greg Clayton | 271a5db | 2011-02-03 21:28:34 +0000 | [diff] [blame] | 655 | if (listener.IsValid()) |
Greg Clayton | 46c9a35 | 2012-02-09 06:16:32 +0000 | [diff] [blame] | 656 | process_sp = target_sp->CreateProcess (listener.ref(), NULL, NULL); |
Greg Clayton | 271a5db | 2011-02-03 21:28:34 +0000 | [diff] [blame] | 657 | else |
Greg Clayton | 46c9a35 | 2012-02-09 06:16:32 +0000 | [diff] [blame] | 658 | process_sp = target_sp->CreateProcess (target_sp->GetDebugger().GetListener(), NULL, NULL); |
Greg Clayton | 180546b | 2011-04-30 01:09:13 +0000 | [diff] [blame] | 659 | } |
Greg Clayton | 7c330d6 | 2011-01-27 01:01:10 +0000 | [diff] [blame] | 660 | |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 661 | if (process_sp) |
Greg Clayton | 180546b | 2011-04-30 01:09:13 +0000 | [diff] [blame] | 662 | { |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 663 | sb_process.SetSP (process_sp); |
Greg Clayton | 180546b | 2011-04-30 01:09:13 +0000 | [diff] [blame] | 664 | if (getenv("LLDB_LAUNCH_FLAG_DISABLE_STDIO")) |
| 665 | launch_flags |= eLaunchFlagDisableSTDIO; |
| 666 | |
Greg Clayton | 36bc5ea | 2011-11-03 21:22:33 +0000 | [diff] [blame] | 667 | ProcessLaunchInfo launch_info (stdin_path, stdout_path, stderr_path, working_directory, launch_flags); |
| 668 | |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 669 | Module *exe_module = target_sp->GetExecutableModulePointer(); |
Greg Clayton | 36bc5ea | 2011-11-03 21:22:33 +0000 | [diff] [blame] | 670 | if (exe_module) |
Greg Clayton | 1d1f39e | 2011-11-29 04:03:30 +0000 | [diff] [blame] | 671 | launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true); |
Greg Clayton | 36bc5ea | 2011-11-03 21:22:33 +0000 | [diff] [blame] | 672 | if (argv) |
| 673 | launch_info.GetArguments().AppendArguments (argv); |
| 674 | if (envp) |
| 675 | launch_info.GetEnvironmentEntries ().SetArguments (envp); |
| 676 | |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 677 | error.SetError (process_sp->Launch (launch_info)); |
Greg Clayton | 180546b | 2011-04-30 01:09:13 +0000 | [diff] [blame] | 678 | if (error.Success()) |
Greg Clayton | 7c330d6 | 2011-01-27 01:01:10 +0000 | [diff] [blame] | 679 | { |
Greg Clayton | 180546b | 2011-04-30 01:09:13 +0000 | [diff] [blame] | 680 | // We we are stopping at the entry point, we can return now! |
| 681 | if (stop_at_entry) |
| 682 | return sb_process; |
Greg Clayton | 7c330d6 | 2011-01-27 01:01:10 +0000 | [diff] [blame] | 683 | |
Greg Clayton | 180546b | 2011-04-30 01:09:13 +0000 | [diff] [blame] | 684 | // Make sure we are stopped at the entry |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 685 | StateType state = process_sp->WaitForProcessToStop (NULL); |
Greg Clayton | 180546b | 2011-04-30 01:09:13 +0000 | [diff] [blame] | 686 | if (state == eStateStopped) |
Greg Clayton | 7c330d6 | 2011-01-27 01:01:10 +0000 | [diff] [blame] | 687 | { |
Greg Clayton | 180546b | 2011-04-30 01:09:13 +0000 | [diff] [blame] | 688 | // resume the process to skip the entry point |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 689 | error.SetError (process_sp->Resume()); |
Greg Clayton | 180546b | 2011-04-30 01:09:13 +0000 | [diff] [blame] | 690 | if (error.Success()) |
Greg Clayton | 7c330d6 | 2011-01-27 01:01:10 +0000 | [diff] [blame] | 691 | { |
Greg Clayton | 180546b | 2011-04-30 01:09:13 +0000 | [diff] [blame] | 692 | // If we are doing synchronous mode, then wait for the |
| 693 | // process to stop yet again! |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 694 | if (target_sp->GetDebugger().GetAsyncExecution () == false) |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 695 | process_sp->WaitForProcessToStop (NULL); |
Greg Clayton | 7c330d6 | 2011-01-27 01:01:10 +0000 | [diff] [blame] | 696 | } |
| 697 | } |
| 698 | } |
Greg Clayton | 180546b | 2011-04-30 01:09:13 +0000 | [diff] [blame] | 699 | } |
| 700 | else |
| 701 | { |
| 702 | error.SetErrorString ("unable to create lldb_private::Process"); |
Greg Clayton | c5f728c | 2010-10-06 22:10:17 +0000 | [diff] [blame] | 703 | } |
| 704 | } |
| 705 | else |
| 706 | { |
| 707 | error.SetErrorString ("SBTarget is invalid"); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 708 | } |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 709 | |
Caroline Tice | 926060e | 2010-10-29 21:48:37 +0000 | [diff] [blame] | 710 | log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 711 | if (log) |
| 712 | { |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 713 | log->Printf ("SBTarget(%p)::Launch (...) => SBProceess(%p)", |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 714 | target_sp.get(), process_sp.get()); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 715 | } |
| 716 | |
Greg Clayton | 1a3083a | 2010-10-06 03:53:16 +0000 | [diff] [blame] | 717 | return sb_process; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 718 | } |
| 719 | |
Greg Clayton | 0a8dcac | 2012-02-24 05:03:03 +0000 | [diff] [blame] | 720 | SBProcess |
| 721 | SBTarget::Launch (SBLaunchInfo &sb_launch_info, SBError& error) |
| 722 | { |
| 723 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
| 724 | |
| 725 | SBProcess sb_process; |
| 726 | ProcessSP process_sp; |
| 727 | TargetSP target_sp(GetSP()); |
| 728 | |
| 729 | if (log) |
| 730 | { |
| 731 | log->Printf ("SBTarget(%p)::Launch (launch_info, error)...", target_sp.get()); |
| 732 | } |
| 733 | |
| 734 | if (target_sp) |
| 735 | { |
| 736 | Mutex::Locker api_locker (target_sp->GetAPIMutex()); |
| 737 | StateType state = eStateInvalid; |
| 738 | process_sp = target_sp->GetProcessSP(); |
| 739 | if (process_sp) |
| 740 | { |
| 741 | state = process_sp->GetState(); |
| 742 | |
| 743 | if (process_sp->IsAlive() && state != eStateConnected) |
| 744 | { |
| 745 | if (state == eStateAttaching) |
| 746 | error.SetErrorString ("process attach is in progress"); |
| 747 | else |
| 748 | error.SetErrorString ("a process is already being debugged"); |
| 749 | return sb_process; |
| 750 | } |
| 751 | } |
| 752 | |
| 753 | if (state != eStateConnected) |
| 754 | process_sp = target_sp->CreateProcess (target_sp->GetDebugger().GetListener(), NULL, NULL); |
| 755 | |
| 756 | if (process_sp) |
| 757 | { |
| 758 | sb_process.SetSP (process_sp); |
| 759 | lldb_private::ProcessLaunchInfo &launch_info = sb_launch_info.ref(); |
Greg Clayton | 98ca1e6 | 2012-02-24 20:59:25 +0000 | [diff] [blame] | 760 | |
Greg Clayton | 98ca1e6 | 2012-02-24 20:59:25 +0000 | [diff] [blame] | 761 | Module *exe_module = target_sp->GetExecutableModulePointer(); |
| 762 | if (exe_module) |
Han Ming Ong | c86723f | 2012-03-02 01:02:04 +0000 | [diff] [blame] | 763 | launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true); |
Greg Clayton | 98ca1e6 | 2012-02-24 20:59:25 +0000 | [diff] [blame] | 764 | |
| 765 | const ArchSpec &arch_spec = target_sp->GetArchitecture(); |
| 766 | if (arch_spec.IsValid()) |
| 767 | launch_info.GetArchitecture () = arch_spec; |
| 768 | |
Greg Clayton | 0a8dcac | 2012-02-24 05:03:03 +0000 | [diff] [blame] | 769 | error.SetError (process_sp->Launch (launch_info)); |
Greg Clayton | 98ca1e6 | 2012-02-24 20:59:25 +0000 | [diff] [blame] | 770 | const bool synchronous_execution = target_sp->GetDebugger().GetAsyncExecution () == false; |
Greg Clayton | 0a8dcac | 2012-02-24 05:03:03 +0000 | [diff] [blame] | 771 | if (error.Success()) |
| 772 | { |
Greg Clayton | 0a8dcac | 2012-02-24 05:03:03 +0000 | [diff] [blame] | 773 | if (launch_info.GetFlags().Test(eLaunchFlagStopAtEntry)) |
Greg Clayton | 98ca1e6 | 2012-02-24 20:59:25 +0000 | [diff] [blame] | 774 | { |
| 775 | // If we are doing synchronous mode, then wait for the initial |
| 776 | // stop to happen, else, return and let the caller watch for |
| 777 | // the stop |
| 778 | if (synchronous_execution) |
Greg Clayton | 4a379b1 | 2012-07-17 03:23:13 +0000 | [diff] [blame] | 779 | process_sp->WaitForProcessToStop (NULL); |
Greg Clayton | 98ca1e6 | 2012-02-24 20:59:25 +0000 | [diff] [blame] | 780 | // We we are stopping at the entry point, we can return now! |
Greg Clayton | 0a8dcac | 2012-02-24 05:03:03 +0000 | [diff] [blame] | 781 | return sb_process; |
Greg Clayton | 98ca1e6 | 2012-02-24 20:59:25 +0000 | [diff] [blame] | 782 | } |
Greg Clayton | 0a8dcac | 2012-02-24 05:03:03 +0000 | [diff] [blame] | 783 | |
| 784 | // Make sure we are stopped at the entry |
Greg Clayton | 4a379b1 | 2012-07-17 03:23:13 +0000 | [diff] [blame] | 785 | StateType state = process_sp->WaitForProcessToStop (NULL); |
Greg Clayton | 0a8dcac | 2012-02-24 05:03:03 +0000 | [diff] [blame] | 786 | if (state == eStateStopped) |
| 787 | { |
| 788 | // resume the process to skip the entry point |
| 789 | error.SetError (process_sp->Resume()); |
| 790 | if (error.Success()) |
| 791 | { |
| 792 | // If we are doing synchronous mode, then wait for the |
| 793 | // process to stop yet again! |
Greg Clayton | 98ca1e6 | 2012-02-24 20:59:25 +0000 | [diff] [blame] | 794 | if (synchronous_execution) |
Greg Clayton | 0a8dcac | 2012-02-24 05:03:03 +0000 | [diff] [blame] | 795 | process_sp->WaitForProcessToStop (NULL); |
| 796 | } |
| 797 | } |
| 798 | } |
| 799 | } |
| 800 | else |
| 801 | { |
| 802 | error.SetErrorString ("unable to create lldb_private::Process"); |
| 803 | } |
| 804 | } |
| 805 | else |
| 806 | { |
| 807 | error.SetErrorString ("SBTarget is invalid"); |
| 808 | } |
| 809 | |
| 810 | log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); |
| 811 | if (log) |
| 812 | { |
| 813 | log->Printf ("SBTarget(%p)::Launch (...) => SBProceess(%p)", |
| 814 | target_sp.get(), process_sp.get()); |
| 815 | } |
| 816 | |
| 817 | return sb_process; |
| 818 | } |
| 819 | |
| 820 | lldb::SBProcess |
| 821 | SBTarget::Attach (SBAttachInfo &sb_attach_info, SBError& error) |
| 822 | { |
| 823 | SBProcess sb_process; |
| 824 | ProcessSP process_sp; |
| 825 | TargetSP target_sp(GetSP()); |
| 826 | if (target_sp) |
| 827 | { |
| 828 | Mutex::Locker api_locker (target_sp->GetAPIMutex()); |
| 829 | |
| 830 | StateType state = eStateInvalid; |
| 831 | process_sp = target_sp->GetProcessSP(); |
| 832 | if (process_sp) |
| 833 | { |
| 834 | state = process_sp->GetState(); |
| 835 | |
| 836 | if (process_sp->IsAlive() && state != eStateConnected) |
| 837 | { |
| 838 | if (state == eStateAttaching) |
| 839 | error.SetErrorString ("process attach is in progress"); |
| 840 | else |
| 841 | error.SetErrorString ("a process is already being debugged"); |
| 842 | return sb_process; |
| 843 | } |
| 844 | } |
| 845 | |
| 846 | if (state != eStateConnected) |
| 847 | process_sp = target_sp->CreateProcess (target_sp->GetDebugger().GetListener(), NULL, NULL); |
| 848 | |
| 849 | if (process_sp) |
| 850 | { |
Greg Clayton | 0a8dcac | 2012-02-24 05:03:03 +0000 | [diff] [blame] | 851 | ProcessAttachInfo &attach_info = sb_attach_info.ref(); |
Han Ming Ong | 435c5ef | 2012-02-29 00:12:56 +0000 | [diff] [blame] | 852 | lldb::pid_t attach_pid = attach_info.GetProcessID(); |
| 853 | if (attach_pid != LLDB_INVALID_PROCESS_ID) |
| 854 | { |
| 855 | PlatformSP platform_sp = target_sp->GetPlatform(); |
Greg Clayton | 02fac1c | 2012-09-27 00:03:39 +0000 | [diff] [blame] | 856 | // See if we can pre-verify if a process exists or not |
| 857 | if (platform_sp && platform_sp->IsConnected()) |
Han Ming Ong | 435c5ef | 2012-02-29 00:12:56 +0000 | [diff] [blame] | 858 | { |
Greg Clayton | 02fac1c | 2012-09-27 00:03:39 +0000 | [diff] [blame] | 859 | ProcessInstanceInfo instance_info; |
| 860 | if (platform_sp->GetProcessInfo(attach_pid, instance_info)) |
| 861 | { |
| 862 | attach_info.SetUserID(instance_info.GetEffectiveUserID()); |
| 863 | } |
| 864 | else |
| 865 | { |
| 866 | error.ref().SetErrorStringWithFormat("no process found with process ID %llu", attach_pid); |
| 867 | return sb_process; |
| 868 | } |
Han Ming Ong | 435c5ef | 2012-02-29 00:12:56 +0000 | [diff] [blame] | 869 | } |
| 870 | } |
Han Ming Ong | 94b4e9a | 2012-02-29 19:16:40 +0000 | [diff] [blame] | 871 | error.SetError (process_sp->Attach (attach_info)); |
| 872 | if (error.Success()) |
| 873 | { |
| 874 | sb_process.SetSP (process_sp); |
| 875 | // If we are doing synchronous mode, then wait for the |
| 876 | // process to stop! |
| 877 | if (target_sp->GetDebugger().GetAsyncExecution () == false) |
| 878 | process_sp->WaitForProcessToStop (NULL); |
| 879 | } |
Greg Clayton | 0a8dcac | 2012-02-24 05:03:03 +0000 | [diff] [blame] | 880 | } |
| 881 | else |
| 882 | { |
| 883 | error.SetErrorString ("unable to create lldb_private::Process"); |
| 884 | } |
| 885 | } |
| 886 | else |
| 887 | { |
| 888 | error.SetErrorString ("SBTarget is invalid"); |
| 889 | } |
| 890 | return sb_process; |
| 891 | } |
| 892 | |
| 893 | |
Greg Clayton | d5b0b44 | 2011-12-02 02:10:57 +0000 | [diff] [blame] | 894 | #if defined(__APPLE__) |
| 895 | |
| 896 | lldb::SBProcess |
| 897 | SBTarget::AttachToProcessWithID (SBListener &listener, |
| 898 | ::pid_t pid, |
| 899 | lldb::SBError& error) |
| 900 | { |
| 901 | return AttachToProcessWithID (listener, (lldb::pid_t)pid, error); |
| 902 | } |
| 903 | |
| 904 | #endif // #if defined(__APPLE__) |
Greg Clayton | c5f728c | 2010-10-06 22:10:17 +0000 | [diff] [blame] | 905 | |
| 906 | lldb::SBProcess |
Greg Clayton | d8c6253 | 2010-10-07 04:19:01 +0000 | [diff] [blame] | 907 | SBTarget::AttachToProcessWithID |
Greg Clayton | c5f728c | 2010-10-06 22:10:17 +0000 | [diff] [blame] | 908 | ( |
Greg Clayton | 271a5db | 2011-02-03 21:28:34 +0000 | [diff] [blame] | 909 | SBListener &listener, |
Greg Clayton | c5f728c | 2010-10-06 22:10:17 +0000 | [diff] [blame] | 910 | lldb::pid_t pid,// The process ID to attach to |
| 911 | SBError& error // An error explaining what went wrong if attach fails |
| 912 | ) |
| 913 | { |
| 914 | SBProcess sb_process; |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 915 | ProcessSP process_sp; |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 916 | TargetSP target_sp(GetSP()); |
| 917 | if (target_sp) |
Greg Clayton | c5f728c | 2010-10-06 22:10:17 +0000 | [diff] [blame] | 918 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 919 | Mutex::Locker api_locker (target_sp->GetAPIMutex()); |
Greg Clayton | de1dd81 | 2011-06-24 03:21:43 +0000 | [diff] [blame] | 920 | |
| 921 | StateType state = eStateInvalid; |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 922 | process_sp = target_sp->GetProcessSP(); |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 923 | if (process_sp) |
Greg Clayton | de1dd81 | 2011-06-24 03:21:43 +0000 | [diff] [blame] | 924 | { |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 925 | state = process_sp->GetState(); |
Greg Clayton | de1dd81 | 2011-06-24 03:21:43 +0000 | [diff] [blame] | 926 | |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 927 | if (process_sp->IsAlive() && state != eStateConnected) |
Greg Clayton | de1dd81 | 2011-06-24 03:21:43 +0000 | [diff] [blame] | 928 | { |
| 929 | if (state == eStateAttaching) |
| 930 | error.SetErrorString ("process attach is in progress"); |
| 931 | else |
| 932 | error.SetErrorString ("a process is already being debugged"); |
Greg Clayton | de1dd81 | 2011-06-24 03:21:43 +0000 | [diff] [blame] | 933 | return sb_process; |
| 934 | } |
| 935 | } |
| 936 | |
| 937 | if (state == eStateConnected) |
| 938 | { |
| 939 | // If we are already connected, then we have already specified the |
| 940 | // listener, so if a valid listener is supplied, we need to error out |
| 941 | // to let the client know. |
| 942 | if (listener.IsValid()) |
| 943 | { |
| 944 | error.SetErrorString ("process is connected and already has a listener, pass empty listener"); |
Greg Clayton | de1dd81 | 2011-06-24 03:21:43 +0000 | [diff] [blame] | 945 | return sb_process; |
| 946 | } |
| 947 | } |
Greg Clayton | 271a5db | 2011-02-03 21:28:34 +0000 | [diff] [blame] | 948 | else |
Greg Clayton | de1dd81 | 2011-06-24 03:21:43 +0000 | [diff] [blame] | 949 | { |
| 950 | if (listener.IsValid()) |
Greg Clayton | 46c9a35 | 2012-02-09 06:16:32 +0000 | [diff] [blame] | 951 | process_sp = target_sp->CreateProcess (listener.ref(), NULL, NULL); |
Greg Clayton | de1dd81 | 2011-06-24 03:21:43 +0000 | [diff] [blame] | 952 | else |
Greg Clayton | 46c9a35 | 2012-02-09 06:16:32 +0000 | [diff] [blame] | 953 | process_sp = target_sp->CreateProcess (target_sp->GetDebugger().GetListener(), NULL, NULL); |
Greg Clayton | de1dd81 | 2011-06-24 03:21:43 +0000 | [diff] [blame] | 954 | } |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 955 | if (process_sp) |
Greg Clayton | c5f728c | 2010-10-06 22:10:17 +0000 | [diff] [blame] | 956 | { |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 957 | sb_process.SetSP (process_sp); |
| 958 | |
Greg Clayton | 527154d | 2011-11-15 03:53:30 +0000 | [diff] [blame] | 959 | ProcessAttachInfo attach_info; |
| 960 | attach_info.SetProcessID (pid); |
Han Ming Ong | d1040dd | 2012-02-25 01:07:38 +0000 | [diff] [blame] | 961 | |
| 962 | PlatformSP platform_sp = target_sp->GetPlatform(); |
| 963 | ProcessInstanceInfo instance_info; |
| 964 | if (platform_sp->GetProcessInfo(pid, instance_info)) |
| 965 | { |
| 966 | attach_info.SetUserID(instance_info.GetEffectiveUserID()); |
Han Ming Ong | d1040dd | 2012-02-25 01:07:38 +0000 | [diff] [blame] | 967 | } |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 968 | error.SetError (process_sp->Attach (attach_info)); |
Greg Clayton | c643077 | 2012-09-07 17:51:47 +0000 | [diff] [blame] | 969 | if (error.Success()) |
| 970 | { |
| 971 | // If we are doing synchronous mode, then wait for the |
| 972 | // process to stop! |
| 973 | if (target_sp->GetDebugger().GetAsyncExecution () == false) |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 974 | process_sp->WaitForProcessToStop (NULL); |
Greg Clayton | c643077 | 2012-09-07 17:51:47 +0000 | [diff] [blame] | 975 | } |
Greg Clayton | c5f728c | 2010-10-06 22:10:17 +0000 | [diff] [blame] | 976 | } |
| 977 | else |
| 978 | { |
| 979 | error.SetErrorString ("unable to create lldb_private::Process"); |
| 980 | } |
| 981 | } |
| 982 | else |
| 983 | { |
| 984 | error.SetErrorString ("SBTarget is invalid"); |
| 985 | } |
| 986 | return sb_process; |
| 987 | |
| 988 | } |
| 989 | |
| 990 | lldb::SBProcess |
Greg Clayton | d8c6253 | 2010-10-07 04:19:01 +0000 | [diff] [blame] | 991 | SBTarget::AttachToProcessWithName |
Greg Clayton | c5f728c | 2010-10-06 22:10:17 +0000 | [diff] [blame] | 992 | ( |
Greg Clayton | 271a5db | 2011-02-03 21:28:34 +0000 | [diff] [blame] | 993 | SBListener &listener, |
Greg Clayton | c5f728c | 2010-10-06 22:10:17 +0000 | [diff] [blame] | 994 | const char *name, // basename of process to attach to |
| 995 | bool wait_for, // if true wait for a new instance of "name" to be launched |
| 996 | SBError& error // An error explaining what went wrong if attach fails |
| 997 | ) |
| 998 | { |
| 999 | SBProcess sb_process; |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 1000 | ProcessSP process_sp; |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1001 | TargetSP target_sp(GetSP()); |
| 1002 | if (name && target_sp) |
Greg Clayton | c5f728c | 2010-10-06 22:10:17 +0000 | [diff] [blame] | 1003 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1004 | Mutex::Locker api_locker (target_sp->GetAPIMutex()); |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 1005 | |
Greg Clayton | de1dd81 | 2011-06-24 03:21:43 +0000 | [diff] [blame] | 1006 | StateType state = eStateInvalid; |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1007 | process_sp = target_sp->GetProcessSP(); |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 1008 | if (process_sp) |
Greg Clayton | de1dd81 | 2011-06-24 03:21:43 +0000 | [diff] [blame] | 1009 | { |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 1010 | state = process_sp->GetState(); |
Greg Clayton | de1dd81 | 2011-06-24 03:21:43 +0000 | [diff] [blame] | 1011 | |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 1012 | if (process_sp->IsAlive() && state != eStateConnected) |
Greg Clayton | de1dd81 | 2011-06-24 03:21:43 +0000 | [diff] [blame] | 1013 | { |
| 1014 | if (state == eStateAttaching) |
| 1015 | error.SetErrorString ("process attach is in progress"); |
| 1016 | else |
| 1017 | error.SetErrorString ("a process is already being debugged"); |
Greg Clayton | de1dd81 | 2011-06-24 03:21:43 +0000 | [diff] [blame] | 1018 | return sb_process; |
| 1019 | } |
| 1020 | } |
| 1021 | |
| 1022 | if (state == eStateConnected) |
| 1023 | { |
| 1024 | // If we are already connected, then we have already specified the |
| 1025 | // listener, so if a valid listener is supplied, we need to error out |
| 1026 | // to let the client know. |
| 1027 | if (listener.IsValid()) |
| 1028 | { |
| 1029 | error.SetErrorString ("process is connected and already has a listener, pass empty listener"); |
Greg Clayton | de1dd81 | 2011-06-24 03:21:43 +0000 | [diff] [blame] | 1030 | return sb_process; |
| 1031 | } |
| 1032 | } |
Greg Clayton | 271a5db | 2011-02-03 21:28:34 +0000 | [diff] [blame] | 1033 | else |
Greg Clayton | de1dd81 | 2011-06-24 03:21:43 +0000 | [diff] [blame] | 1034 | { |
| 1035 | if (listener.IsValid()) |
Greg Clayton | 46c9a35 | 2012-02-09 06:16:32 +0000 | [diff] [blame] | 1036 | process_sp = target_sp->CreateProcess (listener.ref(), NULL, NULL); |
Greg Clayton | de1dd81 | 2011-06-24 03:21:43 +0000 | [diff] [blame] | 1037 | else |
Greg Clayton | 46c9a35 | 2012-02-09 06:16:32 +0000 | [diff] [blame] | 1038 | process_sp = target_sp->CreateProcess (target_sp->GetDebugger().GetListener(), NULL, NULL); |
Greg Clayton | de1dd81 | 2011-06-24 03:21:43 +0000 | [diff] [blame] | 1039 | } |
Greg Clayton | c5f728c | 2010-10-06 22:10:17 +0000 | [diff] [blame] | 1040 | |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 1041 | if (process_sp) |
Greg Clayton | c5f728c | 2010-10-06 22:10:17 +0000 | [diff] [blame] | 1042 | { |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 1043 | sb_process.SetSP (process_sp); |
Greg Clayton | 527154d | 2011-11-15 03:53:30 +0000 | [diff] [blame] | 1044 | ProcessAttachInfo attach_info; |
| 1045 | attach_info.GetExecutableFile().SetFile(name, false); |
| 1046 | attach_info.SetWaitForLaunch(wait_for); |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 1047 | error.SetError (process_sp->Attach (attach_info)); |
Johnny Chen | 58d02ff | 2011-06-17 19:21:30 +0000 | [diff] [blame] | 1048 | // If we are doing synchronous mode, then wait for the |
| 1049 | // process to stop! |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1050 | if (target_sp->GetDebugger().GetAsyncExecution () == false) |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 1051 | process_sp->WaitForProcessToStop (NULL); |
Greg Clayton | c5f728c | 2010-10-06 22:10:17 +0000 | [diff] [blame] | 1052 | } |
| 1053 | else |
| 1054 | { |
| 1055 | error.SetErrorString ("unable to create lldb_private::Process"); |
| 1056 | } |
| 1057 | } |
| 1058 | else |
| 1059 | { |
| 1060 | error.SetErrorString ("SBTarget is invalid"); |
| 1061 | } |
| 1062 | return sb_process; |
| 1063 | |
| 1064 | } |
| 1065 | |
James McIlree | 3809340 | 2011-03-04 00:31:13 +0000 | [diff] [blame] | 1066 | lldb::SBProcess |
| 1067 | SBTarget::ConnectRemote |
| 1068 | ( |
| 1069 | SBListener &listener, |
| 1070 | const char *url, |
| 1071 | const char *plugin_name, |
| 1072 | SBError& error |
| 1073 | ) |
| 1074 | { |
| 1075 | SBProcess sb_process; |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 1076 | ProcessSP process_sp; |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1077 | TargetSP target_sp(GetSP()); |
| 1078 | if (target_sp) |
James McIlree | 3809340 | 2011-03-04 00:31:13 +0000 | [diff] [blame] | 1079 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1080 | Mutex::Locker api_locker (target_sp->GetAPIMutex()); |
James McIlree | 3809340 | 2011-03-04 00:31:13 +0000 | [diff] [blame] | 1081 | if (listener.IsValid()) |
Greg Clayton | 46c9a35 | 2012-02-09 06:16:32 +0000 | [diff] [blame] | 1082 | process_sp = target_sp->CreateProcess (listener.ref(), plugin_name, NULL); |
James McIlree | 3809340 | 2011-03-04 00:31:13 +0000 | [diff] [blame] | 1083 | else |
Greg Clayton | 46c9a35 | 2012-02-09 06:16:32 +0000 | [diff] [blame] | 1084 | process_sp = target_sp->CreateProcess (target_sp->GetDebugger().GetListener(), plugin_name, NULL); |
James McIlree | 3809340 | 2011-03-04 00:31:13 +0000 | [diff] [blame] | 1085 | |
| 1086 | |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 1087 | if (process_sp) |
James McIlree | 3809340 | 2011-03-04 00:31:13 +0000 | [diff] [blame] | 1088 | { |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 1089 | sb_process.SetSP (process_sp); |
| 1090 | error.SetError (process_sp->ConnectRemote (url)); |
James McIlree | 3809340 | 2011-03-04 00:31:13 +0000 | [diff] [blame] | 1091 | } |
| 1092 | else |
| 1093 | { |
| 1094 | error.SetErrorString ("unable to create lldb_private::Process"); |
| 1095 | } |
| 1096 | } |
| 1097 | else |
| 1098 | { |
| 1099 | error.SetErrorString ("SBTarget is invalid"); |
| 1100 | } |
| 1101 | return sb_process; |
| 1102 | } |
| 1103 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1104 | SBFileSpec |
| 1105 | SBTarget::GetExecutable () |
| 1106 | { |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 1107 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1108 | SBFileSpec exe_file_spec; |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1109 | TargetSP target_sp(GetSP()); |
| 1110 | if (target_sp) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1111 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1112 | Module *exe_module = target_sp->GetExecutableModulePointer(); |
Greg Clayton | 5beb99d | 2011-08-11 02:48:45 +0000 | [diff] [blame] | 1113 | if (exe_module) |
| 1114 | exe_file_spec.SetFileSpec (exe_module->GetFileSpec()); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1115 | } |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 1116 | |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 1117 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 1118 | if (log) |
| 1119 | { |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 1120 | log->Printf ("SBTarget(%p)::GetExecutable () => SBFileSpec(%p)", |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1121 | target_sp.get(), exe_file_spec.get()); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 1122 | } |
| 1123 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1124 | return exe_file_spec; |
| 1125 | } |
| 1126 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1127 | bool |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1128 | SBTarget::operator == (const SBTarget &rhs) const |
| 1129 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 1130 | return m_opaque_sp.get() == rhs.m_opaque_sp.get(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1131 | } |
| 1132 | |
| 1133 | bool |
| 1134 | SBTarget::operator != (const SBTarget &rhs) const |
| 1135 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 1136 | return m_opaque_sp.get() != rhs.m_opaque_sp.get(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1137 | } |
| 1138 | |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 1139 | lldb::TargetSP |
| 1140 | SBTarget::GetSP () const |
Greg Clayton | 15afa9f | 2011-10-01 02:59:24 +0000 | [diff] [blame] | 1141 | { |
| 1142 | return m_opaque_sp; |
| 1143 | } |
| 1144 | |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 1145 | void |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 1146 | SBTarget::SetSP (const lldb::TargetSP& target_sp) |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 1147 | { |
| 1148 | m_opaque_sp = target_sp; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1149 | } |
| 1150 | |
Greg Clayton | a395506 | 2011-07-22 16:46:35 +0000 | [diff] [blame] | 1151 | lldb::SBAddress |
| 1152 | SBTarget::ResolveLoadAddress (lldb::addr_t vm_addr) |
Greg Clayton | ea49cc7 | 2010-12-12 19:25:26 +0000 | [diff] [blame] | 1153 | { |
Greg Clayton | a395506 | 2011-07-22 16:46:35 +0000 | [diff] [blame] | 1154 | lldb::SBAddress sb_addr; |
| 1155 | Address &addr = sb_addr.ref(); |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1156 | TargetSP target_sp(GetSP()); |
| 1157 | if (target_sp) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 1158 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1159 | Mutex::Locker api_locker (target_sp->GetAPIMutex()); |
| 1160 | if (target_sp->GetSectionLoadList().ResolveLoadAddress (vm_addr, addr)) |
Greg Clayton | a395506 | 2011-07-22 16:46:35 +0000 | [diff] [blame] | 1161 | return sb_addr; |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 1162 | } |
Greg Clayton | ea49cc7 | 2010-12-12 19:25:26 +0000 | [diff] [blame] | 1163 | |
Greg Clayton | a395506 | 2011-07-22 16:46:35 +0000 | [diff] [blame] | 1164 | // We have a load address that isn't in a section, just return an address |
| 1165 | // with the offset filled in (the address) and the section set to NULL |
Greg Clayton | 3508c38 | 2012-02-24 01:59:29 +0000 | [diff] [blame] | 1166 | addr.SetRawAddress(vm_addr); |
Greg Clayton | a395506 | 2011-07-22 16:46:35 +0000 | [diff] [blame] | 1167 | return sb_addr; |
Greg Clayton | ea49cc7 | 2010-12-12 19:25:26 +0000 | [diff] [blame] | 1168 | } |
| 1169 | |
Greg Clayton | afb8186 | 2011-03-02 21:34:46 +0000 | [diff] [blame] | 1170 | SBSymbolContext |
| 1171 | SBTarget::ResolveSymbolContextForAddress (const SBAddress& addr, uint32_t resolve_scope) |
| 1172 | { |
| 1173 | SBSymbolContext sc; |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1174 | if (addr.IsValid()) |
| 1175 | { |
| 1176 | TargetSP target_sp(GetSP()); |
| 1177 | if (target_sp) |
| 1178 | target_sp->GetImages().ResolveSymbolContextForAddress (addr.ref(), resolve_scope, sc.ref()); |
| 1179 | } |
Greg Clayton | afb8186 | 2011-03-02 21:34:46 +0000 | [diff] [blame] | 1180 | return sc; |
| 1181 | } |
| 1182 | |
| 1183 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1184 | SBBreakpoint |
| 1185 | SBTarget::BreakpointCreateByLocation (const char *file, uint32_t line) |
| 1186 | { |
Greg Clayton | d6d806c | 2010-11-08 00:28:40 +0000 | [diff] [blame] | 1187 | return SBBreakpoint(BreakpointCreateByLocation (SBFileSpec (file, false), line)); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1188 | } |
| 1189 | |
| 1190 | SBBreakpoint |
| 1191 | SBTarget::BreakpointCreateByLocation (const SBFileSpec &sb_file_spec, uint32_t line) |
| 1192 | { |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 1193 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 1194 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1195 | SBBreakpoint sb_bp; |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1196 | TargetSP target_sp(GetSP()); |
| 1197 | if (target_sp && line != 0) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 1198 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1199 | Mutex::Locker api_locker (target_sp->GetAPIMutex()); |
Jim Ingham | 2cf5ccb | 2012-05-22 00:12:20 +0000 | [diff] [blame] | 1200 | |
Greg Clayton | 49ce896 | 2012-08-29 21:13:06 +0000 | [diff] [blame] | 1201 | const LazyBool check_inlines = eLazyBoolCalculate; |
Jim Ingham | 2cf5ccb | 2012-05-22 00:12:20 +0000 | [diff] [blame] | 1202 | const LazyBool skip_prologue = eLazyBoolCalculate; |
Greg Clayton | 49ce896 | 2012-08-29 21:13:06 +0000 | [diff] [blame] | 1203 | const bool internal = false; |
Jim Ingham | 2cf5ccb | 2012-05-22 00:12:20 +0000 | [diff] [blame] | 1204 | *sb_bp = target_sp->CreateBreakpoint (NULL, *sb_file_spec, line, check_inlines, skip_prologue, internal); |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 1205 | } |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 1206 | |
| 1207 | if (log) |
| 1208 | { |
| 1209 | SBStream sstr; |
| 1210 | sb_bp.GetDescription (sstr); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 1211 | char path[PATH_MAX]; |
| 1212 | sb_file_spec->GetPath (path, sizeof(path)); |
| 1213 | log->Printf ("SBTarget(%p)::BreakpointCreateByLocation ( %s:%u ) => SBBreakpoint(%p): %s", |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1214 | target_sp.get(), |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 1215 | path, |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 1216 | line, |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 1217 | sb_bp.get(), |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 1218 | sstr.GetData()); |
| 1219 | } |
| 1220 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1221 | return sb_bp; |
| 1222 | } |
| 1223 | |
| 1224 | SBBreakpoint |
| 1225 | SBTarget::BreakpointCreateByName (const char *symbol_name, const char *module_name) |
| 1226 | { |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 1227 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 1228 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1229 | SBBreakpoint sb_bp; |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1230 | TargetSP target_sp(GetSP()); |
| 1231 | if (target_sp.get()) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1232 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1233 | Mutex::Locker api_locker (target_sp->GetAPIMutex()); |
Jim Ingham | 2cf5ccb | 2012-05-22 00:12:20 +0000 | [diff] [blame] | 1234 | |
| 1235 | const bool internal = false; |
| 1236 | const LazyBool skip_prologue = eLazyBoolCalculate; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1237 | if (module_name && module_name[0]) |
| 1238 | { |
Jim Ingham | 03c8ee5 | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 1239 | FileSpecList module_spec_list; |
| 1240 | module_spec_list.Append (FileSpec (module_name, false)); |
Jim Ingham | 2cf5ccb | 2012-05-22 00:12:20 +0000 | [diff] [blame] | 1241 | *sb_bp = target_sp->CreateBreakpoint (&module_spec_list, NULL, symbol_name, eFunctionNameTypeAuto, skip_prologue, internal); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1242 | } |
| 1243 | else |
| 1244 | { |
Jim Ingham | 2cf5ccb | 2012-05-22 00:12:20 +0000 | [diff] [blame] | 1245 | *sb_bp = target_sp->CreateBreakpoint (NULL, NULL, symbol_name, eFunctionNameTypeAuto, skip_prologue, internal); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1246 | } |
| 1247 | } |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 1248 | |
| 1249 | if (log) |
| 1250 | { |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 1251 | log->Printf ("SBTarget(%p)::BreakpointCreateByName (symbol=\"%s\", module=\"%s\") => SBBreakpoint(%p)", |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1252 | target_sp.get(), symbol_name, module_name, sb_bp.get()); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 1253 | } |
| 1254 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1255 | return sb_bp; |
| 1256 | } |
| 1257 | |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 1258 | lldb::SBBreakpoint |
| 1259 | SBTarget::BreakpointCreateByName (const char *symbol_name, |
| 1260 | const SBFileSpecList &module_list, |
| 1261 | const SBFileSpecList &comp_unit_list) |
| 1262 | { |
Jim Ingham | 1fb8a2d | 2011-10-11 01:18:55 +0000 | [diff] [blame] | 1263 | uint32_t name_type_mask = eFunctionNameTypeAuto; |
| 1264 | return BreakpointCreateByName (symbol_name, name_type_mask, module_list, comp_unit_list); |
| 1265 | } |
| 1266 | |
| 1267 | lldb::SBBreakpoint |
| 1268 | SBTarget::BreakpointCreateByName (const char *symbol_name, |
| 1269 | uint32_t name_type_mask, |
| 1270 | const SBFileSpecList &module_list, |
| 1271 | const SBFileSpecList &comp_unit_list) |
| 1272 | { |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 1273 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
| 1274 | |
| 1275 | SBBreakpoint sb_bp; |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1276 | TargetSP target_sp(GetSP()); |
| 1277 | if (target_sp && symbol_name && symbol_name[0]) |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 1278 | { |
Jim Ingham | 2cf5ccb | 2012-05-22 00:12:20 +0000 | [diff] [blame] | 1279 | const bool internal = false; |
| 1280 | const LazyBool skip_prologue = eLazyBoolCalculate; |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1281 | Mutex::Locker api_locker (target_sp->GetAPIMutex()); |
| 1282 | *sb_bp = target_sp->CreateBreakpoint (module_list.get(), |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 1283 | comp_unit_list.get(), |
| 1284 | symbol_name, |
Jim Ingham | 1fb8a2d | 2011-10-11 01:18:55 +0000 | [diff] [blame] | 1285 | name_type_mask, |
Jim Ingham | 2cf5ccb | 2012-05-22 00:12:20 +0000 | [diff] [blame] | 1286 | skip_prologue, |
| 1287 | internal); |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 1288 | } |
| 1289 | |
| 1290 | if (log) |
| 1291 | { |
Jim Ingham | 1fb8a2d | 2011-10-11 01:18:55 +0000 | [diff] [blame] | 1292 | log->Printf ("SBTarget(%p)::BreakpointCreateByName (symbol=\"%s\", name_type: %d) => SBBreakpoint(%p)", |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1293 | target_sp.get(), symbol_name, name_type_mask, sb_bp.get()); |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 1294 | } |
| 1295 | |
| 1296 | return sb_bp; |
| 1297 | } |
| 1298 | |
Jim Ingham | 4722b10 | 2012-03-06 00:37:27 +0000 | [diff] [blame] | 1299 | lldb::SBBreakpoint |
| 1300 | SBTarget::BreakpointCreateByNames (const char *symbol_names[], |
| 1301 | uint32_t num_names, |
| 1302 | uint32_t name_type_mask, |
| 1303 | const SBFileSpecList &module_list, |
| 1304 | const SBFileSpecList &comp_unit_list) |
| 1305 | { |
| 1306 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
| 1307 | |
| 1308 | SBBreakpoint sb_bp; |
| 1309 | TargetSP target_sp(GetSP()); |
| 1310 | if (target_sp && num_names > 0) |
| 1311 | { |
| 1312 | Mutex::Locker api_locker (target_sp->GetAPIMutex()); |
Jim Ingham | 2cf5ccb | 2012-05-22 00:12:20 +0000 | [diff] [blame] | 1313 | const bool internal = false; |
| 1314 | const LazyBool skip_prologue = eLazyBoolCalculate; |
Jim Ingham | 4722b10 | 2012-03-06 00:37:27 +0000 | [diff] [blame] | 1315 | *sb_bp = target_sp->CreateBreakpoint (module_list.get(), |
| 1316 | comp_unit_list.get(), |
| 1317 | symbol_names, |
| 1318 | num_names, |
| 1319 | name_type_mask, |
Jim Ingham | 2cf5ccb | 2012-05-22 00:12:20 +0000 | [diff] [blame] | 1320 | skip_prologue, |
| 1321 | internal); |
Jim Ingham | 4722b10 | 2012-03-06 00:37:27 +0000 | [diff] [blame] | 1322 | } |
| 1323 | |
| 1324 | if (log) |
| 1325 | { |
| 1326 | log->Printf ("SBTarget(%p)::BreakpointCreateByName (symbols={", target_sp.get()); |
| 1327 | for (uint32_t i = 0 ; i < num_names; i++) |
| 1328 | { |
| 1329 | char sep; |
| 1330 | if (i < num_names - 1) |
| 1331 | sep = ','; |
| 1332 | else |
| 1333 | sep = '}'; |
| 1334 | if (symbol_names[i] != NULL) |
| 1335 | log->Printf ("\"%s\"%c ", symbol_names[i], sep); |
| 1336 | else |
| 1337 | log->Printf ("\"<NULL>\"%c ", sep); |
| 1338 | |
| 1339 | } |
| 1340 | log->Printf ("name_type: %d) => SBBreakpoint(%p)", name_type_mask, sb_bp.get()); |
| 1341 | } |
| 1342 | |
| 1343 | return sb_bp; |
| 1344 | } |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 1345 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1346 | SBBreakpoint |
| 1347 | SBTarget::BreakpointCreateByRegex (const char *symbol_name_regex, const char *module_name) |
| 1348 | { |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 1349 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 1350 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1351 | SBBreakpoint sb_bp; |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1352 | TargetSP target_sp(GetSP()); |
| 1353 | if (target_sp && symbol_name_regex && symbol_name_regex[0]) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1354 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1355 | Mutex::Locker api_locker (target_sp->GetAPIMutex()); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1356 | RegularExpression regexp(symbol_name_regex); |
Jim Ingham | 2cf5ccb | 2012-05-22 00:12:20 +0000 | [diff] [blame] | 1357 | const bool internal = false; |
| 1358 | const LazyBool skip_prologue = eLazyBoolCalculate; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1359 | |
| 1360 | if (module_name && module_name[0]) |
| 1361 | { |
Jim Ingham | 03c8ee5 | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 1362 | FileSpecList module_spec_list; |
| 1363 | module_spec_list.Append (FileSpec (module_name, false)); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1364 | |
Jim Ingham | 2cf5ccb | 2012-05-22 00:12:20 +0000 | [diff] [blame] | 1365 | *sb_bp = target_sp->CreateFuncRegexBreakpoint (&module_spec_list, NULL, regexp, skip_prologue, internal); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1366 | } |
| 1367 | else |
| 1368 | { |
Jim Ingham | 2cf5ccb | 2012-05-22 00:12:20 +0000 | [diff] [blame] | 1369 | *sb_bp = target_sp->CreateFuncRegexBreakpoint (NULL, NULL, regexp, skip_prologue, internal); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1370 | } |
| 1371 | } |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 1372 | |
| 1373 | if (log) |
| 1374 | { |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 1375 | log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (symbol_regex=\"%s\", module_name=\"%s\") => SBBreakpoint(%p)", |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1376 | target_sp.get(), symbol_name_regex, module_name, sb_bp.get()); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 1377 | } |
| 1378 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1379 | return sb_bp; |
| 1380 | } |
| 1381 | |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 1382 | lldb::SBBreakpoint |
| 1383 | SBTarget::BreakpointCreateByRegex (const char *symbol_name_regex, |
| 1384 | const SBFileSpecList &module_list, |
| 1385 | const SBFileSpecList &comp_unit_list) |
| 1386 | { |
| 1387 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1388 | |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 1389 | SBBreakpoint sb_bp; |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1390 | TargetSP target_sp(GetSP()); |
| 1391 | if (target_sp && symbol_name_regex && symbol_name_regex[0]) |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 1392 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1393 | Mutex::Locker api_locker (target_sp->GetAPIMutex()); |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 1394 | RegularExpression regexp(symbol_name_regex); |
Jim Ingham | 2cf5ccb | 2012-05-22 00:12:20 +0000 | [diff] [blame] | 1395 | const bool internal = false; |
| 1396 | const LazyBool skip_prologue = eLazyBoolCalculate; |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 1397 | |
Jim Ingham | 2cf5ccb | 2012-05-22 00:12:20 +0000 | [diff] [blame] | 1398 | *sb_bp = target_sp->CreateFuncRegexBreakpoint (module_list.get(), comp_unit_list.get(), regexp, skip_prologue, internal); |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 1399 | } |
| 1400 | |
| 1401 | if (log) |
| 1402 | { |
| 1403 | log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (symbol_regex=\"%s\") => SBBreakpoint(%p)", |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1404 | target_sp.get(), symbol_name_regex, sb_bp.get()); |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 1405 | } |
| 1406 | |
| 1407 | return sb_bp; |
| 1408 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1409 | |
| 1410 | SBBreakpoint |
| 1411 | SBTarget::BreakpointCreateByAddress (addr_t address) |
| 1412 | { |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 1413 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 1414 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1415 | SBBreakpoint sb_bp; |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1416 | TargetSP target_sp(GetSP()); |
| 1417 | if (target_sp) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 1418 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1419 | Mutex::Locker api_locker (target_sp->GetAPIMutex()); |
| 1420 | *sb_bp = target_sp->CreateBreakpoint (address, false); |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 1421 | } |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 1422 | |
| 1423 | if (log) |
| 1424 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1425 | log->Printf ("SBTarget(%p)::BreakpointCreateByAddress (address=%llu) => SBBreakpoint(%p)", target_sp.get(), (uint64_t) address, sb_bp.get()); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 1426 | } |
| 1427 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1428 | return sb_bp; |
| 1429 | } |
| 1430 | |
Jim Ingham | 03c8ee5 | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 1431 | lldb::SBBreakpoint |
| 1432 | SBTarget::BreakpointCreateBySourceRegex (const char *source_regex, const lldb::SBFileSpec &source_file, const char *module_name) |
| 1433 | { |
| 1434 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
| 1435 | |
| 1436 | SBBreakpoint sb_bp; |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1437 | TargetSP target_sp(GetSP()); |
| 1438 | if (target_sp && source_regex && source_regex[0]) |
Jim Ingham | 03c8ee5 | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 1439 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1440 | Mutex::Locker api_locker (target_sp->GetAPIMutex()); |
Jim Ingham | 03c8ee5 | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 1441 | RegularExpression regexp(source_regex); |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 1442 | FileSpecList source_file_spec_list; |
| 1443 | source_file_spec_list.Append (source_file.ref()); |
Jim Ingham | 03c8ee5 | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 1444 | |
| 1445 | if (module_name && module_name[0]) |
| 1446 | { |
| 1447 | FileSpecList module_spec_list; |
| 1448 | module_spec_list.Append (FileSpec (module_name, false)); |
| 1449 | |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1450 | *sb_bp = target_sp->CreateSourceRegexBreakpoint (&module_spec_list, &source_file_spec_list, regexp, false); |
Jim Ingham | 03c8ee5 | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 1451 | } |
| 1452 | else |
| 1453 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1454 | *sb_bp = target_sp->CreateSourceRegexBreakpoint (NULL, &source_file_spec_list, regexp, false); |
Jim Ingham | 03c8ee5 | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 1455 | } |
| 1456 | } |
| 1457 | |
| 1458 | if (log) |
| 1459 | { |
| 1460 | char path[PATH_MAX]; |
| 1461 | source_file->GetPath (path, sizeof(path)); |
| 1462 | log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (source_regex=\"%s\", file=\"%s\", module_name=\"%s\") => SBBreakpoint(%p)", |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1463 | target_sp.get(), source_regex, path, module_name, sb_bp.get()); |
Jim Ingham | 03c8ee5 | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 1464 | } |
| 1465 | |
| 1466 | return sb_bp; |
| 1467 | } |
| 1468 | |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 1469 | lldb::SBBreakpoint |
| 1470 | SBTarget::BreakpointCreateBySourceRegex (const char *source_regex, |
| 1471 | const SBFileSpecList &module_list, |
| 1472 | const lldb::SBFileSpecList &source_file_list) |
| 1473 | { |
| 1474 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
| 1475 | |
| 1476 | SBBreakpoint sb_bp; |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1477 | TargetSP target_sp(GetSP()); |
| 1478 | if (target_sp && source_regex && source_regex[0]) |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 1479 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1480 | Mutex::Locker api_locker (target_sp->GetAPIMutex()); |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 1481 | RegularExpression regexp(source_regex); |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1482 | *sb_bp = target_sp->CreateSourceRegexBreakpoint (module_list.get(), source_file_list.get(), regexp, false); |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 1483 | } |
| 1484 | |
| 1485 | if (log) |
| 1486 | { |
| 1487 | log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (source_regex=\"%s\") => SBBreakpoint(%p)", |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1488 | target_sp.get(), source_regex, sb_bp.get()); |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 1489 | } |
| 1490 | |
| 1491 | return sb_bp; |
| 1492 | } |
Jim Ingham | 03c8ee5 | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 1493 | |
Jim Ingham | 4722b10 | 2012-03-06 00:37:27 +0000 | [diff] [blame] | 1494 | lldb::SBBreakpoint |
| 1495 | SBTarget::BreakpointCreateForException (lldb::LanguageType language, |
| 1496 | bool catch_bp, |
| 1497 | bool throw_bp) |
| 1498 | { |
| 1499 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
| 1500 | |
| 1501 | SBBreakpoint sb_bp; |
| 1502 | TargetSP target_sp(GetSP()); |
| 1503 | if (target_sp) |
| 1504 | { |
| 1505 | Mutex::Locker api_locker (target_sp->GetAPIMutex()); |
| 1506 | *sb_bp = target_sp->CreateExceptionBreakpoint (language, catch_bp, throw_bp); |
| 1507 | } |
| 1508 | |
| 1509 | if (log) |
| 1510 | { |
| 1511 | log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (Language: %s, catch: %s throw: %s) => SBBreakpoint(%p)", |
| 1512 | target_sp.get(), |
| 1513 | LanguageRuntime::GetNameForLanguageType(language), |
| 1514 | catch_bp ? "on" : "off", |
| 1515 | throw_bp ? "on" : "off", |
| 1516 | sb_bp.get()); |
| 1517 | } |
| 1518 | |
| 1519 | return sb_bp; |
| 1520 | } |
| 1521 | |
Greg Clayton | c7f5d5c | 2010-07-23 23:33:17 +0000 | [diff] [blame] | 1522 | uint32_t |
| 1523 | SBTarget::GetNumBreakpoints () const |
| 1524 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1525 | TargetSP target_sp(GetSP()); |
| 1526 | if (target_sp) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 1527 | { |
| 1528 | // The breakpoint list is thread safe, no need to lock |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1529 | return target_sp->GetBreakpointList().GetSize(); |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 1530 | } |
Greg Clayton | c7f5d5c | 2010-07-23 23:33:17 +0000 | [diff] [blame] | 1531 | return 0; |
| 1532 | } |
| 1533 | |
| 1534 | SBBreakpoint |
| 1535 | SBTarget::GetBreakpointAtIndex (uint32_t idx) const |
| 1536 | { |
| 1537 | SBBreakpoint sb_breakpoint; |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1538 | TargetSP target_sp(GetSP()); |
| 1539 | if (target_sp) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 1540 | { |
| 1541 | // The breakpoint list is thread safe, no need to lock |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1542 | *sb_breakpoint = target_sp->GetBreakpointList().GetBreakpointAtIndex(idx); |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 1543 | } |
Greg Clayton | c7f5d5c | 2010-07-23 23:33:17 +0000 | [diff] [blame] | 1544 | return sb_breakpoint; |
| 1545 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1546 | |
| 1547 | bool |
| 1548 | SBTarget::BreakpointDelete (break_id_t bp_id) |
| 1549 | { |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 1550 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 1551 | |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 1552 | bool result = false; |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1553 | TargetSP target_sp(GetSP()); |
| 1554 | if (target_sp) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 1555 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1556 | Mutex::Locker api_locker (target_sp->GetAPIMutex()); |
| 1557 | result = target_sp->RemoveBreakpointByID (bp_id); |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 1558 | } |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 1559 | |
| 1560 | if (log) |
| 1561 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1562 | log->Printf ("SBTarget(%p)::BreakpointDelete (bp_id=%d) => %i", target_sp.get(), (uint32_t) bp_id, result); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 1563 | } |
| 1564 | |
| 1565 | return result; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1566 | } |
| 1567 | |
Johnny Chen | 096c293 | 2011-09-26 22:40:50 +0000 | [diff] [blame] | 1568 | SBBreakpoint |
| 1569 | SBTarget::FindBreakpointByID (break_id_t bp_id) |
| 1570 | { |
| 1571 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
| 1572 | |
| 1573 | SBBreakpoint sb_breakpoint; |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1574 | TargetSP target_sp(GetSP()); |
| 1575 | if (target_sp && bp_id != LLDB_INVALID_BREAK_ID) |
Johnny Chen | 096c293 | 2011-09-26 22:40:50 +0000 | [diff] [blame] | 1576 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1577 | Mutex::Locker api_locker (target_sp->GetAPIMutex()); |
| 1578 | *sb_breakpoint = target_sp->GetBreakpointByID (bp_id); |
Johnny Chen | 096c293 | 2011-09-26 22:40:50 +0000 | [diff] [blame] | 1579 | } |
| 1580 | |
| 1581 | if (log) |
| 1582 | { |
| 1583 | log->Printf ("SBTarget(%p)::FindBreakpointByID (bp_id=%d) => SBBreakpoint(%p)", |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1584 | target_sp.get(), (uint32_t) bp_id, sb_breakpoint.get()); |
Johnny Chen | 096c293 | 2011-09-26 22:40:50 +0000 | [diff] [blame] | 1585 | } |
| 1586 | |
| 1587 | return sb_breakpoint; |
| 1588 | } |
| 1589 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1590 | bool |
| 1591 | SBTarget::EnableAllBreakpoints () |
| 1592 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1593 | TargetSP target_sp(GetSP()); |
| 1594 | if (target_sp) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1595 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1596 | Mutex::Locker api_locker (target_sp->GetAPIMutex()); |
| 1597 | target_sp->EnableAllBreakpoints (); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1598 | return true; |
| 1599 | } |
| 1600 | return false; |
| 1601 | } |
| 1602 | |
| 1603 | bool |
| 1604 | SBTarget::DisableAllBreakpoints () |
| 1605 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1606 | TargetSP target_sp(GetSP()); |
| 1607 | if (target_sp) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1608 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1609 | Mutex::Locker api_locker (target_sp->GetAPIMutex()); |
| 1610 | target_sp->DisableAllBreakpoints (); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1611 | return true; |
| 1612 | } |
| 1613 | return false; |
| 1614 | } |
| 1615 | |
| 1616 | bool |
| 1617 | SBTarget::DeleteAllBreakpoints () |
| 1618 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1619 | TargetSP target_sp(GetSP()); |
| 1620 | if (target_sp) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1621 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1622 | Mutex::Locker api_locker (target_sp->GetAPIMutex()); |
| 1623 | target_sp->RemoveAllBreakpoints (); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1624 | return true; |
| 1625 | } |
| 1626 | return false; |
| 1627 | } |
| 1628 | |
Johnny Chen | 096c293 | 2011-09-26 22:40:50 +0000 | [diff] [blame] | 1629 | uint32_t |
Greg Clayton | 1fa6b3d | 2011-10-13 18:08:26 +0000 | [diff] [blame] | 1630 | SBTarget::GetNumWatchpoints () const |
Johnny Chen | 096c293 | 2011-09-26 22:40:50 +0000 | [diff] [blame] | 1631 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1632 | TargetSP target_sp(GetSP()); |
| 1633 | if (target_sp) |
Johnny Chen | 096c293 | 2011-09-26 22:40:50 +0000 | [diff] [blame] | 1634 | { |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 1635 | // The watchpoint list is thread safe, no need to lock |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1636 | return target_sp->GetWatchpointList().GetSize(); |
Johnny Chen | 096c293 | 2011-09-26 22:40:50 +0000 | [diff] [blame] | 1637 | } |
| 1638 | return 0; |
| 1639 | } |
| 1640 | |
Greg Clayton | 1fa6b3d | 2011-10-13 18:08:26 +0000 | [diff] [blame] | 1641 | SBWatchpoint |
| 1642 | SBTarget::GetWatchpointAtIndex (uint32_t idx) const |
Johnny Chen | 5eb54bb | 2011-09-27 20:29:45 +0000 | [diff] [blame] | 1643 | { |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 1644 | SBWatchpoint sb_watchpoint; |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1645 | TargetSP target_sp(GetSP()); |
| 1646 | if (target_sp) |
Johnny Chen | 096c293 | 2011-09-26 22:40:50 +0000 | [diff] [blame] | 1647 | { |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 1648 | // The watchpoint list is thread safe, no need to lock |
Greg Clayton | 0a19a1b | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 1649 | sb_watchpoint.SetSP (target_sp->GetWatchpointList().GetByIndex(idx)); |
Johnny Chen | 096c293 | 2011-09-26 22:40:50 +0000 | [diff] [blame] | 1650 | } |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 1651 | return sb_watchpoint; |
Johnny Chen | 096c293 | 2011-09-26 22:40:50 +0000 | [diff] [blame] | 1652 | } |
| 1653 | |
| 1654 | bool |
Greg Clayton | 1fa6b3d | 2011-10-13 18:08:26 +0000 | [diff] [blame] | 1655 | SBTarget::DeleteWatchpoint (watch_id_t wp_id) |
Johnny Chen | 096c293 | 2011-09-26 22:40:50 +0000 | [diff] [blame] | 1656 | { |
| 1657 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
| 1658 | |
| 1659 | bool result = false; |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1660 | TargetSP target_sp(GetSP()); |
| 1661 | if (target_sp) |
Johnny Chen | 096c293 | 2011-09-26 22:40:50 +0000 | [diff] [blame] | 1662 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1663 | Mutex::Locker api_locker (target_sp->GetAPIMutex()); |
Johnny Chen | bbf6aa5 | 2012-05-31 22:56:36 +0000 | [diff] [blame] | 1664 | Mutex::Locker locker; |
| 1665 | target_sp->GetWatchpointList().GetListMutex(locker); |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1666 | result = target_sp->RemoveWatchpointByID (wp_id); |
Johnny Chen | 096c293 | 2011-09-26 22:40:50 +0000 | [diff] [blame] | 1667 | } |
| 1668 | |
| 1669 | if (log) |
| 1670 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1671 | log->Printf ("SBTarget(%p)::WatchpointDelete (wp_id=%d) => %i", target_sp.get(), (uint32_t) wp_id, result); |
Johnny Chen | 096c293 | 2011-09-26 22:40:50 +0000 | [diff] [blame] | 1672 | } |
| 1673 | |
| 1674 | return result; |
| 1675 | } |
| 1676 | |
Greg Clayton | 1fa6b3d | 2011-10-13 18:08:26 +0000 | [diff] [blame] | 1677 | SBWatchpoint |
| 1678 | SBTarget::FindWatchpointByID (lldb::watch_id_t wp_id) |
Johnny Chen | 096c293 | 2011-09-26 22:40:50 +0000 | [diff] [blame] | 1679 | { |
| 1680 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
| 1681 | |
Greg Clayton | 1fa6b3d | 2011-10-13 18:08:26 +0000 | [diff] [blame] | 1682 | SBWatchpoint sb_watchpoint; |
Greg Clayton | 0a19a1b | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 1683 | lldb::WatchpointSP watchpoint_sp; |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1684 | TargetSP target_sp(GetSP()); |
| 1685 | if (target_sp && wp_id != LLDB_INVALID_WATCH_ID) |
Johnny Chen | 096c293 | 2011-09-26 22:40:50 +0000 | [diff] [blame] | 1686 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1687 | Mutex::Locker api_locker (target_sp->GetAPIMutex()); |
Johnny Chen | bbf6aa5 | 2012-05-31 22:56:36 +0000 | [diff] [blame] | 1688 | Mutex::Locker locker; |
| 1689 | target_sp->GetWatchpointList().GetListMutex(locker); |
Greg Clayton | 0a19a1b | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 1690 | watchpoint_sp = target_sp->GetWatchpointList().FindByID(wp_id); |
| 1691 | sb_watchpoint.SetSP (watchpoint_sp); |
Johnny Chen | 096c293 | 2011-09-26 22:40:50 +0000 | [diff] [blame] | 1692 | } |
| 1693 | |
| 1694 | if (log) |
| 1695 | { |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 1696 | log->Printf ("SBTarget(%p)::FindWatchpointByID (bp_id=%d) => SBWatchpoint(%p)", |
Greg Clayton | 0a19a1b | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 1697 | target_sp.get(), (uint32_t) wp_id, watchpoint_sp.get()); |
Johnny Chen | 096c293 | 2011-09-26 22:40:50 +0000 | [diff] [blame] | 1698 | } |
| 1699 | |
Greg Clayton | 1fa6b3d | 2011-10-13 18:08:26 +0000 | [diff] [blame] | 1700 | return sb_watchpoint; |
| 1701 | } |
| 1702 | |
| 1703 | lldb::SBWatchpoint |
Johnny Chen | 3f88349 | 2012-06-04 23:19:54 +0000 | [diff] [blame] | 1704 | SBTarget::WatchAddress (lldb::addr_t addr, size_t size, bool read, bool write, SBError &error) |
Greg Clayton | 1fa6b3d | 2011-10-13 18:08:26 +0000 | [diff] [blame] | 1705 | { |
| 1706 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
| 1707 | |
| 1708 | SBWatchpoint sb_watchpoint; |
Greg Clayton | 0a19a1b | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 1709 | lldb::WatchpointSP watchpoint_sp; |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1710 | TargetSP target_sp(GetSP()); |
Greg Clayton | 0a19a1b | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 1711 | if (target_sp && (read || write) && addr != LLDB_INVALID_ADDRESS && size > 0) |
Greg Clayton | 1fa6b3d | 2011-10-13 18:08:26 +0000 | [diff] [blame] | 1712 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1713 | Mutex::Locker api_locker (target_sp->GetAPIMutex()); |
Greg Clayton | 0a19a1b | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 1714 | uint32_t watch_type = 0; |
| 1715 | if (read) |
| 1716 | watch_type |= LLDB_WATCH_TYPE_READ; |
| 1717 | if (write) |
| 1718 | watch_type |= LLDB_WATCH_TYPE_WRITE; |
Johnny Chen | bbf6aa5 | 2012-05-31 22:56:36 +0000 | [diff] [blame] | 1719 | // Target::CreateWatchpoint() is thread safe. |
Johnny Chen | 3f88349 | 2012-06-04 23:19:54 +0000 | [diff] [blame] | 1720 | Error cw_error; |
| 1721 | watchpoint_sp = target_sp->CreateWatchpoint(addr, size, watch_type, cw_error); |
| 1722 | error.SetError(cw_error); |
Greg Clayton | 0a19a1b | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 1723 | sb_watchpoint.SetSP (watchpoint_sp); |
Greg Clayton | 1fa6b3d | 2011-10-13 18:08:26 +0000 | [diff] [blame] | 1724 | } |
| 1725 | |
| 1726 | if (log) |
| 1727 | { |
| 1728 | log->Printf ("SBTarget(%p)::WatchAddress (addr=0x%llx, 0x%u) => SBWatchpoint(%p)", |
Greg Clayton | 0a19a1b | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 1729 | target_sp.get(), addr, (uint32_t) size, watchpoint_sp.get()); |
Greg Clayton | 1fa6b3d | 2011-10-13 18:08:26 +0000 | [diff] [blame] | 1730 | } |
| 1731 | |
| 1732 | return sb_watchpoint; |
Johnny Chen | 096c293 | 2011-09-26 22:40:50 +0000 | [diff] [blame] | 1733 | } |
| 1734 | |
| 1735 | bool |
Greg Clayton | 1fa6b3d | 2011-10-13 18:08:26 +0000 | [diff] [blame] | 1736 | SBTarget::EnableAllWatchpoints () |
Johnny Chen | 096c293 | 2011-09-26 22:40:50 +0000 | [diff] [blame] | 1737 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1738 | TargetSP target_sp(GetSP()); |
| 1739 | if (target_sp) |
Johnny Chen | 096c293 | 2011-09-26 22:40:50 +0000 | [diff] [blame] | 1740 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1741 | Mutex::Locker api_locker (target_sp->GetAPIMutex()); |
Johnny Chen | bbf6aa5 | 2012-05-31 22:56:36 +0000 | [diff] [blame] | 1742 | Mutex::Locker locker; |
| 1743 | target_sp->GetWatchpointList().GetListMutex(locker); |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1744 | target_sp->EnableAllWatchpoints (); |
Johnny Chen | 096c293 | 2011-09-26 22:40:50 +0000 | [diff] [blame] | 1745 | return true; |
| 1746 | } |
| 1747 | return false; |
| 1748 | } |
| 1749 | |
| 1750 | bool |
Greg Clayton | 1fa6b3d | 2011-10-13 18:08:26 +0000 | [diff] [blame] | 1751 | SBTarget::DisableAllWatchpoints () |
Johnny Chen | 096c293 | 2011-09-26 22:40:50 +0000 | [diff] [blame] | 1752 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1753 | TargetSP target_sp(GetSP()); |
| 1754 | if (target_sp) |
Johnny Chen | 096c293 | 2011-09-26 22:40:50 +0000 | [diff] [blame] | 1755 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1756 | Mutex::Locker api_locker (target_sp->GetAPIMutex()); |
Johnny Chen | bbf6aa5 | 2012-05-31 22:56:36 +0000 | [diff] [blame] | 1757 | Mutex::Locker locker; |
| 1758 | target_sp->GetWatchpointList().GetListMutex(locker); |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1759 | target_sp->DisableAllWatchpoints (); |
Johnny Chen | 096c293 | 2011-09-26 22:40:50 +0000 | [diff] [blame] | 1760 | return true; |
| 1761 | } |
| 1762 | return false; |
| 1763 | } |
| 1764 | |
| 1765 | bool |
Greg Clayton | 1fa6b3d | 2011-10-13 18:08:26 +0000 | [diff] [blame] | 1766 | SBTarget::DeleteAllWatchpoints () |
Johnny Chen | 096c293 | 2011-09-26 22:40:50 +0000 | [diff] [blame] | 1767 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1768 | TargetSP target_sp(GetSP()); |
| 1769 | if (target_sp) |
Johnny Chen | 096c293 | 2011-09-26 22:40:50 +0000 | [diff] [blame] | 1770 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1771 | Mutex::Locker api_locker (target_sp->GetAPIMutex()); |
Johnny Chen | bbf6aa5 | 2012-05-31 22:56:36 +0000 | [diff] [blame] | 1772 | Mutex::Locker locker; |
| 1773 | target_sp->GetWatchpointList().GetListMutex(locker); |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1774 | target_sp->RemoveAllWatchpoints (); |
Johnny Chen | 096c293 | 2011-09-26 22:40:50 +0000 | [diff] [blame] | 1775 | return true; |
| 1776 | } |
| 1777 | return false; |
| 1778 | } |
| 1779 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1780 | |
Greg Clayton | 3e8c25f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 1781 | lldb::SBModule |
| 1782 | SBTarget::AddModule (const char *path, |
| 1783 | const char *triple, |
| 1784 | const char *uuid_cstr) |
| 1785 | { |
Greg Clayton | f0bc815 | 2012-04-23 20:23:39 +0000 | [diff] [blame] | 1786 | return AddModule (path, triple, uuid_cstr, NULL); |
| 1787 | } |
| 1788 | |
| 1789 | lldb::SBModule |
| 1790 | SBTarget::AddModule (const char *path, |
| 1791 | const char *triple, |
| 1792 | const char *uuid_cstr, |
| 1793 | const char *symfile) |
| 1794 | { |
Greg Clayton | 3e8c25f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 1795 | lldb::SBModule sb_module; |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1796 | TargetSP target_sp(GetSP()); |
| 1797 | if (target_sp) |
Greg Clayton | 3e8c25f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 1798 | { |
Greg Clayton | 444fe99 | 2012-02-26 05:51:37 +0000 | [diff] [blame] | 1799 | ModuleSpec module_spec; |
Greg Clayton | 3e8c25f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 1800 | if (path) |
Greg Clayton | 444fe99 | 2012-02-26 05:51:37 +0000 | [diff] [blame] | 1801 | module_spec.GetFileSpec().SetFile(path, false); |
Greg Clayton | f0bc815 | 2012-04-23 20:23:39 +0000 | [diff] [blame] | 1802 | |
Greg Clayton | 3e8c25f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 1803 | if (uuid_cstr) |
Greg Clayton | 437b5bc | 2012-09-27 22:26:11 +0000 | [diff] [blame^] | 1804 | module_spec.GetUUID().SetFromCString(uuid_cstr); |
Greg Clayton | f0bc815 | 2012-04-23 20:23:39 +0000 | [diff] [blame] | 1805 | |
Greg Clayton | 3e8c25f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 1806 | if (triple) |
Greg Clayton | 444fe99 | 2012-02-26 05:51:37 +0000 | [diff] [blame] | 1807 | module_spec.GetArchitecture().SetTriple (triple, target_sp->GetPlatform ().get()); |
Greg Clayton | f0bc815 | 2012-04-23 20:23:39 +0000 | [diff] [blame] | 1808 | |
| 1809 | if (symfile) |
| 1810 | module_spec.GetSymbolFileSpec ().SetFile(symfile, false); |
Greg Clayton | 3e8c25f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 1811 | |
Greg Clayton | 444fe99 | 2012-02-26 05:51:37 +0000 | [diff] [blame] | 1812 | sb_module.SetSP(target_sp->GetSharedModule (module_spec)); |
Greg Clayton | 3e8c25f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 1813 | } |
| 1814 | return sb_module; |
| 1815 | } |
| 1816 | |
| 1817 | bool |
| 1818 | SBTarget::AddModule (lldb::SBModule &module) |
| 1819 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1820 | TargetSP target_sp(GetSP()); |
| 1821 | if (target_sp) |
Greg Clayton | 3e8c25f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 1822 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1823 | target_sp->GetImages().AppendIfNeeded (module.GetSP()); |
Greg Clayton | 3e8c25f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 1824 | return true; |
| 1825 | } |
| 1826 | return false; |
| 1827 | } |
| 1828 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1829 | uint32_t |
| 1830 | SBTarget::GetNumModules () const |
| 1831 | { |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 1832 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 1833 | |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 1834 | uint32_t num = 0; |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1835 | TargetSP target_sp(GetSP()); |
| 1836 | if (target_sp) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 1837 | { |
| 1838 | // The module list is thread safe, no need to lock |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1839 | num = target_sp->GetImages().GetSize(); |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 1840 | } |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 1841 | |
| 1842 | if (log) |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1843 | log->Printf ("SBTarget(%p)::GetNumModules () => %d", target_sp.get(), num); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 1844 | |
| 1845 | return num; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1846 | } |
| 1847 | |
Greg Clayton | 43490d1 | 2010-07-30 20:12:55 +0000 | [diff] [blame] | 1848 | void |
| 1849 | SBTarget::Clear () |
| 1850 | { |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 1851 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 1852 | |
| 1853 | if (log) |
Greg Clayton | 3f5ee7f | 2010-10-29 04:59:35 +0000 | [diff] [blame] | 1854 | log->Printf ("SBTarget(%p)::Clear ()", m_opaque_sp.get()); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 1855 | |
Greg Clayton | 43490d1 | 2010-07-30 20:12:55 +0000 | [diff] [blame] | 1856 | m_opaque_sp.reset(); |
| 1857 | } |
| 1858 | |
| 1859 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1860 | SBModule |
| 1861 | SBTarget::FindModule (const SBFileSpec &sb_file_spec) |
| 1862 | { |
| 1863 | SBModule sb_module; |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1864 | TargetSP target_sp(GetSP()); |
| 1865 | if (target_sp && sb_file_spec.IsValid()) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 1866 | { |
Greg Clayton | 444fe99 | 2012-02-26 05:51:37 +0000 | [diff] [blame] | 1867 | ModuleSpec module_spec(*sb_file_spec); |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 1868 | // The module list is thread safe, no need to lock |
Greg Clayton | 444fe99 | 2012-02-26 05:51:37 +0000 | [diff] [blame] | 1869 | sb_module.SetSP (target_sp->GetImages().FindFirstModule (module_spec)); |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 1870 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1871 | return sb_module; |
| 1872 | } |
| 1873 | |
Greg Clayton | 1b92520 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 1874 | lldb::ByteOrder |
| 1875 | SBTarget::GetByteOrder () |
| 1876 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1877 | TargetSP target_sp(GetSP()); |
| 1878 | if (target_sp) |
| 1879 | return target_sp->GetArchitecture().GetByteOrder(); |
Greg Clayton | 1b92520 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 1880 | return eByteOrderInvalid; |
| 1881 | } |
| 1882 | |
| 1883 | const char * |
| 1884 | SBTarget::GetTriple () |
| 1885 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1886 | TargetSP target_sp(GetSP()); |
| 1887 | if (target_sp) |
Greg Clayton | 1b92520 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 1888 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1889 | std::string triple (target_sp->GetArchitecture().GetTriple().str()); |
Greg Clayton | 1b92520 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 1890 | // Unique the string so we don't run into ownership issues since |
| 1891 | // the const strings put the string into the string pool once and |
| 1892 | // the strings never comes out |
| 1893 | ConstString const_triple (triple.c_str()); |
| 1894 | return const_triple.GetCString(); |
| 1895 | } |
| 1896 | return NULL; |
| 1897 | } |
| 1898 | |
| 1899 | uint32_t |
| 1900 | SBTarget::GetAddressByteSize() |
| 1901 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1902 | TargetSP target_sp(GetSP()); |
| 1903 | if (target_sp) |
| 1904 | return target_sp->GetArchitecture().GetAddressByteSize(); |
Greg Clayton | 1b92520 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 1905 | return sizeof(void*); |
| 1906 | } |
| 1907 | |
| 1908 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1909 | SBModule |
| 1910 | SBTarget::GetModuleAtIndex (uint32_t idx) |
| 1911 | { |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 1912 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 1913 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1914 | SBModule sb_module; |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1915 | ModuleSP module_sp; |
| 1916 | TargetSP target_sp(GetSP()); |
| 1917 | if (target_sp) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 1918 | { |
| 1919 | // The module list is thread safe, no need to lock |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1920 | module_sp = target_sp->GetImages().GetModuleAtIndex(idx); |
| 1921 | sb_module.SetSP (module_sp); |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 1922 | } |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 1923 | |
| 1924 | if (log) |
| 1925 | { |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 1926 | log->Printf ("SBTarget(%p)::GetModuleAtIndex (idx=%d) => SBModule(%p)", |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1927 | target_sp.get(), idx, module_sp.get()); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 1928 | } |
| 1929 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1930 | return sb_module; |
| 1931 | } |
| 1932 | |
Greg Clayton | 3e8c25f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 1933 | bool |
| 1934 | SBTarget::RemoveModule (lldb::SBModule module) |
| 1935 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1936 | TargetSP target_sp(GetSP()); |
| 1937 | if (target_sp) |
| 1938 | return target_sp->GetImages().Remove(module.GetSP()); |
Greg Clayton | 3e8c25f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 1939 | return false; |
| 1940 | } |
| 1941 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1942 | |
| 1943 | SBBroadcaster |
| 1944 | SBTarget::GetBroadcaster () const |
| 1945 | { |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 1946 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 1947 | |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1948 | TargetSP target_sp(GetSP()); |
| 1949 | SBBroadcaster broadcaster(target_sp.get(), false); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 1950 | |
| 1951 | if (log) |
Greg Clayton | 3f5ee7f | 2010-10-29 04:59:35 +0000 | [diff] [blame] | 1952 | log->Printf ("SBTarget(%p)::GetBroadcaster () => SBBroadcaster(%p)", |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1953 | target_sp.get(), broadcaster.get()); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 1954 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1955 | return broadcaster; |
| 1956 | } |
| 1957 | |
Caroline Tice | 98f930f | 2010-09-20 05:20:02 +0000 | [diff] [blame] | 1958 | bool |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 1959 | SBTarget::GetDescription (SBStream &description, lldb::DescriptionLevel description_level) |
Caroline Tice | 98f930f | 2010-09-20 05:20:02 +0000 | [diff] [blame] | 1960 | { |
Greg Clayton | 96154be | 2011-11-13 06:57:31 +0000 | [diff] [blame] | 1961 | Stream &strm = description.ref(); |
| 1962 | |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1963 | TargetSP target_sp(GetSP()); |
| 1964 | if (target_sp) |
Caroline Tice | e7a566e | 2010-09-20 16:21:41 +0000 | [diff] [blame] | 1965 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1966 | target_sp->Dump (&strm, description_level); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 1967 | } |
| 1968 | else |
Greg Clayton | 96154be | 2011-11-13 06:57:31 +0000 | [diff] [blame] | 1969 | strm.PutCString ("No value"); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 1970 | |
| 1971 | return true; |
| 1972 | } |
| 1973 | |
Greg Clayton | 7dd5c51 | 2012-02-06 01:44:54 +0000 | [diff] [blame] | 1974 | lldb::SBSymbolContextList |
| 1975 | SBTarget::FindFunctions (const char *name, uint32_t name_type_mask) |
Greg Clayton | 4ed315f | 2011-06-21 01:34:41 +0000 | [diff] [blame] | 1976 | { |
Greg Clayton | 7dd5c51 | 2012-02-06 01:44:54 +0000 | [diff] [blame] | 1977 | lldb::SBSymbolContextList sb_sc_list; |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1978 | if (name && name[0]) |
Greg Clayton | 4ed315f | 2011-06-21 01:34:41 +0000 | [diff] [blame] | 1979 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1980 | TargetSP target_sp(GetSP()); |
| 1981 | if (target_sp) |
| 1982 | { |
| 1983 | const bool symbols_ok = true; |
Sean Callanan | 302d78c | 2012-02-10 22:52:19 +0000 | [diff] [blame] | 1984 | const bool inlines_ok = true; |
Greg Clayton | 7dd5c51 | 2012-02-06 01:44:54 +0000 | [diff] [blame] | 1985 | const bool append = true; |
| 1986 | target_sp->GetImages().FindFunctions (ConstString(name), |
| 1987 | name_type_mask, |
Sean Callanan | 302d78c | 2012-02-10 22:52:19 +0000 | [diff] [blame] | 1988 | symbols_ok, |
| 1989 | inlines_ok, |
Greg Clayton | 7dd5c51 | 2012-02-06 01:44:54 +0000 | [diff] [blame] | 1990 | append, |
| 1991 | *sb_sc_list); |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 1992 | } |
Greg Clayton | 4ed315f | 2011-06-21 01:34:41 +0000 | [diff] [blame] | 1993 | } |
Greg Clayton | 7dd5c51 | 2012-02-06 01:44:54 +0000 | [diff] [blame] | 1994 | return sb_sc_list; |
Greg Clayton | 4ed315f | 2011-06-21 01:34:41 +0000 | [diff] [blame] | 1995 | } |
| 1996 | |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 1997 | lldb::SBType |
| 1998 | SBTarget::FindFirstType (const char* type) |
| 1999 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 2000 | TargetSP target_sp(GetSP()); |
| 2001 | if (type && target_sp) |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 2002 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 2003 | size_t count = target_sp->GetImages().GetSize(); |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 2004 | for (size_t idx = 0; idx < count; idx++) |
| 2005 | { |
| 2006 | SBType found_at_idx = GetModuleAtIndex(idx).FindFirstType(type); |
| 2007 | |
| 2008 | if (found_at_idx.IsValid()) |
| 2009 | return found_at_idx; |
| 2010 | } |
| 2011 | } |
| 2012 | return SBType(); |
| 2013 | } |
| 2014 | |
| 2015 | lldb::SBTypeList |
| 2016 | SBTarget::FindTypes (const char* type) |
| 2017 | { |
| 2018 | |
| 2019 | SBTypeList retval; |
| 2020 | |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 2021 | TargetSP target_sp(GetSP()); |
| 2022 | if (type && target_sp) |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 2023 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 2024 | ModuleList& images = target_sp->GetImages(); |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 2025 | ConstString name_const(type); |
Greg Clayton | dc0a38c | 2012-03-26 23:03:23 +0000 | [diff] [blame] | 2026 | bool exact_match = false; |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 2027 | SymbolContext sc; |
| 2028 | TypeList type_list; |
| 2029 | |
Greg Clayton | 9f95fb6 | 2012-04-06 17:41:13 +0000 | [diff] [blame] | 2030 | uint32_t num_matches = images.FindTypes (sc, |
Greg Clayton | dc0a38c | 2012-03-26 23:03:23 +0000 | [diff] [blame] | 2031 | name_const, |
| 2032 | exact_match, |
| 2033 | UINT32_MAX, |
| 2034 | type_list); |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 2035 | |
| 2036 | for (size_t idx = 0; idx < num_matches; idx++) |
| 2037 | { |
Greg Clayton | 0fb0bcc | 2011-08-03 22:57:10 +0000 | [diff] [blame] | 2038 | TypeSP type_sp (type_list.GetTypeAtIndex(idx)); |
| 2039 | if (type_sp) |
| 2040 | retval.Append(SBType(type_sp)); |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 2041 | } |
| 2042 | } |
| 2043 | return retval; |
| 2044 | } |
| 2045 | |
Greg Clayton | 917c000 | 2011-06-29 22:09:02 +0000 | [diff] [blame] | 2046 | SBValueList |
| 2047 | SBTarget::FindGlobalVariables (const char *name, uint32_t max_matches) |
| 2048 | { |
| 2049 | SBValueList sb_value_list; |
| 2050 | |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 2051 | TargetSP target_sp(GetSP()); |
| 2052 | if (name && target_sp) |
Greg Clayton | 917c000 | 2011-06-29 22:09:02 +0000 | [diff] [blame] | 2053 | { |
| 2054 | VariableList variable_list; |
| 2055 | const bool append = true; |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 2056 | const uint32_t match_count = target_sp->GetImages().FindGlobalVariables (ConstString (name), |
| 2057 | append, |
| 2058 | max_matches, |
| 2059 | variable_list); |
Greg Clayton | 917c000 | 2011-06-29 22:09:02 +0000 | [diff] [blame] | 2060 | |
| 2061 | if (match_count > 0) |
| 2062 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 2063 | ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get(); |
Greg Clayton | 917c000 | 2011-06-29 22:09:02 +0000 | [diff] [blame] | 2064 | if (exe_scope == NULL) |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 2065 | exe_scope = target_sp.get(); |
Greg Clayton | 917c000 | 2011-06-29 22:09:02 +0000 | [diff] [blame] | 2066 | ValueObjectList &value_object_list = sb_value_list.ref(); |
| 2067 | for (uint32_t i=0; i<match_count; ++i) |
| 2068 | { |
| 2069 | lldb::ValueObjectSP valobj_sp (ValueObjectVariable::Create (exe_scope, variable_list.GetVariableAtIndex(i))); |
| 2070 | if (valobj_sp) |
| 2071 | value_object_list.Append(valobj_sp); |
| 2072 | } |
| 2073 | } |
| 2074 | } |
| 2075 | |
| 2076 | return sb_value_list; |
| 2077 | } |
| 2078 | |
Jim Ingham | cc63746 | 2011-09-13 00:29:56 +0000 | [diff] [blame] | 2079 | SBSourceManager |
| 2080 | SBTarget::GetSourceManager() |
| 2081 | { |
| 2082 | SBSourceManager source_manager (*this); |
| 2083 | return source_manager; |
| 2084 | } |
Greg Clayton | 3e8c25f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 2085 | |
Sean Callanan | ef1f690 | 2011-12-14 23:49:37 +0000 | [diff] [blame] | 2086 | lldb::SBInstructionList |
Greg Clayton | a989307 | 2012-03-06 22:24:44 +0000 | [diff] [blame] | 2087 | SBTarget::ReadInstructions (lldb::SBAddress base_addr, uint32_t count) |
| 2088 | { |
| 2089 | SBInstructionList sb_instructions; |
| 2090 | |
| 2091 | TargetSP target_sp(GetSP()); |
| 2092 | if (target_sp) |
| 2093 | { |
| 2094 | Address *addr_ptr = base_addr.get(); |
| 2095 | |
| 2096 | if (addr_ptr) |
| 2097 | { |
| 2098 | DataBufferHeap data (target_sp->GetArchitecture().GetMaximumOpcodeByteSize() * count, 0); |
| 2099 | bool prefer_file_cache = false; |
| 2100 | lldb_private::Error error; |
| 2101 | const size_t bytes_read = target_sp->ReadMemory(*addr_ptr, prefer_file_cache, data.GetBytes(), data.GetByteSize(), error); |
| 2102 | sb_instructions.SetDisassembler (Disassembler::DisassembleBytes (target_sp->GetArchitecture(), |
| 2103 | NULL, |
| 2104 | *addr_ptr, |
| 2105 | data.GetBytes(), |
| 2106 | bytes_read, |
| 2107 | count)); |
| 2108 | } |
| 2109 | } |
| 2110 | |
| 2111 | return sb_instructions; |
| 2112 | |
| 2113 | } |
| 2114 | |
| 2115 | lldb::SBInstructionList |
Sean Callanan | ef1f690 | 2011-12-14 23:49:37 +0000 | [diff] [blame] | 2116 | SBTarget::GetInstructions (lldb::SBAddress base_addr, const void *buf, size_t size) |
| 2117 | { |
| 2118 | SBInstructionList sb_instructions; |
| 2119 | |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 2120 | TargetSP target_sp(GetSP()); |
| 2121 | if (target_sp) |
Sean Callanan | ef1f690 | 2011-12-14 23:49:37 +0000 | [diff] [blame] | 2122 | { |
| 2123 | Address addr; |
| 2124 | |
| 2125 | if (base_addr.get()) |
| 2126 | addr = *base_addr.get(); |
| 2127 | |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 2128 | sb_instructions.SetDisassembler (Disassembler::DisassembleBytes (target_sp->GetArchitecture(), |
Sean Callanan | ef1f690 | 2011-12-14 23:49:37 +0000 | [diff] [blame] | 2129 | NULL, |
| 2130 | addr, |
| 2131 | buf, |
| 2132 | size)); |
| 2133 | } |
| 2134 | |
| 2135 | return sb_instructions; |
| 2136 | } |
| 2137 | |
| 2138 | lldb::SBInstructionList |
| 2139 | SBTarget::GetInstructions (lldb::addr_t base_addr, const void *buf, size_t size) |
| 2140 | { |
| 2141 | return GetInstructions (ResolveLoadAddress(base_addr), buf, size); |
| 2142 | } |
Greg Clayton | 3e8c25f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 2143 | |
| 2144 | SBError |
| 2145 | SBTarget::SetSectionLoadAddress (lldb::SBSection section, |
| 2146 | lldb::addr_t section_base_addr) |
| 2147 | { |
| 2148 | SBError sb_error; |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 2149 | TargetSP target_sp(GetSP()); |
| 2150 | if (target_sp) |
Greg Clayton | 3e8c25f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 2151 | { |
| 2152 | if (!section.IsValid()) |
| 2153 | { |
| 2154 | sb_error.SetErrorStringWithFormat ("invalid section"); |
| 2155 | } |
| 2156 | else |
| 2157 | { |
Greg Clayton | 9ab696e | 2012-03-27 21:10:07 +0000 | [diff] [blame] | 2158 | SectionSP section_sp (section.GetSP()); |
| 2159 | if (section_sp) |
| 2160 | { |
| 2161 | if (section_sp->IsThreadSpecific()) |
| 2162 | { |
| 2163 | sb_error.SetErrorString ("thread specific sections are not yet supported"); |
| 2164 | } |
| 2165 | else |
| 2166 | { |
Greg Clayton | 545762f | 2012-07-07 01:24:12 +0000 | [diff] [blame] | 2167 | target_sp->GetSectionLoadList().SetSectionLoadAddress (section_sp, section_base_addr); |
Greg Clayton | 9ab696e | 2012-03-27 21:10:07 +0000 | [diff] [blame] | 2168 | } |
| 2169 | } |
Greg Clayton | 3e8c25f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 2170 | } |
| 2171 | } |
| 2172 | else |
| 2173 | { |
Greg Clayton | 9ab696e | 2012-03-27 21:10:07 +0000 | [diff] [blame] | 2174 | sb_error.SetErrorString ("invalid target"); |
Greg Clayton | 3e8c25f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 2175 | } |
| 2176 | return sb_error; |
| 2177 | } |
| 2178 | |
| 2179 | SBError |
| 2180 | SBTarget::ClearSectionLoadAddress (lldb::SBSection section) |
| 2181 | { |
| 2182 | SBError sb_error; |
| 2183 | |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 2184 | TargetSP target_sp(GetSP()); |
| 2185 | if (target_sp) |
Greg Clayton | 3e8c25f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 2186 | { |
| 2187 | if (!section.IsValid()) |
| 2188 | { |
| 2189 | sb_error.SetErrorStringWithFormat ("invalid section"); |
| 2190 | } |
| 2191 | else |
| 2192 | { |
Greg Clayton | 545762f | 2012-07-07 01:24:12 +0000 | [diff] [blame] | 2193 | target_sp->GetSectionLoadList().SetSectionUnloaded (section.GetSP()); |
Greg Clayton | 3e8c25f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 2194 | } |
| 2195 | } |
| 2196 | else |
| 2197 | { |
| 2198 | sb_error.SetErrorStringWithFormat ("invalid target"); |
| 2199 | } |
| 2200 | return sb_error; |
| 2201 | } |
| 2202 | |
| 2203 | SBError |
| 2204 | SBTarget::SetModuleLoadAddress (lldb::SBModule module, int64_t slide_offset) |
| 2205 | { |
| 2206 | SBError sb_error; |
| 2207 | |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 2208 | TargetSP target_sp(GetSP()); |
| 2209 | if (target_sp) |
Greg Clayton | 3e8c25f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 2210 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 2211 | ModuleSP module_sp (module.GetSP()); |
| 2212 | if (module_sp) |
Greg Clayton | 3e8c25f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 2213 | { |
Greg Clayton | 9ab696e | 2012-03-27 21:10:07 +0000 | [diff] [blame] | 2214 | bool changed = false; |
| 2215 | if (module_sp->SetLoadAddress (*target_sp, slide_offset, changed)) |
Greg Clayton | 3e8c25f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 2216 | { |
Greg Clayton | 9ab696e | 2012-03-27 21:10:07 +0000 | [diff] [blame] | 2217 | // The load was successful, make sure that at least some sections |
| 2218 | // changed before we notify that our module was loaded. |
| 2219 | if (changed) |
Greg Clayton | 3e8c25f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 2220 | { |
Greg Clayton | 9ab696e | 2012-03-27 21:10:07 +0000 | [diff] [blame] | 2221 | ModuleList module_list; |
| 2222 | module_list.Append(module_sp); |
| 2223 | target_sp->ModulesDidLoad (module_list); |
Greg Clayton | 3e8c25f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 2224 | } |
Greg Clayton | 3e8c25f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 2225 | } |
| 2226 | } |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 2227 | else |
| 2228 | { |
| 2229 | sb_error.SetErrorStringWithFormat ("invalid module"); |
| 2230 | } |
| 2231 | |
Greg Clayton | 3e8c25f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 2232 | } |
| 2233 | else |
| 2234 | { |
| 2235 | sb_error.SetErrorStringWithFormat ("invalid target"); |
| 2236 | } |
| 2237 | return sb_error; |
| 2238 | } |
| 2239 | |
| 2240 | SBError |
| 2241 | SBTarget::ClearModuleLoadAddress (lldb::SBModule module) |
| 2242 | { |
| 2243 | SBError sb_error; |
| 2244 | |
| 2245 | char path[PATH_MAX]; |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 2246 | TargetSP target_sp(GetSP()); |
| 2247 | if (target_sp) |
Greg Clayton | 3e8c25f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 2248 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 2249 | ModuleSP module_sp (module.GetSP()); |
| 2250 | if (module_sp) |
Greg Clayton | 3e8c25f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 2251 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 2252 | ObjectFile *objfile = module_sp->GetObjectFile(); |
Greg Clayton | 3e8c25f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 2253 | if (objfile) |
| 2254 | { |
| 2255 | SectionList *section_list = objfile->GetSectionList(); |
| 2256 | if (section_list) |
| 2257 | { |
| 2258 | const size_t num_sections = section_list->GetSize(); |
| 2259 | for (size_t sect_idx = 0; sect_idx < num_sections; ++sect_idx) |
| 2260 | { |
| 2261 | SectionSP section_sp (section_list->GetSectionAtIndex(sect_idx)); |
| 2262 | if (section_sp) |
Greg Clayton | 545762f | 2012-07-07 01:24:12 +0000 | [diff] [blame] | 2263 | target_sp->GetSectionLoadList().SetSectionUnloaded (section_sp); |
Greg Clayton | 3e8c25f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 2264 | } |
| 2265 | } |
| 2266 | else |
| 2267 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 2268 | module_sp->GetFileSpec().GetPath (path, sizeof(path)); |
Greg Clayton | 3e8c25f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 2269 | sb_error.SetErrorStringWithFormat ("no sections in object file '%s'", path); |
| 2270 | } |
| 2271 | } |
| 2272 | else |
| 2273 | { |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 2274 | module_sp->GetFileSpec().GetPath (path, sizeof(path)); |
Greg Clayton | 3e8c25f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 2275 | sb_error.SetErrorStringWithFormat ("no object file for module '%s'", path); |
| 2276 | } |
| 2277 | } |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 2278 | else |
| 2279 | { |
| 2280 | sb_error.SetErrorStringWithFormat ("invalid module"); |
| 2281 | } |
Greg Clayton | 3e8c25f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 2282 | } |
| 2283 | else |
| 2284 | { |
| 2285 | sb_error.SetErrorStringWithFormat ("invalid target"); |
| 2286 | } |
| 2287 | return sb_error; |
| 2288 | } |
| 2289 | |
| 2290 | |