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);
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();
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 /// Architecture data byte width accessor
401 ///
402 /// \return
403 /// The size in 8-bit (host) bytes of a minimum addressable
404 /// unit from the Architecture's data bus
405 uint32_t GetDataByteSize();
406
407 /// Architecture code byte width accessor
408 ///
409 /// \return
410 /// The size in 8-bit (host) bytes of a minimum addressable
411 /// unit from the Architecture's code bus
412 uint32_t GetCodeByteSize();
413
414 /// Gets the target.max-children-count value
415 /// It should be used to limit the number of
416 /// children of large data structures to be displayed.
418
419 /// Set the base load address for a module section.
420 ///
421 /// \param[in] section
422 /// The section whose base load address will be set within this
423 /// target.
424 ///
425 /// \param[in] section_base_addr
426 /// The base address for the section.
427 ///
428 /// \return
429 /// An error to indicate success, fail, and any reason for
430 /// failure.
432 lldb::addr_t section_base_addr);
433
434 /// Clear the base load address for a module section.
435 ///
436 /// \param[in] section
437 /// The section whose base load address will be cleared within
438 /// this target.
439 ///
440 /// \return
441 /// An error to indicate success, fail, and any reason for
442 /// failure.
444
445#ifndef SWIG
446 /// Slide all file addresses for all module sections so that \a module
447 /// appears to loaded at these slide addresses.
448 ///
449 /// When you need all sections within a module to be loaded at a
450 /// rigid slide from the addresses found in the module object file,
451 /// this function will allow you to easily and quickly slide all
452 /// module sections.
453 ///
454 /// \param[in] module
455 /// The module to load.
456 ///
457 /// \param[in] sections_offset
458 /// An offset that will be applied to all section file addresses
459 /// (the virtual addresses found in the object file itself).
460 ///
461 /// \return
462 /// An error to indicate success, fail, and any reason for
463 /// failure.
464 LLDB_DEPRECATED_FIXME("Use SetModuleLoadAddress(lldb::SBModule, uint64_t)",
465 "SetModuleLoadAddress(lldb::SBModule, uint64_t)")
467 int64_t sections_offset);
468#endif
469
470 /// Slide all file addresses for all module sections so that \a module
471 /// appears to loaded at these slide addresses.
472 ///
473 /// When you need all sections within a module to be loaded at a
474 /// rigid slide from the addresses found in the module object file,
475 /// this function will allow you to easily and quickly slide all
476 /// module sections.
477 ///
478 /// \param[in] module
479 /// The module to load.
480 ///
481 /// \param[in] sections_offset
482 /// An offset that will be applied to all section file addresses
483 /// (the virtual addresses found in the object file itself).
484 ///
485 /// \return
486 /// An error to indicate success, fail, and any reason for
487 /// failure.
489 uint64_t sections_offset);
490
491 /// Clear the section base load addresses for all sections in a module.
492 ///
493 /// \param[in] module
494 /// The module to unload.
495 ///
496 /// \return
497 /// An error to indicate success, fail, and any reason for
498 /// failure.
500
501 /// Find functions by name.
502 ///
503 /// \param[in] name
504 /// The name of the function we are looking for.
505 ///
506 /// \param[in] name_type_mask
507 /// A logical OR of one or more FunctionNameType enum bits that
508 /// indicate what kind of names should be used when doing the
509 /// lookup. Bits include fully qualified names, base names,
510 /// C++ methods, or ObjC selectors.
511 /// See FunctionNameType for more details.
512 ///
513 /// \return
514 /// A lldb::SBSymbolContextList that gets filled in with all of
515 /// the symbol contexts for all the matches.
517 FindFunctions(const char *name,
518 uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
519
520 /// Find global and static variables by name.
521 ///
522 /// \param[in] name
523 /// The name of the global or static variable we are looking
524 /// for.
525 ///
526 /// \param[in] max_matches
527 /// Allow the number of matches to be limited to \a max_matches.
528 ///
529 /// \return
530 /// A list of matched variables in an SBValueList.
531 lldb::SBValueList FindGlobalVariables(const char *name, uint32_t max_matches);
532
533 /// Find the first global (or static) variable by name.
534 ///
535 /// \param[in] name
536 /// The name of the global or static variable we are looking
537 /// for.
538 ///
539 /// \return
540 /// An SBValue that gets filled in with the found variable (if any).
541 lldb::SBValue FindFirstGlobalVariable(const char *name);
542
543 /// Find global and static variables by pattern.
544 ///
545 /// \param[in] name
546 /// The pattern to search for global or static variables
547 ///
548 /// \param[in] max_matches
549 /// Allow the number of matches to be limited to \a max_matches.
550 ///
551 /// \param[in] matchtype
552 /// The match type to use.
553 ///
554 /// \return
555 /// A list of matched variables in an SBValueList.
556 lldb::SBValueList FindGlobalVariables(const char *name, uint32_t max_matches,
557 MatchType matchtype);
558
559 /// Find global functions by their name with pattern matching.
560 ///
561 /// \param[in] name
562 /// The pattern to search for global or static variables
563 ///
564 /// \param[in] max_matches
565 /// Allow the number of matches to be limited to \a max_matches.
566 ///
567 /// \param[in] matchtype
568 /// The match type to use.
569 ///
570 /// \return
571 /// A list of matched variables in an SBValueList.
573 uint32_t max_matches,
574 MatchType matchtype);
575
576 void Clear();
577
578 /// Resolve a current file address into a section offset address.
579 ///
580 /// \param[in] file_addr
581 /// The file address to resolve.
582 ///
583 /// \return
584 /// An SBAddress which will be valid if...
586
587 /// Resolve a current load address into a section offset address.
588 ///
589 /// \param[in] vm_addr
590 /// A virtual address from the current process state that is to
591 /// be translated into a section offset address.
592 ///
593 /// \return
594 /// An SBAddress which will be valid if \a vm_addr was
595 /// successfully resolved into a section offset address, or an
596 /// invalid SBAddress if \a vm_addr doesn't resolve to a section
597 /// in a module.
599
600 /// Resolve a current load address into a section offset address
601 /// using the process stop ID to identify a time in the past.
602 ///
603 /// \param[in] stop_id
604 /// Each time a process stops, the process stop ID integer gets
605 /// incremented. These stop IDs are used to identify past times
606 /// and can be used in history objects as a cheap way to store
607 /// the time at which the sample was taken. Specifying
608 /// UINT32_MAX will always resolve the address using the
609 /// currently loaded sections.
610 ///
611 /// \param[in] vm_addr
612 /// A virtual address from the current process state that is to
613 /// be translated into a section offset address.
614 ///
615 /// \return
616 /// An SBAddress which will be valid if \a vm_addr was
617 /// successfully resolved into a section offset address, or an
618 /// invalid SBAddress if \a vm_addr doesn't resolve to a section
619 /// in a module.
621 lldb::addr_t vm_addr);
622
624 uint32_t resolve_scope);
625
626 /// Read target memory. If a target process is running then memory
627 /// is read from here. Otherwise the memory is read from the object
628 /// files. For a target whose bytes are sized as a multiple of host
629 /// bytes, the data read back will preserve the target's byte order.
630 ///
631 /// \param[in] addr
632 /// A target address to read from.
633 ///
634 /// \param[out] buf
635 /// The buffer to read memory into.
636 ///
637 /// \param[in] size
638 /// The maximum number of host bytes to read in the buffer passed
639 /// into this call
640 ///
641 /// \param[out] error
642 /// Status information is written here if the memory read fails.
643 ///
644 /// \return
645 /// The amount of data read in host bytes.
646 size_t ReadMemory(const SBAddress addr, void *buf, size_t size,
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
1060 friend class lldb_private::python::SWIGBridge;
1061
1062 // Constructors are private, use static Target::Create function to create an
1063 // instance of this class.
1064
1065 SBTarget(const lldb::TargetSP &target_sp);
1066
1067 lldb::TargetSP GetSP() const;
1068
1069 void SetSP(const lldb::TargetSP &target_sp);
1070
1071private:
1073};
1074
1075} // namespace lldb
1076
1077#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:1051
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:1047
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: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:534
friend class SBBreakpoint
Definition SBTarget.h:1040
lldb::SBBreakpoint BreakpointCreateByName(const char *symbol_name, const char *module_name=nullptr)
Definition SBTarget.cpp:768
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:443
bool EnableAllWatchpoints()
lldb::SBBreakpoint BreakpointCreateBySBAddress(SBAddress &address)
Definition SBTarget.cpp:961
friend class SBValue
Definition SBTarget.h:1057
friend class SBAddress
Definition SBTarget.h:1037
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:1044
uint32_t GetDataByteSize()
Architecture data byte width accessor.
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: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: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: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
lldb::TargetSP m_opaque_sp
Definition SBTarget.h:1072
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)
const char * GetArchName()
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)
Definition SBTarget.cpp:979
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: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:1046
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: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:198
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:612
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()
Architecture code byte width accessor.
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:86
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:87
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