LLDB mainline
SBTarget.h
Go to the documentation of this file.
1//===-- SBTarget.h ----------------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLDB_API_SBTARGET_H
10#define LLDB_API_SBTARGET_H
11
12#include "lldb/API/SBAddress.h"
16#include "lldb/API/SBDefines.h"
17#include "lldb/API/SBFileSpec.h"
23#include "lldb/API/SBType.h"
24#include "lldb/API/SBValue.h"
27
28namespace lldb_private {
29namespace python {
30class SWIGBridge;
31}
32} // namespace lldb_private
33
34namespace lldb {
35
36class SBPlatform;
37
39public:
40 // Broadcaster bits.
41 enum {
49 };
50
51 // Constructors
52 SBTarget();
53
54 SBTarget(const lldb::SBTarget &rhs);
55
56 // Destructor
58
59 const lldb::SBTarget &operator=(const lldb::SBTarget &rhs);
60
61 explicit operator bool() const;
62
63 bool IsValid() const;
64
65 static bool EventIsTargetEvent(const lldb::SBEvent &event);
66
68
69 /// For eBroadcastBitNewTargetCreated events, returns the newly created
70 /// target. For other event types, returns an invalid SBTarget.
72
73 static uint32_t GetNumModulesFromEvent(const lldb::SBEvent &event);
74
75 static lldb::SBModule GetModuleAtIndexFromEvent(const uint32_t idx,
76 const lldb::SBEvent &event);
77
78 static const char *GetBroadcasterClassName();
79
81
82 /// Sets whether we should collect statistics on lldb or not.
83 ///
84 /// \param[in] v
85 /// A boolean to control the collection.
86 void SetCollectingStats(bool v);
87
88 /// Returns whether statistics collection are enabled.
89 ///
90 /// \return
91 /// true if statistics are currently being collected, false
92 /// otherwise.
93 bool GetCollectingStats();
94
95 /// Returns a dump of the collected statistics.
96 ///
97 /// \return
98 /// A SBStructuredData with the statistics collected.
100
101 /// Returns a dump of the collected statistics.
102 ///
103 /// \param[in] options
104 /// An objects object that contains all options for the statistics dumping.
105 ///
106 /// \return
107 /// A SBStructuredData with the statistics collected.
109
110 /// Reset the statistics collected for this target.
111 /// This includes clearing symbol table and debug info parsing/index time for
112 /// all modules, breakpoint resolve time and target statistics.
113 void ResetStatistics();
114
115 /// Return the platform object associated with the target.
116 ///
117 /// After return, the platform object should be checked for
118 /// validity.
119 ///
120 /// \return
121 /// A platform object.
123
124 /// Return the environment variables that would be used to launch a new
125 /// process.
126 ///
127 /// \return
128 /// An lldb::SBEnvironment object which is a copy of the target's
129 /// environment.
130
132
133 /// Install any binaries that need to be installed.
134 ///
135 /// This function does nothing when debugging on the host system.
136 /// When connected to remote platforms, the target's main executable
137 /// and any modules that have their remote install path set will be
138 /// installed on the remote platform. If the main executable doesn't
139 /// have an install location set, it will be installed in the remote
140 /// platform's working directory.
141 ///
142 /// \return
143 /// An error describing anything that went wrong during
144 /// installation.
146
147 /// Launch a new process.
148 ///
149 /// Launch a new process by spawning a new process using the
150 /// target object's executable module's file as the file to launch.
151 /// Arguments are given in \a argv, and the environment variables
152 /// are in \a envp. Standard input and output files can be
153 /// optionally re-directed to \a stdin_path, \a stdout_path, and
154 /// \a stderr_path.
155 ///
156 /// \param[in] listener
157 /// An optional listener that will receive all process events.
158 /// If \a listener is valid then \a listener will listen to all
159 /// process events. If not valid, then this target's debugger
160 /// (SBTarget::GetDebugger()) will listen to all process events.
161 ///
162 /// \param[in] argv
163 /// The argument array.
164 ///
165 /// \param[in] envp
166 /// The environment array. If this is null, the default
167 /// environment values (provided through `settings set
168 /// target.env-vars`) will be used.
169 ///
170 /// \param[in] stdin_path
171 /// The path to use when re-directing the STDIN of the new
172 /// process. If all stdXX_path arguments are nullptr, a pseudo
173 /// terminal will be used.
174 ///
175 /// \param[in] stdout_path
176 /// The path to use when re-directing the STDOUT of the new
177 /// process. If all stdXX_path arguments are nullptr, a pseudo
178 /// terminal will be used.
179 ///
180 /// \param[in] stderr_path
181 /// The path to use when re-directing the STDERR of the new
182 /// process. If all stdXX_path arguments are nullptr, a pseudo
183 /// terminal will be used.
184 ///
185 /// \param[in] working_directory
186 /// The working directory to have the child process run in
187 ///
188 /// \param[in] launch_flags
189 /// Some launch options specified by logical OR'ing
190 /// lldb::LaunchFlags enumeration values together.
191 ///
192 /// \param[in] stop_at_entry
193 /// If false do not stop the inferior at the entry point.
194 ///
195 /// \param[out] error
196 /// An error object. Contains the reason if there is some failure.
197 ///
198 /// \return
199 /// A process object for the newly created process.
200 lldb::SBProcess Launch(SBListener &listener, char const **argv,
201 char const **envp, const char *stdin_path,
202 const char *stdout_path, const char *stderr_path,
203 const char *working_directory,
204 uint32_t launch_flags, // See LaunchFlags
205 bool stop_at_entry, lldb::SBError &error);
206
207 SBProcess LoadCore(const char *core_file);
208 SBProcess LoadCore(const char *core_file, lldb::SBError &error);
209
210 /// Launch a new process with sensible defaults.
211 ///
212 /// \param[in] argv
213 /// The argument array.
214 ///
215 /// \param[in] envp
216 /// The environment array. If this isn't provided, the default
217 /// environment values (provided through `settings set
218 /// target.env-vars`) will be used.
219 ///
220 /// \param[in] working_directory
221 /// The working directory to have the child process run in
222 ///
223 /// Default: listener
224 /// Set to the target's debugger (SBTarget::GetDebugger())
225 ///
226 /// Default: launch_flags
227 /// Empty launch flags
228 ///
229 /// Default: stdin_path
230 /// Default: stdout_path
231 /// Default: stderr_path
232 /// A pseudo terminal will be used.
233 ///
234 /// \return
235 /// A process object for the newly created process.
236 SBProcess LaunchSimple(const char **argv, const char **envp,
237 const char *working_directory);
238
239 SBProcess Launch(SBLaunchInfo &launch_info, SBError &error);
240
241 SBProcess Attach(SBAttachInfo &attach_info, SBError &error);
242
243 /// Attach to process with pid.
244 ///
245 /// \param[in] listener
246 /// An optional listener that will receive all process events.
247 /// If \a listener is valid then \a listener will listen to all
248 /// process events. If not valid, then this target's debugger
249 /// (SBTarget::GetDebugger()) will listen to all process events.
250 ///
251 /// \param[in] pid
252 /// The process ID to attach to.
253 ///
254 /// \param[out] error
255 /// An error explaining what went wrong if attach fails.
256 ///
257 /// \return
258 /// A process object for the attached process.
261
262 /// Attach to process with name.
263 ///
264 /// \param[in] listener
265 /// An optional listener that will receive all process events.
266 /// If \a listener is valid then \a listener will listen to all
267 /// process events. If not valid, then this target's debugger
268 /// (SBTarget::GetDebugger()) will listen to all process events.
269 ///
270 /// \param[in] name
271 /// Basename of process to attach to.
272 ///
273 /// \param[in] wait_for
274 /// If true wait for a new instance of 'name' to be launched.
275 ///
276 /// \param[out] error
277 /// An error explaining what went wrong if attach fails.
278 ///
279 /// \return
280 /// A process object for the attached process.
282 const char *name, bool wait_for,
284
285 /// Connect to a remote debug server with url.
286 ///
287 /// \param[in] listener
288 /// An optional listener that will receive all process events.
289 /// If \a listener is valid then \a listener will listen to all
290 /// process events. If not valid, then this target's debugger
291 /// (SBTarget::GetDebugger()) will listen to all process events.
292 ///
293 /// \param[in] url
294 /// The url to connect to, e.g., 'connect://localhost:12345'.
295 ///
296 /// \param[in] plugin_name
297 /// The plugin name to be used; can be nullptr.
298 ///
299 /// \param[out] error
300 /// An error explaining what went wrong if the connect fails.
301 ///
302 /// \return
303 /// A process object for the connected process.
304 lldb::SBProcess ConnectRemote(SBListener &listener, const char *url,
305 const char *plugin_name, SBError &error);
306
308
309 // Append the path mapping (from -> to) to the target's paths mapping list.
310 void AppendImageSearchPath(const char *from, const char *to,
312
313 bool AddModule(lldb::SBModule &module);
314
315 lldb::SBModule AddModule(const char *path, const char *triple,
316 const char *uuid);
317
318 lldb::SBModule AddModule(const char *path, const char *triple,
319 const char *uuid_cstr, const char *symfile);
320
321 lldb::SBModule AddModule(const SBModuleSpec &module_spec);
322
323 uint32_t GetNumModules() const;
324
325 lldb::SBModule GetModuleAtIndex(uint32_t idx);
326
327 bool RemoveModule(lldb::SBModule module);
328
330
332
333 /// Find a module with the given module specification.
334 ///
335 /// \param[in] module_spec
336 /// A lldb::SBModuleSpec object that contains module specification.
337 ///
338 /// \return
339 /// A lldb::SBModule object that represents the found module, or an
340 /// invalid SBModule object if no module was found.
341 lldb::SBModule FindModule(const lldb::SBModuleSpec &module_spec) const;
342
343 /// Find compile units related to *this target and passed source
344 /// file.
345 ///
346 /// \param[in] sb_file_spec
347 /// A lldb::SBFileSpec object that contains source file
348 /// specification.
349 ///
350 /// \return
351 /// A lldb::SBSymbolContextList that gets filled in with all of
352 /// the symbol contexts for all the matches.
354 FindCompileUnits(const lldb::SBFileSpec &sb_file_spec);
355
357
358 uint32_t GetAddressByteSize();
359
360 const char *GetTriple();
361
362 const char *GetArchName() const;
363
364 const char *GetABIName();
365
366 const char *GetLabel() const;
367
368 /// Get the globally unique ID for this target. This ID is unique
369 /// across all debugger instances within the same lldb process.
370 ///
371 /// \return
372 /// The globally unique ID for this target, or
373 /// LLDB_INVALID_GLOBALLY_UNIQUE_TARGET_ID if the target is invalid.
375
376 /// Get the target session name for this target.
377 ///
378 /// The target session name provides a meaningful name for IDEs or tools to
379 /// display to help the user identify the origin and purpose of the target.
380 ///
381 /// \return
382 /// The target session name for this target, or nullptr if the target is
383 /// invalid or has no target session name.
384 const char *GetTargetSessionName() const;
385
386 SBError SetLabel(const char *label);
387
388 /// Architecture opcode byte size width accessor
389 ///
390 /// \return
391 /// The minimum size in 8-bit (host) bytes of an opcode.
392 uint32_t GetMinimumOpcodeByteSize() const;
393
394 /// Architecture opcode byte size width accessor
395 ///
396 /// \return
397 /// The maximum size in 8-bit (host) bytes of an opcode.
398 uint32_t GetMaximumOpcodeByteSize() const;
399
400 LLDB_DEPRECATED("Always returns 1.")
401 uint32_t GetDataByteSize();
402
403 LLDB_DEPRECATED("Always returns 1.")
404 uint32_t GetCodeByteSize();
405
406 /// Gets the target.max-children-count value
407 /// It should be used to limit the number of
408 /// children of large data structures to be displayed.
410
411 /// Set the base load address for a module section.
412 ///
413 /// \param[in] section
414 /// The section whose base load address will be set within this
415 /// target.
416 ///
417 /// \param[in] section_base_addr
418 /// The base address for the section.
419 ///
420 /// \return
421 /// An error to indicate success, fail, and any reason for
422 /// failure.
424 lldb::addr_t section_base_addr);
425
426 /// Clear the base load address for a module section.
427 ///
428 /// \param[in] section
429 /// The section whose base load address will be cleared within
430 /// this target.
431 ///
432 /// \return
433 /// An error to indicate success, fail, and any reason for
434 /// failure.
436
437#ifndef SWIG
438 /// Slide all file addresses for all module sections so that \a module
439 /// appears to loaded at these slide addresses.
440 ///
441 /// When you need all sections within a module to be loaded at a
442 /// rigid slide from the addresses found in the module object file,
443 /// this function will allow you to easily and quickly slide all
444 /// module sections.
445 ///
446 /// \param[in] module
447 /// The module to load.
448 ///
449 /// \param[in] sections_offset
450 /// An offset that will be applied to all section file addresses
451 /// (the virtual addresses found in the object file itself).
452 ///
453 /// \return
454 /// An error to indicate success, fail, and any reason for
455 /// failure.
456 LLDB_DEPRECATED_FIXME("Use SetModuleLoadAddress(lldb::SBModule, uint64_t)",
457 "SetModuleLoadAddress(lldb::SBModule, uint64_t)")
459 int64_t sections_offset);
460#endif
461
462 /// Slide all file addresses for all module sections so that \a module
463 /// appears to loaded at these slide addresses.
464 ///
465 /// When you need all sections within a module to be loaded at a
466 /// rigid slide from the addresses found in the module object file,
467 /// this function will allow you to easily and quickly slide all
468 /// module sections.
469 ///
470 /// \param[in] module
471 /// The module to load.
472 ///
473 /// \param[in] sections_offset
474 /// An offset that will be applied to all section file addresses
475 /// (the virtual addresses found in the object file itself).
476 ///
477 /// \return
478 /// An error to indicate success, fail, and any reason for
479 /// failure.
481 uint64_t sections_offset);
482
483 /// Clear the section base load addresses for all sections in a module.
484 ///
485 /// \param[in] module
486 /// The module to unload.
487 ///
488 /// \return
489 /// An error to indicate success, fail, and any reason for
490 /// failure.
492
493 /// Find functions by name.
494 ///
495 /// \param[in] name
496 /// The name of the function we are looking for.
497 ///
498 /// \param[in] name_type_mask
499 /// A logical OR of one or more FunctionNameType enum bits that
500 /// indicate what kind of names should be used when doing the
501 /// lookup. Bits include fully qualified names, base names,
502 /// C++ methods, or ObjC selectors.
503 /// See FunctionNameType for more details.
504 ///
505 /// \return
506 /// A lldb::SBSymbolContextList that gets filled in with all of
507 /// the symbol contexts for all the matches.
509 FindFunctions(const char *name,
510 uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
511
512 /// Find global and static variables by name.
513 ///
514 /// \param[in] name
515 /// The name of the global or static variable we are looking
516 /// for.
517 ///
518 /// \param[in] max_matches
519 /// Allow the number of matches to be limited to \a max_matches.
520 ///
521 /// \return
522 /// A list of matched variables in an SBValueList.
523 lldb::SBValueList FindGlobalVariables(const char *name, uint32_t max_matches);
524
525 /// Find the first global (or static) variable by name.
526 ///
527 /// \param[in] name
528 /// The name of the global or static variable we are looking
529 /// for.
530 ///
531 /// \return
532 /// An SBValue that gets filled in with the found variable (if any).
533 lldb::SBValue FindFirstGlobalVariable(const char *name);
534
535 /// Find global and static variables by pattern.
536 ///
537 /// \param[in] name
538 /// The pattern to search for global or static variables
539 ///
540 /// \param[in] max_matches
541 /// Allow the number of matches to be limited to \a max_matches.
542 ///
543 /// \param[in] matchtype
544 /// The match type to use.
545 ///
546 /// \return
547 /// A list of matched variables in an SBValueList.
548 lldb::SBValueList FindGlobalVariables(const char *name, uint32_t max_matches,
549 MatchType matchtype);
550
551 /// Find global functions by their name with pattern matching.
552 ///
553 /// \param[in] name
554 /// The pattern to search for global or static variables
555 ///
556 /// \param[in] max_matches
557 /// Allow the number of matches to be limited to \a max_matches.
558 ///
559 /// \param[in] matchtype
560 /// The match type to use.
561 ///
562 /// \return
563 /// A list of matched variables in an SBValueList.
565 uint32_t max_matches,
566 MatchType matchtype);
567
568 void Clear();
569
570 /// Resolve a current file address into a section offset address.
571 ///
572 /// \param[in] file_addr
573 /// The file address to resolve.
574 ///
575 /// \return
576 /// An SBAddress which will be valid if...
578
579 /// Resolve a current load address into a section offset address.
580 ///
581 /// \param[in] vm_addr
582 /// A virtual address from the current process state that is to
583 /// be translated into a section offset address.
584 ///
585 /// \return
586 /// An SBAddress which will be valid if \a vm_addr was
587 /// successfully resolved into a section offset address, or an
588 /// invalid SBAddress if \a vm_addr doesn't resolve to a section
589 /// in a module.
591
592 /// Resolve a current load address into a section offset address
593 /// using the process stop ID to identify a time in the past.
594 ///
595 /// \param[in] stop_id
596 /// Each time a process stops, the process stop ID integer gets
597 /// incremented. These stop IDs are used to identify past times
598 /// and can be used in history objects as a cheap way to store
599 /// the time at which the sample was taken. Specifying
600 /// UINT32_MAX will always resolve the address using the
601 /// currently loaded sections.
602 ///
603 /// \param[in] vm_addr
604 /// A virtual address from the current process state that is to
605 /// be translated into a section offset address.
606 ///
607 /// \return
608 /// An SBAddress which will be valid if \a vm_addr was
609 /// successfully resolved into a section offset address, or an
610 /// invalid SBAddress if \a vm_addr doesn't resolve to a section
611 /// in a module.
613 lldb::addr_t vm_addr);
614
616 uint32_t resolve_scope);
617
618 /// Read target memory. If a target process is running then memory
619 /// is read from here. Otherwise the memory is read from the object
620 /// files. For a target whose bytes are sized as a multiple of host
621 /// bytes, the data read back will preserve the target's byte order.
622 ///
623 /// \param[in] addr
624 /// A target address to read from.
625 ///
626 /// \param[out] buf
627 /// The buffer to read memory into.
628 ///
629 /// \param[in] size
630 /// The maximum number of host bytes to read in the buffer passed
631 /// into this call
632 ///
633 /// \param[out] error
634 /// Status information is written here if the memory read fails.
635 ///
636 /// \return
637 /// The amount of data read in host bytes.
638 size_t ReadMemory(const SBAddress addr, void *buf, size_t size,
640
642 uint32_t line);
643
645 BreakpointCreateByLocation(const lldb::SBFileSpec &file_spec, uint32_t line);
646
648 BreakpointCreateByLocation(const lldb::SBFileSpec &file_spec, uint32_t line,
649 lldb::addr_t offset);
650
652 BreakpointCreateByLocation(const lldb::SBFileSpec &file_spec, uint32_t line,
653 lldb::addr_t offset, SBFileSpecList &module_list);
654
656 BreakpointCreateByLocation(const lldb::SBFileSpec &file_spec, uint32_t line,
657 uint32_t column, lldb::addr_t offset,
658 SBFileSpecList &module_list);
659
661 BreakpointCreateByLocation(const lldb::SBFileSpec &file_spec, uint32_t line,
662 uint32_t column, lldb::addr_t offset,
663 SBFileSpecList &module_list,
664 bool move_to_nearest_code);
665
666 lldb::SBBreakpoint BreakpointCreateByName(const char *symbol_name,
667 const char *module_name = nullptr);
668
669 // This version uses name_type_mask = eFunctionNameTypeAuto
671 BreakpointCreateByName(const char *symbol_name,
672 const SBFileSpecList &module_list,
673 const SBFileSpecList &comp_unit_list);
674
676 const char *symbol_name,
677 uint32_t
678 name_type_mask, // Logical OR one or more FunctionNameType enum bits
679 const SBFileSpecList &module_list,
680 const SBFileSpecList &comp_unit_list);
681
683 const char *symbol_name,
684 uint32_t
685 name_type_mask, // Logical OR one or more FunctionNameType enum bits
686 lldb::LanguageType symbol_language,
687 const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list);
688
690 const char *symbol_name,
691 uint32_t
692 name_type_mask, // Logical OR one or more FunctionNameType enum bits
693 lldb::LanguageType symbol_language, lldb::addr_t offset,
694 bool offset_is_insn_count, const SBFileSpecList &module_list,
695 const SBFileSpecList &comp_unit_list);
696
697#ifdef SWIG
699 const char **symbol_name, uint32_t num_names,
700 uint32_t
701 name_type_mask, // Logical OR one or more FunctionNameType enum bits
702 const SBFileSpecList &module_list,
703 const SBFileSpecList &comp_unit_list);
704
706 const char **symbol_name, uint32_t num_names,
707 uint32_t
708 name_type_mask, // Logical OR one or more FunctionNameType enum bits
709 lldb::LanguageType symbol_language,
710 const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list);
711
713 const char **symbol_name, uint32_t num_names,
714 uint32_t
715 name_type_mask, // Logical OR one or more FunctionNameType enum bits
716 lldb::LanguageType symbol_language,
717 lldb::addr_t offset, const SBFileSpecList &module_list,
718 const SBFileSpecList &comp_unit_list);
719#else
721 const char *symbol_name[], uint32_t num_names,
722 uint32_t
723 name_type_mask, // Logical OR one or more FunctionNameType enum bits
724 const SBFileSpecList &module_list,
725 const SBFileSpecList &comp_unit_list);
726
728 const char *symbol_name[], uint32_t num_names,
729 uint32_t
730 name_type_mask, // Logical OR one or more FunctionNameType enum bits
731 lldb::LanguageType symbol_language,
732 const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list);
733
735 const char *symbol_name[], uint32_t num_names,
736 uint32_t
737 name_type_mask, // Logical OR one or more FunctionNameType enum bits
738 lldb::LanguageType symbol_language,
739 lldb::addr_t offset, const SBFileSpecList &module_list,
740 const SBFileSpecList &comp_unit_list);
741#endif
742
743 lldb::SBBreakpoint BreakpointCreateByRegex(const char *symbol_name_regex,
744 const char *module_name = nullptr);
745
747 BreakpointCreateByRegex(const char *symbol_name_regex,
748 const SBFileSpecList &module_list,
749 const SBFileSpecList &comp_unit_list);
750
752 const char *symbol_name_regex, lldb::LanguageType symbol_language,
753 const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list);
754
756 BreakpointCreateBySourceRegex(const char *source_regex,
757 const SBFileSpec &source_file,
758 const char *module_name = nullptr);
759
761 BreakpointCreateBySourceRegex(const char *source_regex,
762 const SBFileSpecList &module_list,
763 const SBFileSpecList &source_file);
764
766 const char *source_regex, const SBFileSpecList &module_list,
767 const SBFileSpecList &source_file, const SBStringList &func_names);
768
770 bool catch_bp, bool throw_bp);
771
773
775
776 /// Create a breakpoint using a scripted resolver.
777 ///
778 /// \param[in] class_name
779 /// This is the name of the class that implements a scripted resolver.
780 ///
781 /// \param[in] extra_args
782 /// This is an SBStructuredData object that will get passed to the
783 /// constructor of the class in class_name. You can use this to
784 /// reuse the same class, parametrizing with entries from this
785 /// dictionary.
786 ///
787 /// \param module_list
788 /// If this is non-empty, this will be used as the module filter in the
789 /// SearchFilter created for this breakpoint.
790 ///
791 /// \param file_list
792 /// If this is non-empty, this will be used as the comp unit filter in the
793 /// SearchFilter created for this breakpoint.
794 ///
795 /// \return
796 /// An SBBreakpoint that will set locations based on the logic in the
797 /// resolver's search callback.
799 const char *class_name,
800 SBStructuredData &extra_args,
801 const SBFileSpecList &module_list,
802 const SBFileSpecList &file_list,
803 bool request_hardware = false);
804
805 /// Read breakpoints from source_file and return the newly created
806 /// breakpoints in bkpt_list.
807 ///
808 /// \param[in] source_file
809 /// The file from which to read the breakpoints.
810 ///
811 /// \param[out] new_bps
812 /// A list of the newly created breakpoints.
813 ///
814 /// \return
815 /// An SBError detailing any errors in reading in the breakpoints.
817 SBBreakpointList &new_bps);
818
819 /// Read breakpoints from source_file and return the newly created
820 /// breakpoints in bkpt_list.
821 ///
822 /// \param[in] source_file
823 /// The file from which to read the breakpoints.
824 ///
825 /// \param[in] matching_names
826 /// Only read in breakpoints whose names match one of the names in this
827 /// list.
828 ///
829 /// \param[out] new_bps
830 /// A list of the newly created breakpoints.
831 ///
832 /// \return
833 /// An SBError detailing any errors in reading in the breakpoints.
835 SBStringList &matching_names,
836 SBBreakpointList &new_bps);
837
838 /// Write breakpoints to dest_file.
839 ///
840 /// \param[in] dest_file
841 /// The file to which to write the breakpoints.
842 ///
843 /// \return
844 /// An SBError detailing any errors in writing in the breakpoints.
846
847 /// Write breakpoints listed in bkpt_list to dest_file.
848 ///
849 /// \param[in] dest_file
850 /// The file to which to write the breakpoints.
851 ///
852 /// \param[in] bkpt_list
853 /// Only write breakpoints from this list.
854 ///
855 /// \param[in] append
856 /// If \b true, append the breakpoints in bkpt_list to the others
857 /// serialized in dest_file. If dest_file doesn't exist, then a new
858 /// file will be created and the breakpoints in bkpt_list written to it.
859 ///
860 /// \return
861 /// An SBError detailing any errors in writing in the breakpoints.
863 SBBreakpointList &bkpt_list,
864 bool append = false);
865
866 uint32_t GetNumBreakpoints() const;
867
868 lldb::SBBreakpoint GetBreakpointAtIndex(uint32_t idx) const;
869
870 bool BreakpointDelete(break_id_t break_id);
871
873
874 // Finds all breakpoints by name, returning the list in bkpt_list. Returns
875 // false if the name is not a valid breakpoint name, true otherwise.
876 bool FindBreakpointsByName(const char *name, SBBreakpointList &bkpt_list);
877
878 void GetBreakpointNames(SBStringList &names);
879
880 void DeleteBreakpointName(const char *name);
881
883
885
887
888 uint32_t GetNumWatchpoints() const;
889
890 lldb::SBWatchpoint GetWatchpointAtIndex(uint32_t idx) const;
891
892 bool DeleteWatchpoint(lldb::watch_id_t watch_id);
893
895
896 LLDB_DEPRECATED("WatchAddress deprecated, use WatchpointCreateByAddress")
897 lldb::SBWatchpoint WatchAddress(lldb::addr_t addr, size_t size, bool read,
898 bool modify, SBError &error);
899
901 WatchpointCreateByAddress(lldb::addr_t addr, size_t size,
903
905
907
909
911
912 lldb::SBType FindFirstType(const char *type);
913
914 lldb::SBTypeList FindTypes(const char *type);
915
917
918 lldb::SBValue CreateValueFromAddress(const char *name, lldb::SBAddress addr,
919 lldb::SBType type);
920
921 lldb::SBValue CreateValueFromData(const char *name, lldb::SBData data,
922 lldb::SBType type);
923
924 lldb::SBValue CreateValueFromExpression(const char *name, const char *expr);
925
927
929 uint32_t count);
930
932 uint32_t count,
933 const char *flavor_string);
934
936 lldb::SBAddress end_addr,
937 const char *flavor_string);
938
940 const void *buf, size_t size);
941
942 // The "WithFlavor" is necessary to keep SWIG from getting confused about
943 // overloaded arguments when using the buf + size -> Python Object magic.
944
946 const char *flavor_string,
947 const void *buf,
948 size_t size);
949
950#ifndef SWIG
952 const void *buf, size_t size);
954 const char *flavor_string,
955 const void *buf,
956 size_t size);
957#endif
958
959 lldb::SBSymbolContextList FindSymbols(const char *name,
961
962 bool operator==(const lldb::SBTarget &rhs) const;
963
964 bool operator!=(const lldb::SBTarget &rhs) const;
965
966 bool GetDescription(lldb::SBStream &description,
967 lldb::DescriptionLevel description_level);
968
969 lldb::SBValue EvaluateExpression(const char *expr);
970
971 lldb::SBValue EvaluateExpression(const char *expr,
972 const SBExpressionOptions &options);
973
975
976 bool IsLoaded(const lldb::SBModule &module) const;
977
979
980 void SetLaunchInfo(const lldb::SBLaunchInfo &launch_info);
981
982 /// Get a \a SBTrace object the can manage the processor trace information of
983 /// this target.
984 ///
985 /// \return
986 /// The trace object. The returned SBTrace object might not be valid, so it
987 /// should be checked with a call to "bool SBTrace::IsValid()".
989
990 /// Create a \a Trace object for the current target using the using the
991 /// default supported tracing technology for this process.
992 ///
993 /// \param[out] error
994 /// An error if a Trace already exists or the trace couldn't be created.
996
998
999 /// Register a scripted frame provider for this target.
1000 /// If a scripted frame provider with the same name and same argument
1001 /// dictionary is already registered on this target, it will be overwritten.
1002 ///
1003 /// \param[in] class_name
1004 /// The name of the Python class that implements the frame provider.
1005 ///
1006 /// \param[in] args_dict
1007 /// A dictionary of arguments to pass to the frame provider class.
1008 ///
1009 /// \param[out] error
1010 /// An error object indicating success or failure.
1011 ///
1012 /// \return
1013 /// A unique identifier for the frame provider descriptor that was
1014 /// registered. 0 if the registration failed.
1015 uint32_t RegisterScriptedFrameProvider(const char *class_name,
1016 lldb::SBStructuredData args_dict,
1018
1019 /// Remove a scripted frame provider from this target by name.
1020 ///
1021 /// \param[in] provider_id
1022 /// The id of the frame provider class to remove.
1023 ///
1024 /// \return
1025 /// An error object indicating success or failure.
1026 lldb::SBError RemoveScriptedFrameProvider(uint32_t provider_id);
1027
1028protected:
1029 friend class SBAddress;
1030 friend class SBAddressRange;
1031 friend class SBBlock;
1032 friend class SBBreakpoint;
1033 friend class SBBreakpointList;
1035 friend class SBDebugger;
1037 friend class SBFrame;
1038 friend class SBFunction;
1039 friend class SBInstruction;
1040 friend class SBModule;
1041 friend class SBModuleSpec;
1042 friend class SBPlatform;
1043 friend class SBProcess;
1044 friend class SBSection;
1045 friend class SBSourceManager;
1046 friend class SBSymbol;
1047 friend class SBType;
1048 friend class SBTypeStaticField;
1049 friend class SBValue;
1051
1053
1054 // Constructors are private, use static Target::Create function to create an
1055 // instance of this class.
1056
1057 SBTarget(const lldb::TargetSP &target_sp);
1058
1059 lldb::TargetSP GetSP() const;
1060
1061 void SetSP(const lldb::TargetSP &target_sp);
1062
1063private:
1065};
1066
1067} // namespace lldb
1068
1069#endif // LLDB_API_SBTARGET_H
static llvm::Expected< ValueObjectSP > EvaluateExpression(llvm::StringRef expression, StackFrame &frame, Process &process)
static llvm::raw_ostream & error(Stream &strm)
static llvm::Expected< lldb::addr_t > ResolveLoadAddress(ExecutionContext *exe_ctx, lldb::ModuleSP &module_sp, const char *dw_op_type, lldb::addr_t file_addr, Address &so_addr, bool check_sectionoffset=false)
Helper function to move common code used to resolve a file address and turn into a load address.
#define LLDB_API
Definition SBDefines.h:28
#define LLDB_DEPRECATED_FIXME(MSG, FIX)
Definition SBDefines.h:39
#define LLDB_DEPRECATED(MSG)
Definition SBDefines.h:38
This class handles the verbosity when dumping statistics.
SBSourceManager GetSourceManager()
const char * GetTargetSessionName() const
Get the target session name for this target.
bool AddModule(lldb::SBModule &module)
bool DisableAllBreakpoints()
uint32_t GetNumWatchpoints() const
bool GetDescription(lldb::SBStream &description, lldb::DescriptionLevel description_level)
lldb::SBError ClearSectionLoadAddress(lldb::SBSection section)
Clear the base load address for a module section.
bool DeleteWatchpoint(lldb::watch_id_t watch_id)
lldb::ByteOrder GetByteOrder()
uint32_t GetNumBreakpoints() const
lldb::SBInstructionList GetInstructionsWithFlavor(lldb::SBAddress base_addr, const char *flavor_string, const void *buf, size_t size)
void SetCollectingStats(bool v)
Sets whether we should collect statistics on lldb or not.
Definition SBTarget.cpp:236
bool BreakpointDelete(break_id_t break_id)
void SetSP(const lldb::TargetSP &target_sp)
Definition SBTarget.cpp:591
bool IsLoaded(const lldb::SBModule &module) const
const char * GetTriple()
static lldb::SBModule GetModuleAtIndexFromEvent(const uint32_t idx, const lldb::SBEvent &event)
Definition SBTarget.cpp:149
bool GetCollectingStats()
Returns whether statistics collection are enabled.
Definition SBTarget.cpp:243
lldb::SBBreakpoint BreakpointCreateByAddress(addr_t address)
Definition SBTarget.cpp:948
lldb::SBValue CreateValueFromExpression(const char *name, const char *expr)
lldb::SBSymbolContextList FindGlobalFunctions(const char *name, uint32_t max_matches, MatchType matchtype)
Find global functions by their name with pattern matching.
lldb::SBBreakpoint BreakpointCreateByRegex(const char *symbol_name_regex, const char *module_name=nullptr)
Definition SBTarget.cpp:902
lldb::SBTrace GetTrace()
Get a SBTrace object the can manage the processor trace information of this target.
const lldb::SBTarget & operator=(const lldb::SBTarget &rhs)
Definition SBTarget.cpp:112
const char * GetLabel() const
friend class SBProcess
Definition SBTarget.h:1043
static bool EventIsTargetEvent(const lldb::SBEvent &event)
Definition SBTarget.cpp:123
lldb::SBAddress ResolvePastLoadAddress(uint32_t stop_id, lldb::addr_t vm_addr)
Resolve a current load address into a section offset address using the process stop ID to identify a ...
Definition SBTarget.cpp:627
bool DisableAllWatchpoints()
lldb::addr_t GetStackRedZoneSize()
lldb::SBBreakpoint GetBreakpointAtIndex(uint32_t idx) const
SBError Install()
Install any binaries that need to be installed.
Definition SBTarget.cpp:305
lldb::SBSymbolContextList FindCompileUnits(const lldb::SBFileSpec &sb_file_spec)
Find compile units related to *this target and passed source file.
lldb::SBWatchpoint WatchpointCreateByAddress(lldb::addr_t addr, size_t size, lldb::SBWatchpointOptions options, SBError &error)
friend class SBInstruction
Definition SBTarget.h:1039
lldb::SBMutex GetAPIMutex() const
lldb::SBStructuredData GetStatistics()
Returns a dump of the collected statistics.
Definition SBTarget.cpp:207
lldb::SBModule GetModuleAtIndex(uint32_t idx)
SBError SetLabel(const char *label)
lldb::SBValueList FindGlobalVariables(const char *name, uint32_t max_matches)
Find global and static variables by name.
lldb::SBType GetBasicType(lldb::BasicType type)
lldb::SBFileSpec GetExecutable()
Definition SBTarget.cpp:564
const char * GetABIName()
friend class SBSymbol
Definition SBTarget.h:1046
friend class SBDebugger
Definition SBTarget.h:1035
lldb::SBError SetSectionLoadAddress(lldb::SBSection section, lldb::addr_t section_base_addr)
Set the base load address for a module section.
friend class SBAddressRange
Definition SBTarget.h:1030
friend class SBModule
Definition SBTarget.h:1040
lldb::SBProcess ConnectRemote(SBListener &listener, const char *url, const char *plugin_name, SBError &error)
Connect to a remote debug server with url.
Definition SBTarget.cpp:534
friend class SBBreakpoint
Definition SBTarget.h:1032
lldb::SBBreakpoint BreakpointCreateByName(const char *symbol_name, const char *module_name=nullptr)
Definition SBTarget.cpp:768
friend class SBTypeStaticField
Definition SBTarget.h:1048
void DeleteBreakpointName(const char *name)
lldb::SBWatchpoint WatchAddress(lldb::addr_t addr, size_t size, bool read, bool modify, SBError &error)
SBProcess Attach(SBAttachInfo &attach_info, SBError &error)
Definition SBTarget.cpp:443
bool EnableAllWatchpoints()
lldb::SBBreakpoint BreakpointCreateBySBAddress(SBAddress &address)
Definition SBTarget.cpp:961
friend class SBValue
Definition SBTarget.h:1049
friend class SBAddress
Definition SBTarget.h:1029
bool IsValid() const
Definition SBTarget.cpp:164
LLDB_DEPRECATED_FIXME("Use SetModuleLoadAddress(lldb::SBModule, uint64_t)", "SetModuleLoadAddress(lldb::SBModule, uint64_t)") lldb lldb::SBError SetModuleLoadAddress(lldb::SBModule module, uint64_t sections_offset)
Slide all file addresses for all module sections so that module appears to loaded at these slide addr...
lldb::SBProcess GetProcess()
Definition SBTarget.cpp:174
uint32_t RegisterScriptedFrameProvider(const char *class_name, lldb::SBStructuredData args_dict, lldb::SBError &error)
Register a scripted frame provider for this target.
SBSymbolContext ResolveSymbolContextForAddress(const SBAddress &addr, uint32_t resolve_scope)
Definition SBTarget.cpp:646
lldb::SBProcess AttachToProcessWithID(SBListener &listener, lldb::pid_t pid, lldb::SBError &error)
Attach to process with pid.
Definition SBTarget.cpp:475
lldb::SBPlatform GetPlatform()
Return the platform object associated with the target.
Definition SBTarget.cpp:187
lldb::SBBreakpoint BreakpointCreateByLocation(const char *file, uint32_t line)
Definition SBTarget.cpp:679
lldb::SBBreakpoint BreakpointCreateForException(lldb::LanguageType language, bool catch_bp, bool throw_bp)
uint32_t GetNumModules() const
lldb::TargetSP GetSP() const
Definition SBTarget.cpp:589
friend class SBExecutionContext
Definition SBTarget.h:1036
uint32_t GetDataByteSize()
uint32_t GetMaximumNumberOfChildrenToDisplay() const
Gets the target.max-children-count value It should be used to limit the number of children of large d...
bool DeleteAllWatchpoints()
lldb::SBInstructionList GetInstructions(lldb::SBAddress base_addr, const void *buf, size_t size)
friend class SBModuleSpec
Definition SBTarget.h:1041
lldb::SBProcess Launch(SBListener &listener, char const **argv, char const **envp, const char *stdin_path, const char *stdout_path, const char *stderr_path, const char *working_directory, uint32_t launch_flags, bool stop_at_entry, lldb::SBError &error)
Launch a new process.
Definition SBTarget.cpp:316
bool RemoveModule(lldb::SBModule module)
@ eBroadcastBitModulesUnloaded
Definition SBTarget.h:44
@ eBroadcastBitSymbolsChanged
Definition SBTarget.h:47
@ eBroadcastBitSymbolsLoaded
Definition SBTarget.h:46
@ eBroadcastBitBreakpointChanged
Definition SBTarget.h:42
@ eBroadcastBitWatchpointChanged
Definition SBTarget.h:45
@ eBroadcastBitNewTargetCreated
Definition SBTarget.h:48
@ eBroadcastBitModulesLoaded
Definition SBTarget.h:43
lldb::SBSymbolContextList FindFunctions(const char *name, uint32_t name_type_mask=lldb::eFunctionNameTypeAny)
Find functions by name.
lldb::SBValue FindFirstGlobalVariable(const char *name)
Find the first global (or static) variable by name.
friend class SBBlock
Definition SBTarget.h:1031
friend class SBVariablesOptions
Definition SBTarget.h:1050
lldb::SBBreakpoint BreakpointCreateFromScript(const char *class_name, SBStructuredData &extra_args, const SBFileSpecList &module_list, const SBFileSpecList &file_list, bool request_hardware=false)
Create a breakpoint using a scripted resolver.
static const char * GetBroadcasterClassName()
Definition SBTarget.cpp:158
SBEnvironment GetEnvironment()
Return the environment variables that would be used to launch a new process.
lldb::SBTypeList FindTypes(const char *type)
static lldb::SBTarget GetCreatedTargetFromEvent(const lldb::SBEvent &event)
For eBroadcastBitNewTargetCreated events, returns the newly created target.
Definition SBTarget.cpp:135
lldb::SBValue CreateValueFromAddress(const char *name, lldb::SBAddress addr, lldb::SBType type)
static lldb::SBTarget GetTargetFromEvent(const lldb::SBEvent &event)
Definition SBTarget.cpp:129
lldb::SBError BreakpointsCreateFromFile(SBFileSpec &source_file, SBBreakpointList &new_bps)
Read breakpoints from source_file and return the newly created breakpoints in bkpt_list.
uint32_t GetAddressByteSize()
bool operator==(const lldb::SBTarget &rhs) const
Definition SBTarget.cpp:577
bool operator!=(const lldb::SBTarget &rhs) const
Definition SBTarget.cpp:583
const char * GetArchName() const
lldb::TargetSP m_opaque_sp
Definition SBTarget.h:1064
lldb::SBWatchpoint GetWatchpointAtIndex(uint32_t idx) const
lldb::SBLaunchInfo GetLaunchInfo() const
lldb::SBSymbolContextList FindSymbols(const char *name, lldb::SymbolType type=eSymbolTypeAny)
lldb::user_id_t GetGloballyUniqueID() const
Get the globally unique ID for this target.
void AppendImageSearchPath(const char *from, const char *to, lldb::SBError &error)
lldb::SBError RemoveScriptedFrameProvider(uint32_t provider_id)
Remove a scripted frame provider from this target by name.
friend class SBFrame
Definition SBTarget.h:1037
friend class SBBreakpointList
Definition SBTarget.h:1033
lldb::SBTrace CreateTrace(SBError &error)
Create a Trace object for the current target using the using the default supported tracing technology...
lldb::SBBreakpoint BreakpointCreateBySourceRegex(const char *source_regex, const SBFileSpec &source_file, const char *module_name=nullptr)
Definition SBTarget.cpp:979
bool DeleteAllBreakpoints()
friend class SBSection
Definition SBTarget.h:1044
lldb::SBValue CreateValueFromData(const char *name, lldb::SBData data, lldb::SBType type)
void ResetStatistics()
Reset the statistics collected for this target.
Definition SBTarget.cpp:229
lldb::SBBroadcaster GetBroadcaster() const
uint32_t GetMinimumOpcodeByteSize() const
Architecture opcode byte size width accessor.
bool FindBreakpointsByName(const char *name, SBBreakpointList &bkpt_list)
friend class SBFunction
Definition SBTarget.h:1038
size_t ReadMemory(const SBAddress addr, void *buf, size_t size, lldb::SBError &error)
Read target memory.
Definition SBTarget.cpp:663
lldb::SBBreakpoint BreakpointCreateByNames(const char *symbol_name[], uint32_t num_names, uint32_t name_type_mask, const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list)
Definition SBTarget.cpp:857
uint32_t GetMaximumOpcodeByteSize() const
Architecture opcode byte size width accessor.
SBProcess LaunchSimple(const char **argv, const char **envp, const char *working_directory)
Launch a new process with sensible defaults.
Definition SBTarget.cpp:281
lldb::SBModule FindModule(const lldb::SBFileSpec &file_spec)
friend class SBSourceManager
Definition SBTarget.h:1045
lldb::SBBreakpoint FindBreakpointByID(break_id_t break_id)
friend class SBType
Definition SBTarget.h:1047
lldb::SBInstructionList ReadInstructions(lldb::SBAddress base_addr, uint32_t count)
void GetBreakpointNames(SBStringList &names)
lldb::SBDebugger GetDebugger() const
Definition SBTarget.cpp:198
friend class SBPlatform
Definition SBTarget.h:1042
lldb::SBError BreakpointsWriteToFile(SBFileSpec &dest_file)
Write breakpoints to dest_file.
lldb::SBWatchpoint FindWatchpointByID(lldb::watch_id_t watch_id)
lldb::SBAddress ResolveFileAddress(lldb::addr_t file_addr)
Resolve a current file address into a section offset address.
Definition SBTarget.cpp:612
friend class SBBreakpointNameImpl
Definition SBTarget.h:1034
void SetLaunchInfo(const lldb::SBLaunchInfo &launch_info)
lldb::SBError ClearModuleLoadAddress(lldb::SBModule module)
Clear the section base load addresses for all sections in a module.
lldb::SBType FindFirstType(const char *type)
uint32_t GetCodeByteSize()
lldb::SBProcess AttachToProcessWithName(SBListener &listener, const char *name, bool wait_for, lldb::SBError &error)
Attach to process with name.
Definition SBTarget.cpp:502
SBProcess LoadCore(const char *core_file)
Definition SBTarget.cpp:251
static uint32_t GetNumModulesFromEvent(const lldb::SBEvent &event)
Definition SBTarget.cpp:141
bool EnableAllBreakpoints()
A class that represents a running process on the host machine.
MatchType
String matching algorithm used by SBTarget.
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
BasicType
Basic types enumeration for the public API SBType::GetBasicType().
LanguageType
Programming language type.
int32_t break_id_t
Definition lldb-types.h:87
SymbolType
Symbol types.
uint64_t pid_t
Definition lldb-types.h:83
ByteOrder
Byte ordering definitions.
int32_t watch_id_t
Definition lldb-types.h:88
uint64_t user_id_t
Definition lldb-types.h:82
uint64_t addr_t
Definition lldb-types.h:80
std::shared_ptr< lldb_private::Target > TargetSP