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