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