blob: 27da3aa9186d7f52b7dd4bdf5cda724ce806ce56 [file] [log] [blame]
Chris Lattner24943d22010-06-08 16:52:24 +00001//===-- 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 Friedman7a62c8b2010-06-09 07:44:37 +000010#include "lldb/API/SBTarget.h"
Chris Lattner24943d22010-06-08 16:52:24 +000011
12#include "lldb/lldb-include.h"
13
14#include "lldb/API/SBFileSpec.h"
15#include "lldb/API/SBModule.h"
Caroline Tice98f930f2010-09-20 05:20:02 +000016#include "lldb/API/SBStream.h"
Chris Lattner24943d22010-06-08 16:52:24 +000017#include "lldb/Breakpoint/BreakpointID.h"
18#include "lldb/Breakpoint/BreakpointIDList.h"
19#include "lldb/Breakpoint/BreakpointList.h"
20#include "lldb/Breakpoint/BreakpointLocation.h"
21#include "lldb/Core/Address.h"
22#include "lldb/Core/AddressResolver.h"
23#include "lldb/Core/AddressResolverName.h"
Jim Ingham84cdc152010-06-15 19:49:27 +000024#include "lldb/Interpreter/Args.h"
Chris Lattner24943d22010-06-08 16:52:24 +000025#include "lldb/Core/ArchSpec.h"
26#include "lldb/Core/Debugger.h"
27#include "lldb/Core/Disassembler.h"
28#include "lldb/Core/FileSpec.h"
29#include "lldb/Core/RegularExpression.h"
30#include "lldb/Core/SearchFilter.h"
31#include "lldb/Core/STLUtils.h"
32#include "lldb/Target/Process.h"
33#include "lldb/Target/Target.h"
34#include "lldb/Target/TargetList.h"
35
36#include "lldb/Interpreter/CommandReturnObject.h"
37#include "../source/Commands/CommandObjectBreakpoint.h"
38
Eli Friedman7a62c8b2010-06-09 07:44:37 +000039#include "lldb/API/SBDebugger.h"
40#include "lldb/API/SBProcess.h"
41#include "lldb/API/SBListener.h"
42#include "lldb/API/SBBreakpoint.h"
Chris Lattner24943d22010-06-08 16:52:24 +000043
44using namespace lldb;
45using namespace lldb_private;
46
47#define DEFAULT_DISASM_BYTE_SIZE 32
48
49//----------------------------------------------------------------------
50// SBTarget constructor
51//----------------------------------------------------------------------
52SBTarget::SBTarget ()
53{
54}
55
56SBTarget::SBTarget (const SBTarget& rhs) :
Greg Clayton63094e02010-06-23 01:19:29 +000057 m_opaque_sp (rhs.m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +000058{
59}
60
61SBTarget::SBTarget(const TargetSP& target_sp) :
Greg Clayton63094e02010-06-23 01:19:29 +000062 m_opaque_sp (target_sp)
Chris Lattner24943d22010-06-08 16:52:24 +000063{
64}
65
66const SBTarget&
67SBTarget::Assign (const SBTarget& rhs)
68{
69 if (this != &rhs)
70 {
Greg Clayton63094e02010-06-23 01:19:29 +000071 m_opaque_sp = rhs.m_opaque_sp;
Chris Lattner24943d22010-06-08 16:52:24 +000072 }
73 return *this;
74}
75
76
77//----------------------------------------------------------------------
78// Destructor
79//----------------------------------------------------------------------
80SBTarget::~SBTarget()
81{
82}
83
84bool
85SBTarget::IsValid () const
86{
Greg Clayton63094e02010-06-23 01:19:29 +000087 return m_opaque_sp.get() != NULL;
Chris Lattner24943d22010-06-08 16:52:24 +000088}
89
90SBProcess
91SBTarget::GetProcess ()
92{
93 SBProcess sb_process;
Greg Clayton63094e02010-06-23 01:19:29 +000094 if (m_opaque_sp)
95 sb_process.SetProcess (m_opaque_sp->GetProcessSP());
Chris Lattner24943d22010-06-08 16:52:24 +000096 return sb_process;
97}
98
Greg Clayton63094e02010-06-23 01:19:29 +000099SBDebugger
100SBTarget::GetDebugger () const
101{
102 SBDebugger debugger;
103 if (m_opaque_sp)
104 debugger.reset (m_opaque_sp->GetDebugger().GetSP());
105 return debugger;
106}
107
Greg Clayton992ce262010-10-06 18:44:26 +0000108
109// DEPRECATED
110SBProcess
111SBTarget::CreateProcess ()
112{
113 SBProcess sb_process;
114
115 if (m_opaque_sp)
116 sb_process.SetProcess (m_opaque_sp->CreateProcess (m_opaque_sp->GetDebugger().GetListener()));
117
118 return sb_process;
119}
120
121
Chris Lattner24943d22010-06-08 16:52:24 +0000122SBProcess
Chris Lattner24943d22010-06-08 16:52:24 +0000123SBTarget::LaunchProcess
124(
125 char const **argv,
126 char const **envp,
127 const char *tty,
Greg Clayton452bf612010-08-31 18:35:14 +0000128 uint32_t launch_flags,
Chris Lattner24943d22010-06-08 16:52:24 +0000129 bool stop_at_entry
130)
131{
Greg Clayton1a3083a2010-10-06 03:53:16 +0000132 SBProcess sb_process;
133 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000134 {
Greg Clayton992ce262010-10-06 18:44:26 +0000135 // DEPRECATED, this will change when CreateProcess is removed...
136 if (m_opaque_sp->GetProcessSP())
137 {
138 sb_process.SetProcess(m_opaque_sp->GetProcessSP());
139 }
140 else
141 {
142 // When launching, we always want to create a new process When
143 // SBTarget::CreateProcess is removed, this will always happen.
144 sb_process.SetProcess (m_opaque_sp->CreateProcess (m_opaque_sp->GetDebugger().GetListener()));
145 }
Greg Clayton1a3083a2010-10-06 03:53:16 +0000146
147 if (sb_process.IsValid())
Chris Lattner24943d22010-06-08 16:52:24 +0000148 {
Greg Clayton1a3083a2010-10-06 03:53:16 +0000149 Error error (sb_process->Launch (argv, envp, launch_flags, tty, tty, tty));
150 if (error.Success())
Chris Lattner24943d22010-06-08 16:52:24 +0000151 {
Greg Clayton1a3083a2010-10-06 03:53:16 +0000152 // We we are stopping at the entry point, we can return now!
153 if (stop_at_entry)
154 return sb_process;
155
156 // Make sure we are stopped at the entry
157 StateType state = sb_process->WaitForProcessToStop (NULL);
Chris Lattner24943d22010-06-08 16:52:24 +0000158 if (state == eStateStopped)
Greg Clayton1a3083a2010-10-06 03:53:16 +0000159 {
160 // resume the process to skip the entry point
161 error = sb_process->Resume();
162 if (error.Success())
163 {
164 // If we are doing synchronous mode, then wait for the
165 // process to stop yet again!
166 if (m_opaque_sp->GetDebugger().GetAsyncExecution () == false)
167 sb_process->WaitForProcessToStop (NULL);
168 }
169 }
Chris Lattner24943d22010-06-08 16:52:24 +0000170 }
171 }
172 }
Greg Clayton1a3083a2010-10-06 03:53:16 +0000173 return sb_process;
Chris Lattner24943d22010-06-08 16:52:24 +0000174}
175
176SBFileSpec
177SBTarget::GetExecutable ()
178{
179 SBFileSpec exe_file_spec;
Greg Clayton63094e02010-06-23 01:19:29 +0000180 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000181 {
Greg Clayton63094e02010-06-23 01:19:29 +0000182 ModuleSP exe_module_sp (m_opaque_sp->GetExecutableModule ());
Chris Lattner24943d22010-06-08 16:52:24 +0000183 if (exe_module_sp)
184 exe_file_spec.SetFileSpec (exe_module_sp->GetFileSpec());
185 }
186 return exe_file_spec;
187}
188
189
190bool
191SBTarget::DeleteTargetFromList (TargetList *list)
192{
Greg Clayton63094e02010-06-23 01:19:29 +0000193 if (m_opaque_sp)
194 return list->DeleteTarget (m_opaque_sp);
Chris Lattner24943d22010-06-08 16:52:24 +0000195 else
196 return false;
197}
198
199bool
Chris Lattner24943d22010-06-08 16:52:24 +0000200SBTarget::operator == (const SBTarget &rhs) const
201{
Greg Clayton63094e02010-06-23 01:19:29 +0000202 return m_opaque_sp.get() == rhs.m_opaque_sp.get();
Chris Lattner24943d22010-06-08 16:52:24 +0000203}
204
205bool
206SBTarget::operator != (const SBTarget &rhs) const
207{
Greg Clayton63094e02010-06-23 01:19:29 +0000208 return m_opaque_sp.get() != rhs.m_opaque_sp.get();
Chris Lattner24943d22010-06-08 16:52:24 +0000209}
210
211lldb_private::Target *
Greg Clayton63094e02010-06-23 01:19:29 +0000212SBTarget::operator ->() const
Chris Lattner24943d22010-06-08 16:52:24 +0000213{
Greg Clayton63094e02010-06-23 01:19:29 +0000214 return m_opaque_sp.get();
Chris Lattner24943d22010-06-08 16:52:24 +0000215}
Greg Clayton63094e02010-06-23 01:19:29 +0000216
217lldb_private::Target *
218SBTarget::get() const
Chris Lattner24943d22010-06-08 16:52:24 +0000219{
Greg Clayton63094e02010-06-23 01:19:29 +0000220 return m_opaque_sp.get();
221}
222
223void
224SBTarget::reset (const lldb::TargetSP& target_sp)
225{
226 m_opaque_sp = target_sp;
Chris Lattner24943d22010-06-08 16:52:24 +0000227}
228
229SBBreakpoint
230SBTarget::BreakpointCreateByLocation (const char *file, uint32_t line)
231{
232 SBBreakpoint sb_bp;
233 if (file != NULL && line != 0)
234 sb_bp = BreakpointCreateByLocation (SBFileSpec (file), line);
235 return sb_bp;
236}
237
238SBBreakpoint
239SBTarget::BreakpointCreateByLocation (const SBFileSpec &sb_file_spec, uint32_t line)
240{
241 SBBreakpoint sb_bp;
Greg Clayton63094e02010-06-23 01:19:29 +0000242 if (m_opaque_sp.get() && line != 0)
243 *sb_bp = m_opaque_sp->CreateBreakpoint (NULL, *sb_file_spec, line, true, false);
Chris Lattner24943d22010-06-08 16:52:24 +0000244 return sb_bp;
245}
246
247SBBreakpoint
248SBTarget::BreakpointCreateByName (const char *symbol_name, const char *module_name)
249{
250 SBBreakpoint sb_bp;
Greg Clayton63094e02010-06-23 01:19:29 +0000251 if (m_opaque_sp.get() && symbol_name && symbol_name[0])
Chris Lattner24943d22010-06-08 16:52:24 +0000252 {
253 if (module_name && module_name[0])
254 {
255 FileSpec module_file_spec(module_name);
Jim Ingham7ec03bd2010-09-30 21:21:43 +0000256 *sb_bp = m_opaque_sp->CreateBreakpoint (&module_file_spec, symbol_name, eFunctionNameTypeFull | eFunctionNameTypeBase, false);
Chris Lattner24943d22010-06-08 16:52:24 +0000257 }
258 else
259 {
Jim Ingham7ec03bd2010-09-30 21:21:43 +0000260 *sb_bp = m_opaque_sp->CreateBreakpoint (NULL, symbol_name, eFunctionNameTypeFull | eFunctionNameTypeBase, false);
Chris Lattner24943d22010-06-08 16:52:24 +0000261 }
262 }
263 return sb_bp;
264}
265
266SBBreakpoint
267SBTarget::BreakpointCreateByRegex (const char *symbol_name_regex, const char *module_name)
268{
269 SBBreakpoint sb_bp;
Greg Clayton63094e02010-06-23 01:19:29 +0000270 if (m_opaque_sp.get() && symbol_name_regex && symbol_name_regex[0])
Chris Lattner24943d22010-06-08 16:52:24 +0000271 {
272 RegularExpression regexp(symbol_name_regex);
273
274 if (module_name && module_name[0])
275 {
276 FileSpec module_file_spec(module_name);
277
Greg Clayton63094e02010-06-23 01:19:29 +0000278 *sb_bp = m_opaque_sp->CreateBreakpoint (&module_file_spec, regexp, false);
Chris Lattner24943d22010-06-08 16:52:24 +0000279 }
280 else
281 {
Greg Clayton63094e02010-06-23 01:19:29 +0000282 *sb_bp = m_opaque_sp->CreateBreakpoint (NULL, regexp, false);
Chris Lattner24943d22010-06-08 16:52:24 +0000283 }
284 }
285 return sb_bp;
286}
287
288
289
290SBBreakpoint
291SBTarget::BreakpointCreateByAddress (addr_t address)
292{
293 SBBreakpoint sb_bp;
Greg Clayton63094e02010-06-23 01:19:29 +0000294 if (m_opaque_sp.get())
295 *sb_bp = m_opaque_sp->CreateBreakpoint (address, false);
Chris Lattner24943d22010-06-08 16:52:24 +0000296 return sb_bp;
297}
298
Chris Lattner24943d22010-06-08 16:52:24 +0000299SBBreakpoint
300SBTarget::FindBreakpointByID (break_id_t bp_id)
301{
302 SBBreakpoint sb_breakpoint;
Greg Clayton63094e02010-06-23 01:19:29 +0000303 if (m_opaque_sp && bp_id != LLDB_INVALID_BREAK_ID)
304 *sb_breakpoint = m_opaque_sp->GetBreakpointByID (bp_id);
Chris Lattner24943d22010-06-08 16:52:24 +0000305 return sb_breakpoint;
306}
307
Greg Claytonc7f5d5c2010-07-23 23:33:17 +0000308uint32_t
309SBTarget::GetNumBreakpoints () const
310{
311 if (m_opaque_sp)
312 return m_opaque_sp->GetBreakpointList().GetSize();
313 return 0;
314}
315
316SBBreakpoint
317SBTarget::GetBreakpointAtIndex (uint32_t idx) const
318{
319 SBBreakpoint sb_breakpoint;
320 if (m_opaque_sp)
321 *sb_breakpoint = m_opaque_sp->GetBreakpointList().GetBreakpointAtIndex(idx);
322 return sb_breakpoint;
323}
Chris Lattner24943d22010-06-08 16:52:24 +0000324
325bool
326SBTarget::BreakpointDelete (break_id_t bp_id)
327{
Greg Clayton63094e02010-06-23 01:19:29 +0000328 if (m_opaque_sp)
329 return m_opaque_sp->RemoveBreakpointByID (bp_id);
Chris Lattner24943d22010-06-08 16:52:24 +0000330 return false;
331}
332
333bool
334SBTarget::EnableAllBreakpoints ()
335{
Greg Clayton63094e02010-06-23 01:19:29 +0000336 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000337 {
Greg Clayton63094e02010-06-23 01:19:29 +0000338 m_opaque_sp->EnableAllBreakpoints ();
Chris Lattner24943d22010-06-08 16:52:24 +0000339 return true;
340 }
341 return false;
342}
343
344bool
345SBTarget::DisableAllBreakpoints ()
346{
Greg Clayton63094e02010-06-23 01:19:29 +0000347 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000348 {
Greg Clayton63094e02010-06-23 01:19:29 +0000349 m_opaque_sp->DisableAllBreakpoints ();
Chris Lattner24943d22010-06-08 16:52:24 +0000350 return true;
351 }
352 return false;
353}
354
355bool
356SBTarget::DeleteAllBreakpoints ()
357{
Greg Clayton63094e02010-06-23 01:19:29 +0000358 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000359 {
Greg Clayton63094e02010-06-23 01:19:29 +0000360 m_opaque_sp->RemoveAllBreakpoints ();
Chris Lattner24943d22010-06-08 16:52:24 +0000361 return true;
362 }
363 return false;
364}
365
366
367uint32_t
368SBTarget::GetNumModules () const
369{
Greg Clayton63094e02010-06-23 01:19:29 +0000370 if (m_opaque_sp)
371 return m_opaque_sp->GetImages().GetSize();
Chris Lattner24943d22010-06-08 16:52:24 +0000372 return 0;
373}
374
Greg Clayton43490d12010-07-30 20:12:55 +0000375void
376SBTarget::Clear ()
377{
378 m_opaque_sp.reset();
379}
380
381
Chris Lattner24943d22010-06-08 16:52:24 +0000382SBModule
383SBTarget::FindModule (const SBFileSpec &sb_file_spec)
384{
385 SBModule sb_module;
Greg Clayton63094e02010-06-23 01:19:29 +0000386 if (m_opaque_sp && sb_file_spec.IsValid())
387 sb_module.SetModule (m_opaque_sp->GetImages().FindFirstModuleForFileSpec (*sb_file_spec, NULL));
Chris Lattner24943d22010-06-08 16:52:24 +0000388 return sb_module;
389}
390
391SBModule
392SBTarget::GetModuleAtIndex (uint32_t idx)
393{
394 SBModule sb_module;
Greg Clayton63094e02010-06-23 01:19:29 +0000395 if (m_opaque_sp)
396 sb_module.SetModule(m_opaque_sp->GetImages().GetModuleAtIndex(idx));
Chris Lattner24943d22010-06-08 16:52:24 +0000397 return sb_module;
398}
399
400
401SBBroadcaster
402SBTarget::GetBroadcaster () const
403{
Greg Clayton63094e02010-06-23 01:19:29 +0000404 SBBroadcaster broadcaster(m_opaque_sp.get(), false);
Chris Lattner24943d22010-06-08 16:52:24 +0000405 return broadcaster;
406}
407
408void
Greg Clayton70436352010-06-30 23:03:03 +0000409SBTarget::Disassemble (lldb::addr_t start_addr, lldb::addr_t end_addr, const char *module_name)
Chris Lattner24943d22010-06-08 16:52:24 +0000410{
Greg Clayton70436352010-06-30 23:03:03 +0000411 if (start_addr == LLDB_INVALID_ADDRESS)
Chris Lattner24943d22010-06-08 16:52:24 +0000412 return;
413
Greg Clayton63094e02010-06-23 01:19:29 +0000414 FILE *out = m_opaque_sp->GetDebugger().GetOutputFileHandle();
Chris Lattner24943d22010-06-08 16:52:24 +0000415 if (out == NULL)
416 return;
417
Greg Clayton63094e02010-06-23 01:19:29 +0000418 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000419 {
Greg Clayton70436352010-06-30 23:03:03 +0000420 ModuleSP module_sp;
Chris Lattner24943d22010-06-08 16:52:24 +0000421 if (module_name != NULL)
422 {
Greg Clayton70436352010-06-30 23:03:03 +0000423 FileSpec module_file_spec (module_name);
424 module_sp = m_opaque_sp->GetImages().FindFirstModuleForFileSpec (module_file_spec, NULL);
Chris Lattner24943d22010-06-08 16:52:24 +0000425 }
Greg Clayton70436352010-06-30 23:03:03 +0000426
427 AddressRange range;
428
429 // Make sure the process object is alive if we have one (it might be
430 // created but we might not be launched yet).
Greg Claytoneea26402010-09-14 23:36:40 +0000431
Greg Clayton1a3083a2010-10-06 03:53:16 +0000432 Process *sb_process = m_opaque_sp->GetProcessSP().get();
433 if (sb_process && !sb_process->IsAlive())
434 sb_process = NULL;
Greg Clayton70436352010-06-30 23:03:03 +0000435
436 // If we are given a module, then "start_addr" is a file address in
437 // that module.
438 if (module_sp)
439 {
440 if (!module_sp->ResolveFileAddress (start_addr, range.GetBaseAddress()))
441 range.GetBaseAddress().SetOffset(start_addr);
442 }
Greg Claytoneea26402010-09-14 23:36:40 +0000443 else if (m_opaque_sp->GetSectionLoadList().IsEmpty() == false)
Greg Clayton70436352010-06-30 23:03:03 +0000444 {
445 // We don't have a module, se we need to figure out if "start_addr"
446 // resolves to anything in a running process.
Greg Claytoneea26402010-09-14 23:36:40 +0000447 if (!m_opaque_sp->GetSectionLoadList().ResolveLoadAddress (start_addr, range.GetBaseAddress()))
Greg Clayton70436352010-06-30 23:03:03 +0000448 range.GetBaseAddress().SetOffset(start_addr);
449 }
450 else
451 {
452 if (m_opaque_sp->GetImages().ResolveFileAddress (start_addr, range.GetBaseAddress()))
453 range.GetBaseAddress().SetOffset(start_addr);
454 }
Chris Lattner24943d22010-06-08 16:52:24 +0000455
456 // For now, we need a process; the disassembly functions insist. If we don't have one already,
457 // make one.
458
Greg Clayton70436352010-06-30 23:03:03 +0000459 ExecutionContext exe_ctx;
Chris Lattner24943d22010-06-08 16:52:24 +0000460
Greg Clayton1a3083a2010-10-06 03:53:16 +0000461 if (sb_process)
462 sb_process->CalculateExecutionContext(exe_ctx);
Greg Clayton70436352010-06-30 23:03:03 +0000463 else
Greg Claytona830adb2010-10-04 01:05:56 +0000464 m_opaque_sp->CalculateExecutionContext(exe_ctx);
Chris Lattner24943d22010-06-08 16:52:24 +0000465
Greg Clayton70436352010-06-30 23:03:03 +0000466 if (end_addr == LLDB_INVALID_ADDRESS || end_addr < start_addr)
467 range.SetByteSize( DEFAULT_DISASM_BYTE_SIZE);
468 else
469 range.SetByteSize(end_addr - start_addr);
Chris Lattner24943d22010-06-08 16:52:24 +0000470
Greg Clayton70436352010-06-30 23:03:03 +0000471 StreamFile out_stream (out);
Chris Lattner24943d22010-06-08 16:52:24 +0000472
Greg Clayton70436352010-06-30 23:03:03 +0000473 Disassembler::Disassemble (m_opaque_sp->GetDebugger(),
474 m_opaque_sp->GetArchitecture(),
475 exe_ctx,
476 range,
477 3,
478 false,
479 out_stream);
Chris Lattner24943d22010-06-08 16:52:24 +0000480 }
481}
482
483void
484SBTarget::Disassemble (const char *function_name, const char *module_name)
485{
486 if (function_name == NULL)
487 return;
488
Greg Clayton63094e02010-06-23 01:19:29 +0000489 FILE *out = m_opaque_sp->GetDebugger().GetOutputFileHandle();
Chris Lattner24943d22010-06-08 16:52:24 +0000490 if (out == NULL)
491 return;
492
Greg Clayton63094e02010-06-23 01:19:29 +0000493 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000494 {
Greg Clayton70436352010-06-30 23:03:03 +0000495 Disassembler *disassembler = Disassembler::FindPlugin (m_opaque_sp->GetArchitecture());
Chris Lattner24943d22010-06-08 16:52:24 +0000496 if (disassembler == NULL)
497 return;
498
Greg Clayton70436352010-06-30 23:03:03 +0000499 ModuleSP module_sp;
Chris Lattner24943d22010-06-08 16:52:24 +0000500 if (module_name != NULL)
Chris Lattner24943d22010-06-08 16:52:24 +0000501 {
Greg Clayton70436352010-06-30 23:03:03 +0000502 FileSpec module_file_spec (module_name);
503 module_sp = m_opaque_sp->GetImages().FindFirstModuleForFileSpec (module_file_spec, NULL);
Chris Lattner24943d22010-06-08 16:52:24 +0000504 }
Greg Clayton70436352010-06-30 23:03:03 +0000505
506 ExecutionContext exe_ctx;
507
508 // Make sure the process object is alive if we have one (it might be
509 // created but we might not be launched yet).
Greg Clayton1a3083a2010-10-06 03:53:16 +0000510 Process *sb_process = m_opaque_sp->GetProcessSP().get();
511 if (sb_process && !sb_process->IsAlive())
512 sb_process = NULL;
Greg Clayton70436352010-06-30 23:03:03 +0000513
Greg Clayton1a3083a2010-10-06 03:53:16 +0000514 if (sb_process)
515 sb_process->CalculateExecutionContext(exe_ctx);
Greg Clayton70436352010-06-30 23:03:03 +0000516 else
Greg Claytona830adb2010-10-04 01:05:56 +0000517 m_opaque_sp->CalculateExecutionContext(exe_ctx);
Greg Clayton70436352010-06-30 23:03:03 +0000518
519
520 StreamFile out_stream (out);
521
522 Disassembler::Disassemble (m_opaque_sp->GetDebugger(),
523 m_opaque_sp->GetArchitecture(),
524 exe_ctx,
525 ConstString (function_name),
526 module_sp.get(),
527 3,
528 false,
529 out_stream);
Chris Lattner24943d22010-06-08 16:52:24 +0000530 }
531}
Caroline Tice98f930f2010-09-20 05:20:02 +0000532
533bool
534SBTarget::GetDescription (SBStream &description)
535{
536 if (m_opaque_sp)
Caroline Ticee7a566e2010-09-20 16:21:41 +0000537 {
Caroline Ticee49ec182010-09-22 23:01:29 +0000538 description.ref();
Caroline Tice98f930f2010-09-20 05:20:02 +0000539 m_opaque_sp->Dump (description.get());
Caroline Ticee7a566e2010-09-20 16:21:41 +0000540 }
Caroline Tice98f930f2010-09-20 05:20:02 +0000541 else
542 description.Printf ("No value");
543
544 return true;
545}