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
641 /// Adds a breakpoint override implemented by class_name. Returns the ID
642 /// of the new override or LLDB_INVALID_INDEX64 on error.
643 uint64_t AddBreakpointOverride(const char *class_name,
644 const char *description,
645 SBStructuredData &args_data, SBError &status);
646
647 bool RemoveBreakpointOverride(uint64_t id);
648
650 uint32_t line);
651
653 BreakpointCreateByLocation(const lldb::SBFileSpec &file_spec, uint32_t line);
654
656 BreakpointCreateByLocation(const lldb::SBFileSpec &file_spec, uint32_t line,
657 lldb::addr_t offset);
658
660 BreakpointCreateByLocation(const lldb::SBFileSpec &file_spec, uint32_t line,
661 lldb::addr_t offset, SBFileSpecList &module_list);
662
664 BreakpointCreateByLocation(const lldb::SBFileSpec &file_spec, uint32_t line,
665 uint32_t column, lldb::addr_t offset,
666 SBFileSpecList &module_list);
667
669 BreakpointCreateByLocation(const lldb::SBFileSpec &file_spec, uint32_t line,
670 uint32_t column, lldb::addr_t offset,
671 SBFileSpecList &module_list,
672 bool move_to_nearest_code);
673
674 lldb::SBBreakpoint BreakpointCreateByName(const char *symbol_name,
675 const char *module_name = nullptr);
676
677 // This version uses name_type_mask = eFunctionNameTypeAuto
679 BreakpointCreateByName(const char *symbol_name,
680 const SBFileSpecList &module_list,
681 const SBFileSpecList &comp_unit_list);
682
684 const char *symbol_name,
685 uint32_t
686 name_type_mask, // Logical OR one or more FunctionNameType enum bits
687 const SBFileSpecList &module_list,
688 const SBFileSpecList &comp_unit_list);
689
691 const char *symbol_name,
692 uint32_t
693 name_type_mask, // Logical OR one or more FunctionNameType enum bits
694 lldb::LanguageType symbol_language,
695 const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list);
696
698 const char *symbol_name,
699 uint32_t
700 name_type_mask, // Logical OR one or more FunctionNameType enum bits
701 lldb::LanguageType symbol_language, lldb::addr_t offset,
702 bool offset_is_insn_count, const SBFileSpecList &module_list,
703 const SBFileSpecList &comp_unit_list);
704
705#ifdef SWIG
707 const char **symbol_name, uint32_t num_names,
708 uint32_t
709 name_type_mask, // Logical OR one or more FunctionNameType enum bits
710 const SBFileSpecList &module_list,
711 const SBFileSpecList &comp_unit_list);
712
714 const char **symbol_name, uint32_t num_names,
715 uint32_t
716 name_type_mask, // Logical OR one or more FunctionNameType enum bits
717 lldb::LanguageType symbol_language,
718 const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list);
719
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 lldb::LanguageType symbol_language,
725 lldb::addr_t offset, const SBFileSpecList &module_list,
726 const SBFileSpecList &comp_unit_list);
727#else
729 const char *symbol_name[], uint32_t num_names,
730 uint32_t
731 name_type_mask, // Logical OR one or more FunctionNameType enum bits
732 const SBFileSpecList &module_list,
733 const SBFileSpecList &comp_unit_list);
734
736 const char *symbol_name[], uint32_t num_names,
737 uint32_t
738 name_type_mask, // Logical OR one or more FunctionNameType enum bits
739 lldb::LanguageType symbol_language,
740 const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list);
741
743 const char *symbol_name[], uint32_t num_names,
744 uint32_t
745 name_type_mask, // Logical OR one or more FunctionNameType enum bits
746 lldb::LanguageType symbol_language,
747 lldb::addr_t offset, const SBFileSpecList &module_list,
748 const SBFileSpecList &comp_unit_list);
749#endif
750
751 lldb::SBBreakpoint BreakpointCreateByRegex(const char *symbol_name_regex,
752 const char *module_name = nullptr);
753
755 BreakpointCreateByRegex(const char *symbol_name_regex,
756 const SBFileSpecList &module_list,
757 const SBFileSpecList &comp_unit_list);
758
760 const char *symbol_name_regex, lldb::LanguageType symbol_language,
761 const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list);
762
764 BreakpointCreateBySourceRegex(const char *source_regex,
765 const SBFileSpec &source_file,
766 const char *module_name = nullptr);
767
769 BreakpointCreateBySourceRegex(const char *source_regex,
770 const SBFileSpecList &module_list,
771 const SBFileSpecList &source_file);
772
774 const char *source_regex, const SBFileSpecList &module_list,
775 const SBFileSpecList &source_file, const SBStringList &func_names);
776
778 bool catch_bp, bool throw_bp);
779
781
783
784 /// Create a breakpoint using a scripted resolver.
785 ///
786 /// \param[in] class_name
787 /// This is the name of the class that implements a scripted resolver.
788 ///
789 /// \param[in] extra_args
790 /// This is an SBStructuredData object that will get passed to the
791 /// constructor of the class in class_name. You can use this to
792 /// reuse the same class, parametrizing with entries from this
793 /// dictionary.
794 ///
795 /// \param module_list
796 /// If this is non-empty, this will be used as the module filter in the
797 /// SearchFilter created for this breakpoint.
798 ///
799 /// \param file_list
800 /// If this is non-empty, this will be used as the comp unit filter in the
801 /// SearchFilter created for this breakpoint.
802 ///
803 /// \return
804 /// An SBBreakpoint that will set locations based on the logic in the
805 /// resolver's search callback.
807 const char *class_name,
808 SBStructuredData &extra_args,
809 const SBFileSpecList &module_list,
810 const SBFileSpecList &file_list,
811 bool request_hardware = false);
812
813 /// Read breakpoints from source_file and return the newly created
814 /// breakpoints in bkpt_list.
815 ///
816 /// \param[in] source_file
817 /// The file from which to read the breakpoints.
818 ///
819 /// \param[out] new_bps
820 /// A list of the newly created breakpoints.
821 ///
822 /// \return
823 /// An SBError detailing any errors in reading in the breakpoints.
825 SBBreakpointList &new_bps);
826
827 /// Read breakpoints from source_file and return the newly created
828 /// breakpoints in bkpt_list.
829 ///
830 /// \param[in] source_file
831 /// The file from which to read the breakpoints.
832 ///
833 /// \param[in] matching_names
834 /// Only read in breakpoints whose names match one of the names in this
835 /// list.
836 ///
837 /// \param[out] new_bps
838 /// A list of the newly created breakpoints.
839 ///
840 /// \return
841 /// An SBError detailing any errors in reading in the breakpoints.
843 SBStringList &matching_names,
844 SBBreakpointList &new_bps);
845
846 /// Write breakpoints to dest_file.
847 ///
848 /// \param[in] dest_file
849 /// The file to which to write the breakpoints.
850 ///
851 /// \return
852 /// An SBError detailing any errors in writing in the breakpoints.
854
855 /// Write breakpoints listed in bkpt_list to dest_file.
856 ///
857 /// \param[in] dest_file
858 /// The file to which to write the breakpoints.
859 ///
860 /// \param[in] bkpt_list
861 /// Only write breakpoints from this list.
862 ///
863 /// \param[in] append
864 /// If \b true, append the breakpoints in bkpt_list to the others
865 /// serialized in dest_file. If dest_file doesn't exist, then a new
866 /// file will be created and the breakpoints in bkpt_list written to it.
867 ///
868 /// \return
869 /// An SBError detailing any errors in writing in the breakpoints.
871 SBBreakpointList &bkpt_list,
872 bool append = false);
873
874 uint32_t GetNumBreakpoints() const;
875
876 lldb::SBBreakpoint GetBreakpointAtIndex(uint32_t idx) const;
877
878 bool BreakpointDelete(break_id_t break_id);
879
881
882 // Finds all breakpoints by name, returning the list in bkpt_list. Returns
883 // false if the name is not a valid breakpoint name, true otherwise.
884 bool FindBreakpointsByName(const char *name, SBBreakpointList &bkpt_list);
885
886 void GetBreakpointNames(SBStringList &names);
887
888 void DeleteBreakpointName(const char *name);
889
891
893
895
896 uint32_t GetNumWatchpoints() const;
897
898 lldb::SBWatchpoint GetWatchpointAtIndex(uint32_t idx) const;
899
900 bool DeleteWatchpoint(lldb::watch_id_t watch_id);
901
903
904 LLDB_DEPRECATED("WatchAddress deprecated, use WatchpointCreateByAddress")
905 lldb::SBWatchpoint WatchAddress(lldb::addr_t addr, size_t size, bool read,
906 bool modify, SBError &error);
907
909 WatchpointCreateByAddress(lldb::addr_t addr, size_t size,
911
913
915
917
919
920 lldb::SBType FindFirstType(const char *type);
921
922 lldb::SBTypeList FindTypes(const char *type);
923
925
926 lldb::SBValue CreateValueFromAddress(const char *name, lldb::SBAddress addr,
927 lldb::SBType type);
928
929 lldb::SBValue CreateValueFromData(const char *name, lldb::SBData data,
930 lldb::SBType type);
931
932 lldb::SBValue CreateValueFromExpression(const char *name, const char *expr);
933
935
937 uint32_t count);
938
940 uint32_t count,
941 const char *flavor_string);
942
944 lldb::SBAddress end_addr,
945 const char *flavor_string);
946
948 const void *buf, size_t size);
949
950 // The "WithFlavor" is necessary to keep SWIG from getting confused about
951 // overloaded arguments when using the buf + size -> Python Object magic.
952
954 const char *flavor_string,
955 const void *buf,
956 size_t size);
957
958#ifndef SWIG
960 const void *buf, size_t size);
962 const char *flavor_string,
963 const void *buf,
964 size_t size);
965#endif
966
967 lldb::SBSymbolContextList FindSymbols(const char *name,
969
970 bool operator==(const lldb::SBTarget &rhs) const;
971
972 bool operator!=(const lldb::SBTarget &rhs) const;
973
974 bool GetDescription(lldb::SBStream &description,
975 lldb::DescriptionLevel description_level);
976
977 lldb::SBValue EvaluateExpression(const char *expr);
978
979 lldb::SBValue EvaluateExpression(const char *expr,
980 const SBExpressionOptions &options);
981
983
984 bool IsLoaded(const lldb::SBModule &module) const;
985
987
988 void SetLaunchInfo(const lldb::SBLaunchInfo &launch_info);
989
990 /// Get a \a SBTrace object the can manage the processor trace information of
991 /// this target.
992 ///
993 /// \return
994 /// The trace object. The returned SBTrace object might not be valid, so it
995 /// should be checked with a call to "bool SBTrace::IsValid()".
997
998 /// Create a \a Trace object for the current target using the using the
999 /// default supported tracing technology for this process.
1000 ///
1001 /// \param[out] error
1002 /// An error if a Trace already exists or the trace couldn't be created.
1004
1005 lldb::SBMutex GetAPIMutex() const;
1006
1007 /// Register a scripted frame provider for this target.
1008 /// If a scripted frame provider with the same name and same argument
1009 /// dictionary is already registered on this target, it will be overwritten.
1010 ///
1011 /// \param[in] class_name
1012 /// The name of the Python class that implements the frame provider.
1013 ///
1014 /// \param[in] args_dict
1015 /// A dictionary of arguments to pass to the frame provider class.
1016 ///
1017 /// \param[out] error
1018 /// An error object indicating success or failure.
1019 ///
1020 /// \return
1021 /// A unique identifier for the frame provider descriptor that was
1022 /// registered. 0 if the registration failed.
1023 uint32_t RegisterScriptedFrameProvider(const char *class_name,
1024 lldb::SBStructuredData args_dict,
1026
1027 /// Remove a scripted frame provider from this target by name.
1028 ///
1029 /// \param[in] provider_id
1030 /// The id of the frame provider class to remove.
1031 ///
1032 /// \return
1033 /// An error object indicating success or failure.
1034 lldb::SBError RemoveScriptedFrameProvider(uint32_t provider_id);
1035
1036protected:
1037 friend class SBAddress;
1038 friend class SBAddressRange;
1039 friend class SBBlock;
1040 friend class SBBreakpoint;
1041 friend class SBBreakpointList;
1043 friend class SBDebugger;
1045 friend class SBFrame;
1046 friend class SBFunction;
1047 friend class SBInstruction;
1048 friend class SBModule;
1049 friend class SBModuleSpec;
1050 friend class SBPlatform;
1051 friend class SBProcess;
1052 friend class SBSection;
1053 friend class SBSourceManager;
1054 friend class SBSymbol;
1055 friend class SBType;
1056 friend class SBTypeStaticField;
1057 friend class SBValue;
1059
1063
1064 // Constructors are private, use static Target::Create function to create an
1065 // instance of this class.
1066
1067 SBTarget(const lldb::TargetSP &target_sp);
1068
1069 lldb::TargetSP GetSP() const;
1070
1071 void SetSP(const lldb::TargetSP &target_sp);
1072
1073private:
1075};
1076
1077} // namespace lldb
1078
1079#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(EvalContext &eval_ctx, 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:238
bool BreakpointDelete(break_id_t break_id)
void SetSP(const lldb::TargetSP &target_sp)
Definition SBTarget.cpp:596
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:151
bool GetCollectingStats()
Returns whether statistics collection are enabled.
Definition SBTarget.cpp:245
lldb::SBBreakpoint BreakpointCreateByAddress(addr_t address)
Definition SBTarget.cpp:995
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:949
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:114
const char * GetLabel() const
friend class SBProcess
Definition SBTarget.h:1051
static bool EventIsTargetEvent(const lldb::SBEvent &event)
Definition SBTarget.cpp:125
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:632
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:307
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:1047
lldb::SBMutex GetAPIMutex() const
lldb::SBStructuredData GetStatistics()
Returns a dump of the collected statistics.
Definition SBTarget.cpp:209
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)
uint64_t AddBreakpointOverride(const char *class_name, const char *description, SBStructuredData &args_data, SBError &status)
Adds a breakpoint override implemented by class_name.
Definition SBTarget.cpp:684
lldb::SBFileSpec GetExecutable()
Definition SBTarget.cpp:569
const char * GetABIName()
friend class SBSymbol
Definition SBTarget.h:1054
friend class SBDebugger
Definition SBTarget.h:1043
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:1038
friend class SBModule
Definition SBTarget.h:1048
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:539
friend class SBBreakpoint
Definition SBTarget.h:1040
lldb::SBBreakpoint BreakpointCreateByName(const char *symbol_name, const char *module_name=nullptr)
Definition SBTarget.cpp:815
friend class SBTypeStaticField
Definition SBTarget.h:1056
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:448
bool EnableAllWatchpoints()
lldb::SBBreakpoint BreakpointCreateBySBAddress(SBAddress &address)
friend class SBValue
Definition SBTarget.h:1057
friend class SBAddress
Definition SBTarget.h:1037
bool IsValid() const
Definition SBTarget.cpp:166
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:176
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:651
lldb::SBProcess AttachToProcessWithID(SBListener &listener, lldb::pid_t pid, lldb::SBError &error)
Attach to process with pid.
Definition SBTarget.cpp:480
lldb::SBPlatform GetPlatform()
Return the platform object associated with the target.
Definition SBTarget.cpp:189
bool RemoveBreakpointOverride(uint64_t id)
Definition SBTarget.cpp:719
lldb::SBBreakpoint BreakpointCreateByLocation(const char *file, uint32_t line)
Definition SBTarget.cpp:726
lldb::SBBreakpoint BreakpointCreateForException(lldb::LanguageType language, bool catch_bp, bool throw_bp)
uint32_t GetNumModules() const
lldb::TargetSP GetSP() const
Definition SBTarget.cpp:594
friend class SBExecutionContext
Definition SBTarget.h:1044
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:1049
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:318
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:1039
friend class SBVariablesOptions
Definition SBTarget.h:1058
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:160
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:137
lldb::SBValue CreateValueFromAddress(const char *name, lldb::SBAddress addr, lldb::SBType type)
static lldb::SBTarget GetTargetFromEvent(const lldb::SBEvent &event)
Definition SBTarget.cpp:131
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:582
bool operator!=(const lldb::SBTarget &rhs) const
Definition SBTarget.cpp:588
const char * GetArchName() const
lldb::TargetSP m_opaque_sp
Definition SBTarget.h:1074
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:1045
friend class SBBreakpointList
Definition SBTarget.h:1041
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)
bool DeleteAllBreakpoints()
friend class SBSection
Definition SBTarget.h:1052
lldb::SBValue CreateValueFromData(const char *name, lldb::SBData data, lldb::SBType type)
void ResetStatistics()
Reset the statistics collected for this target.
Definition SBTarget.cpp:231
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:1046
size_t ReadMemory(const SBAddress addr, void *buf, size_t size, lldb::SBError &error)
Read target memory.
Definition SBTarget.cpp:668
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:904
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:283
lldb::SBModule FindModule(const lldb::SBFileSpec &file_spec)
friend class SBSourceManager
Definition SBTarget.h:1053
lldb::SBBreakpoint FindBreakpointByID(break_id_t break_id)
friend class SBType
Definition SBTarget.h:1055
lldb::SBInstructionList ReadInstructions(lldb::SBAddress base_addr, uint32_t count)
void GetBreakpointNames(SBStringList &names)
lldb::SBDebugger GetDebugger() const
Definition SBTarget.cpp:200
friend class SBPlatform
Definition SBTarget.h:1050
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:617
friend class SBBreakpointNameImpl
Definition SBTarget.h:1042
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:507
SBProcess LoadCore(const char *core_file)
Definition SBTarget.cpp:253
static uint32_t GetNumModulesFromEvent(const lldb::SBEvent &event)
Definition SBTarget.cpp:143
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