SBTarget.h 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874
  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. #ifndef LLDB_API_SBTARGET_H
  9. #define LLDB_API_SBTARGET_H
  10. #include "lldb/API/SBAddress.h"
  11. #include "lldb/API/SBAttachInfo.h"
  12. #include "lldb/API/SBBreakpoint.h"
  13. #include "lldb/API/SBBroadcaster.h"
  14. #include "lldb/API/SBDefines.h"
  15. #include "lldb/API/SBFileSpec.h"
  16. #include "lldb/API/SBFileSpecList.h"
  17. #include "lldb/API/SBLaunchInfo.h"
  18. #include "lldb/API/SBSymbolContextList.h"
  19. #include "lldb/API/SBType.h"
  20. #include "lldb/API/SBValue.h"
  21. #include "lldb/API/SBWatchpoint.h"
  22. namespace lldb {
  23. class SBPlatform;
  24. class LLDB_API SBTarget {
  25. public:
  26. // Broadcaster bits.
  27. enum {
  28. eBroadcastBitBreakpointChanged = (1 << 0),
  29. eBroadcastBitModulesLoaded = (1 << 1),
  30. eBroadcastBitModulesUnloaded = (1 << 2),
  31. eBroadcastBitWatchpointChanged = (1 << 3),
  32. eBroadcastBitSymbolsLoaded = (1 << 4)
  33. };
  34. // Constructors
  35. SBTarget();
  36. SBTarget(const lldb::SBTarget &rhs);
  37. SBTarget(const lldb::TargetSP &target_sp);
  38. // Destructor
  39. ~SBTarget();
  40. const lldb::SBTarget &operator=(const lldb::SBTarget &rhs);
  41. explicit operator bool() const;
  42. bool IsValid() const;
  43. static bool EventIsTargetEvent(const lldb::SBEvent &event);
  44. static lldb::SBTarget GetTargetFromEvent(const lldb::SBEvent &event);
  45. static uint32_t GetNumModulesFromEvent(const lldb::SBEvent &event);
  46. static lldb::SBModule GetModuleAtIndexFromEvent(const uint32_t idx,
  47. const lldb::SBEvent &event);
  48. static const char *GetBroadcasterClassName();
  49. lldb::SBProcess GetProcess();
  50. /// Sets whether we should collect statistics on lldb or not.
  51. ///
  52. /// \param[in] v
  53. /// A boolean to control the collection.
  54. void SetCollectingStats(bool v);
  55. /// Returns whether statistics collection are enabled.
  56. ///
  57. /// \return
  58. /// true if statistics are currently being collected, false
  59. /// otherwise.
  60. bool GetCollectingStats();
  61. /// Returns a dump of the collected statistics.
  62. ///
  63. /// \return
  64. /// A SBStructuredData with the statistics collected.
  65. lldb::SBStructuredData GetStatistics();
  66. /// Return the platform object associated with the target.
  67. ///
  68. /// After return, the platform object should be checked for
  69. /// validity.
  70. ///
  71. /// \return
  72. /// A platform object.
  73. lldb::SBPlatform GetPlatform();
  74. /// Return the environment variables that would be used to launch a new
  75. /// process.
  76. ///
  77. /// \return
  78. /// An lldb::SBEnvironment object which is a copy of the target's
  79. /// environment.
  80. SBEnvironment GetEnvironment();
  81. /// Install any binaries that need to be installed.
  82. ///
  83. /// This function does nothing when debugging on the host system.
  84. /// When connected to remote platforms, the target's main executable
  85. /// and any modules that have their remote install path set will be
  86. /// installed on the remote platform. If the main executable doesn't
  87. /// have an install location set, it will be installed in the remote
  88. /// platform's working directory.
  89. ///
  90. /// \return
  91. /// An error describing anything that went wrong during
  92. /// installation.
  93. SBError Install();
  94. /// Launch a new process.
  95. ///
  96. /// Launch a new process by spawning a new process using the
  97. /// target object's executable module's file as the file to launch.
  98. /// Arguments are given in \a argv, and the environment variables
  99. /// are in \a envp. Standard input and output files can be
  100. /// optionally re-directed to \a stdin_path, \a stdout_path, and
  101. /// \a stderr_path.
  102. ///
  103. /// \param[in] listener
  104. /// An optional listener that will receive all process events.
  105. /// If \a listener is valid then \a listener will listen to all
  106. /// process events. If not valid, then this target's debugger
  107. /// (SBTarget::GetDebugger()) will listen to all process events.
  108. ///
  109. /// \param[in] argv
  110. /// The argument array.
  111. ///
  112. /// \param[in] envp
  113. /// The environment array. If this is null, the default
  114. /// environment values (provided through `settings set
  115. /// target.env-vars`) will be used.
  116. ///
  117. /// \param[in] stdin_path
  118. /// The path to use when re-directing the STDIN of the new
  119. /// process. If all stdXX_path arguments are nullptr, a pseudo
  120. /// terminal will be used.
  121. ///
  122. /// \param[in] stdout_path
  123. /// The path to use when re-directing the STDOUT of the new
  124. /// process. If all stdXX_path arguments are nullptr, a pseudo
  125. /// terminal will be used.
  126. ///
  127. /// \param[in] stderr_path
  128. /// The path to use when re-directing the STDERR of the new
  129. /// process. If all stdXX_path arguments are nullptr, a pseudo
  130. /// terminal will be used.
  131. ///
  132. /// \param[in] working_directory
  133. /// The working directory to have the child process run in
  134. ///
  135. /// \param[in] launch_flags
  136. /// Some launch options specified by logical OR'ing
  137. /// lldb::LaunchFlags enumeration values together.
  138. ///
  139. /// \param[in] stop_at_entry
  140. /// If false do not stop the inferior at the entry point.
  141. ///
  142. /// \param[out] error
  143. /// An error object. Contains the reason if there is some failure.
  144. ///
  145. /// \return
  146. /// A process object for the newly created process.
  147. lldb::SBProcess Launch(SBListener &listener, char const **argv,
  148. char const **envp, const char *stdin_path,
  149. const char *stdout_path, const char *stderr_path,
  150. const char *working_directory,
  151. uint32_t launch_flags, // See LaunchFlags
  152. bool stop_at_entry, lldb::SBError &error);
  153. SBProcess LoadCore(const char *core_file);
  154. SBProcess LoadCore(const char *core_file, lldb::SBError &error);
  155. /// Launch a new process with sensible defaults.
  156. ///
  157. /// \param[in] argv
  158. /// The argument array.
  159. ///
  160. /// \param[in] envp
  161. /// The environment array. If this isn't provided, the default
  162. /// environment values (provided through `settings set
  163. /// target.env-vars`) will be used.
  164. ///
  165. /// \param[in] working_directory
  166. /// The working directory to have the child process run in
  167. ///
  168. /// Default: listener
  169. /// Set to the target's debugger (SBTarget::GetDebugger())
  170. ///
  171. /// Default: launch_flags
  172. /// Empty launch flags
  173. ///
  174. /// Default: stdin_path
  175. /// Default: stdout_path
  176. /// Default: stderr_path
  177. /// A pseudo terminal will be used.
  178. ///
  179. /// \return
  180. /// A process object for the newly created process.
  181. SBProcess LaunchSimple(const char **argv, const char **envp,
  182. const char *working_directory);
  183. SBProcess Launch(SBLaunchInfo &launch_info, SBError &error);
  184. SBProcess Attach(SBAttachInfo &attach_info, SBError &error);
  185. /// Attach to process with pid.
  186. ///
  187. /// \param[in] listener
  188. /// An optional listener that will receive all process events.
  189. /// If \a listener is valid then \a listener will listen to all
  190. /// process events. If not valid, then this target's debugger
  191. /// (SBTarget::GetDebugger()) will listen to all process events.
  192. ///
  193. /// \param[in] pid
  194. /// The process ID to attach to.
  195. ///
  196. /// \param[out] error
  197. /// An error explaining what went wrong if attach fails.
  198. ///
  199. /// \return
  200. /// A process object for the attached process.
  201. lldb::SBProcess AttachToProcessWithID(SBListener &listener, lldb::pid_t pid,
  202. lldb::SBError &error);
  203. /// Attach to process with name.
  204. ///
  205. /// \param[in] listener
  206. /// An optional listener that will receive all process events.
  207. /// If \a listener is valid then \a listener will listen to all
  208. /// process events. If not valid, then this target's debugger
  209. /// (SBTarget::GetDebugger()) will listen to all process events.
  210. ///
  211. /// \param[in] name
  212. /// Basename of process to attach to.
  213. ///
  214. /// \param[in] wait_for
  215. /// If true wait for a new instance of 'name' to be launched.
  216. ///
  217. /// \param[out] error
  218. /// An error explaining what went wrong if attach fails.
  219. ///
  220. /// \return
  221. /// A process object for the attached process.
  222. lldb::SBProcess AttachToProcessWithName(SBListener &listener,
  223. const char *name, bool wait_for,
  224. lldb::SBError &error);
  225. /// Connect to a remote debug server with url.
  226. ///
  227. /// \param[in] listener
  228. /// An optional listener that will receive all process events.
  229. /// If \a listener is valid then \a listener will listen to all
  230. /// process events. If not valid, then this target's debugger
  231. /// (SBTarget::GetDebugger()) will listen to all process events.
  232. ///
  233. /// \param[in] url
  234. /// The url to connect to, e.g., 'connect://localhost:12345'.
  235. ///
  236. /// \param[in] plugin_name
  237. /// The plugin name to be used; can be nullptr.
  238. ///
  239. /// \param[out] error
  240. /// An error explaining what went wrong if the connect fails.
  241. ///
  242. /// \return
  243. /// A process object for the connected process.
  244. lldb::SBProcess ConnectRemote(SBListener &listener, const char *url,
  245. const char *plugin_name, SBError &error);
  246. lldb::SBFileSpec GetExecutable();
  247. // Append the path mapping (from -> to) to the target's paths mapping list.
  248. void AppendImageSearchPath(const char *from, const char *to,
  249. lldb::SBError &error);
  250. bool AddModule(lldb::SBModule &module);
  251. lldb::SBModule AddModule(const char *path, const char *triple,
  252. const char *uuid);
  253. lldb::SBModule AddModule(const char *path, const char *triple,
  254. const char *uuid_cstr, const char *symfile);
  255. lldb::SBModule AddModule(const SBModuleSpec &module_spec);
  256. uint32_t GetNumModules() const;
  257. lldb::SBModule GetModuleAtIndex(uint32_t idx);
  258. bool RemoveModule(lldb::SBModule module);
  259. lldb::SBDebugger GetDebugger() const;
  260. lldb::SBModule FindModule(const lldb::SBFileSpec &file_spec);
  261. /// Find compile units related to *this target and passed source
  262. /// file.
  263. ///
  264. /// \param[in] sb_file_spec
  265. /// A lldb::SBFileSpec object that contains source file
  266. /// specification.
  267. ///
  268. /// \return
  269. /// A lldb::SBSymbolContextList that gets filled in with all of
  270. /// the symbol contexts for all the matches.
  271. lldb::SBSymbolContextList
  272. FindCompileUnits(const lldb::SBFileSpec &sb_file_spec);
  273. lldb::ByteOrder GetByteOrder();
  274. uint32_t GetAddressByteSize();
  275. const char *GetTriple();
  276. /// Architecture data byte width accessor
  277. ///
  278. /// \return
  279. /// The size in 8-bit (host) bytes of a minimum addressable
  280. /// unit from the Architecture's data bus
  281. uint32_t GetDataByteSize();
  282. /// Architecture code byte width accessor
  283. ///
  284. /// \return
  285. /// The size in 8-bit (host) bytes of a minimum addressable
  286. /// unit from the Architecture's code bus
  287. uint32_t GetCodeByteSize();
  288. /// Set the base load address for a module section.
  289. ///
  290. /// \param[in] section
  291. /// The section whose base load address will be set within this
  292. /// target.
  293. ///
  294. /// \param[in] section_base_addr
  295. /// The base address for the section.
  296. ///
  297. /// \return
  298. /// An error to indicate success, fail, and any reason for
  299. /// failure.
  300. lldb::SBError SetSectionLoadAddress(lldb::SBSection section,
  301. lldb::addr_t section_base_addr);
  302. /// Clear the base load address for a module section.
  303. ///
  304. /// \param[in] section
  305. /// The section whose base load address will be cleared within
  306. /// this target.
  307. ///
  308. /// \return
  309. /// An error to indicate success, fail, and any reason for
  310. /// failure.
  311. lldb::SBError ClearSectionLoadAddress(lldb::SBSection section);
  312. /// Slide all file addresses for all module sections so that \a module
  313. /// appears to loaded at these slide addresses.
  314. ///
  315. /// When you need all sections within a module to be loaded at a
  316. /// rigid slide from the addresses found in the module object file,
  317. /// this function will allow you to easily and quickly slide all
  318. /// module sections.
  319. ///
  320. /// \param[in] module
  321. /// The module to load.
  322. ///
  323. /// \param[in] sections_offset
  324. /// An offset that will be applied to all section file addresses
  325. /// (the virtual addresses found in the object file itself).
  326. ///
  327. /// \return
  328. /// An error to indicate success, fail, and any reason for
  329. /// failure.
  330. lldb::SBError SetModuleLoadAddress(lldb::SBModule module,
  331. int64_t sections_offset);
  332. /// Clear the section base load addresses for all sections in a module.
  333. ///
  334. /// \param[in] module
  335. /// The module to unload.
  336. ///
  337. /// \return
  338. /// An error to indicate success, fail, and any reason for
  339. /// failure.
  340. lldb::SBError ClearModuleLoadAddress(lldb::SBModule module);
  341. /// Find functions by name.
  342. ///
  343. /// \param[in] name
  344. /// The name of the function we are looking for.
  345. ///
  346. /// \param[in] name_type_mask
  347. /// A logical OR of one or more FunctionNameType enum bits that
  348. /// indicate what kind of names should be used when doing the
  349. /// lookup. Bits include fully qualified names, base names,
  350. /// C++ methods, or ObjC selectors.
  351. /// See FunctionNameType for more details.
  352. ///
  353. /// \return
  354. /// A lldb::SBSymbolContextList that gets filled in with all of
  355. /// the symbol contexts for all the matches.
  356. lldb::SBSymbolContextList
  357. FindFunctions(const char *name,
  358. uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
  359. /// Find global and static variables by name.
  360. ///
  361. /// \param[in] name
  362. /// The name of the global or static variable we are looking
  363. /// for.
  364. ///
  365. /// \param[in] max_matches
  366. /// Allow the number of matches to be limited to \a max_matches.
  367. ///
  368. /// \return
  369. /// A list of matched variables in an SBValueList.
  370. lldb::SBValueList FindGlobalVariables(const char *name, uint32_t max_matches);
  371. /// Find the first global (or static) variable by name.
  372. ///
  373. /// \param[in] name
  374. /// The name of the global or static variable we are looking
  375. /// for.
  376. ///
  377. /// \return
  378. /// An SBValue that gets filled in with the found variable (if any).
  379. lldb::SBValue FindFirstGlobalVariable(const char *name);
  380. /// Find global and static variables by pattern.
  381. ///
  382. /// \param[in] name
  383. /// The pattern to search for global or static variables
  384. ///
  385. /// \param[in] max_matches
  386. /// Allow the number of matches to be limited to \a max_matches.
  387. ///
  388. /// \param[in] matchtype
  389. /// The match type to use.
  390. ///
  391. /// \return
  392. /// A list of matched variables in an SBValueList.
  393. lldb::SBValueList FindGlobalVariables(const char *name, uint32_t max_matches,
  394. MatchType matchtype);
  395. /// Find global functions by their name with pattern matching.
  396. ///
  397. /// \param[in] name
  398. /// The pattern to search for global or static variables
  399. ///
  400. /// \param[in] max_matches
  401. /// Allow the number of matches to be limited to \a max_matches.
  402. ///
  403. /// \param[in] matchtype
  404. /// The match type to use.
  405. ///
  406. /// \return
  407. /// A list of matched variables in an SBValueList.
  408. lldb::SBSymbolContextList FindGlobalFunctions(const char *name,
  409. uint32_t max_matches,
  410. MatchType matchtype);
  411. void Clear();
  412. /// Resolve a current file address into a section offset address.
  413. ///
  414. /// \param[in] file_addr
  415. /// The file address to resolve.
  416. ///
  417. /// \return
  418. /// An SBAddress which will be valid if...
  419. lldb::SBAddress ResolveFileAddress(lldb::addr_t file_addr);
  420. /// Resolve a current load address into a section offset address.
  421. ///
  422. /// \param[in] vm_addr
  423. /// A virtual address from the current process state that is to
  424. /// be translated into a section offset address.
  425. ///
  426. /// \return
  427. /// An SBAddress which will be valid if \a vm_addr was
  428. /// successfully resolved into a section offset address, or an
  429. /// invalid SBAddress if \a vm_addr doesn't resolve to a section
  430. /// in a module.
  431. lldb::SBAddress ResolveLoadAddress(lldb::addr_t vm_addr);
  432. /// Resolve a current load address into a section offset address
  433. /// using the process stop ID to identify a time in the past.
  434. ///
  435. /// \param[in] stop_id
  436. /// Each time a process stops, the process stop ID integer gets
  437. /// incremented. These stop IDs are used to identify past times
  438. /// and can be used in history objects as a cheap way to store
  439. /// the time at which the sample was taken. Specifying
  440. /// UINT32_MAX will always resolve the address using the
  441. /// currently loaded sections.
  442. ///
  443. /// \param[in] vm_addr
  444. /// A virtual address from the current process state that is to
  445. /// be translated into a section offset address.
  446. ///
  447. /// \return
  448. /// An SBAddress which will be valid if \a vm_addr was
  449. /// successfully resolved into a section offset address, or an
  450. /// invalid SBAddress if \a vm_addr doesn't resolve to a section
  451. /// in a module.
  452. lldb::SBAddress ResolvePastLoadAddress(uint32_t stop_id,
  453. lldb::addr_t vm_addr);
  454. SBSymbolContext ResolveSymbolContextForAddress(const SBAddress &addr,
  455. uint32_t resolve_scope);
  456. /// Read target memory. If a target process is running then memory
  457. /// is read from here. Otherwise the memory is read from the object
  458. /// files. For a target whose bytes are sized as a multiple of host
  459. /// bytes, the data read back will preserve the target's byte order.
  460. ///
  461. /// \param[in] addr
  462. /// A target address to read from.
  463. ///
  464. /// \param[out] buf
  465. /// The buffer to read memory into.
  466. ///
  467. /// \param[in] size
  468. /// The maximum number of host bytes to read in the buffer passed
  469. /// into this call
  470. ///
  471. /// \param[out] error
  472. /// Status information is written here if the memory read fails.
  473. ///
  474. /// \return
  475. /// The amount of data read in host bytes.
  476. size_t ReadMemory(const SBAddress addr, void *buf, size_t size,
  477. lldb::SBError &error);
  478. lldb::SBBreakpoint BreakpointCreateByLocation(const char *file,
  479. uint32_t line);
  480. lldb::SBBreakpoint
  481. BreakpointCreateByLocation(const lldb::SBFileSpec &file_spec, uint32_t line);
  482. lldb::SBBreakpoint
  483. BreakpointCreateByLocation(const lldb::SBFileSpec &file_spec, uint32_t line,
  484. lldb::addr_t offset);
  485. lldb::SBBreakpoint
  486. BreakpointCreateByLocation(const lldb::SBFileSpec &file_spec, uint32_t line,
  487. lldb::addr_t offset, SBFileSpecList &module_list);
  488. lldb::SBBreakpoint
  489. BreakpointCreateByLocation(const lldb::SBFileSpec &file_spec, uint32_t line,
  490. uint32_t column, lldb::addr_t offset,
  491. SBFileSpecList &module_list);
  492. lldb::SBBreakpoint
  493. BreakpointCreateByLocation(const lldb::SBFileSpec &file_spec, uint32_t line,
  494. uint32_t column, lldb::addr_t offset,
  495. SBFileSpecList &module_list,
  496. bool move_to_nearest_code);
  497. lldb::SBBreakpoint BreakpointCreateByName(const char *symbol_name,
  498. const char *module_name = nullptr);
  499. // This version uses name_type_mask = eFunctionNameTypeAuto
  500. lldb::SBBreakpoint
  501. BreakpointCreateByName(const char *symbol_name,
  502. const SBFileSpecList &module_list,
  503. const SBFileSpecList &comp_unit_list);
  504. lldb::SBBreakpoint BreakpointCreateByName(
  505. const char *symbol_name,
  506. uint32_t
  507. name_type_mask, // Logical OR one or more FunctionNameType enum bits
  508. const SBFileSpecList &module_list,
  509. const SBFileSpecList &comp_unit_list);
  510. lldb::SBBreakpoint BreakpointCreateByName(
  511. const char *symbol_name,
  512. uint32_t
  513. name_type_mask, // Logical OR one or more FunctionNameType enum bits
  514. lldb::LanguageType symbol_language,
  515. const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list);
  516. lldb::SBBreakpoint BreakpointCreateByNames(
  517. const char *symbol_name[], uint32_t num_names,
  518. uint32_t
  519. name_type_mask, // Logical OR one or more FunctionNameType enum bits
  520. const SBFileSpecList &module_list,
  521. const SBFileSpecList &comp_unit_list);
  522. lldb::SBBreakpoint BreakpointCreateByNames(
  523. const char *symbol_name[], uint32_t num_names,
  524. uint32_t
  525. name_type_mask, // Logical OR one or more FunctionNameType enum bits
  526. lldb::LanguageType symbol_language,
  527. const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list);
  528. lldb::SBBreakpoint BreakpointCreateByNames(
  529. const char *symbol_name[], uint32_t num_names,
  530. uint32_t
  531. name_type_mask, // Logical OR one or more FunctionNameType enum bits
  532. lldb::LanguageType symbol_language,
  533. lldb::addr_t offset, const SBFileSpecList &module_list,
  534. const SBFileSpecList &comp_unit_list);
  535. lldb::SBBreakpoint BreakpointCreateByRegex(const char *symbol_name_regex,
  536. const char *module_name = nullptr);
  537. lldb::SBBreakpoint
  538. BreakpointCreateByRegex(const char *symbol_name_regex,
  539. const SBFileSpecList &module_list,
  540. const SBFileSpecList &comp_unit_list);
  541. lldb::SBBreakpoint BreakpointCreateByRegex(
  542. const char *symbol_name_regex, lldb::LanguageType symbol_language,
  543. const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list);
  544. lldb::SBBreakpoint
  545. BreakpointCreateBySourceRegex(const char *source_regex,
  546. const SBFileSpec &source_file,
  547. const char *module_name = nullptr);
  548. lldb::SBBreakpoint
  549. BreakpointCreateBySourceRegex(const char *source_regex,
  550. const SBFileSpecList &module_list,
  551. const SBFileSpecList &source_file);
  552. lldb::SBBreakpoint BreakpointCreateBySourceRegex(
  553. const char *source_regex, const SBFileSpecList &module_list,
  554. const SBFileSpecList &source_file, const SBStringList &func_names);
  555. lldb::SBBreakpoint BreakpointCreateForException(lldb::LanguageType language,
  556. bool catch_bp, bool throw_bp);
  557. lldb::SBBreakpoint BreakpointCreateByAddress(addr_t address);
  558. lldb::SBBreakpoint BreakpointCreateBySBAddress(SBAddress &address);
  559. /// Create a breakpoint using a scripted resolver.
  560. ///
  561. /// \param[in] class_name
  562. /// This is the name of the class that implements a scripted resolver.
  563. ///
  564. /// \param[in] extra_args
  565. /// This is an SBStructuredData object that will get passed to the
  566. /// constructor of the class in class_name. You can use this to
  567. /// reuse the same class, parametrizing with entries from this
  568. /// dictionary.
  569. ///
  570. /// \param module_list
  571. /// If this is non-empty, this will be used as the module filter in the
  572. /// SearchFilter created for this breakpoint.
  573. ///
  574. /// \param file_list
  575. /// If this is non-empty, this will be used as the comp unit filter in the
  576. /// SearchFilter created for this breakpoint.
  577. ///
  578. /// \return
  579. /// An SBBreakpoint that will set locations based on the logic in the
  580. /// resolver's search callback.
  581. lldb::SBBreakpoint BreakpointCreateFromScript(
  582. const char *class_name,
  583. SBStructuredData &extra_args,
  584. const SBFileSpecList &module_list,
  585. const SBFileSpecList &file_list,
  586. bool request_hardware = false);
  587. /// Read breakpoints from source_file and return the newly created
  588. /// breakpoints in bkpt_list.
  589. ///
  590. /// \param[in] source_file
  591. /// The file from which to read the breakpoints.
  592. ///
  593. /// \param[out] new_bps
  594. /// A list of the newly created breakpoints.
  595. ///
  596. /// \return
  597. /// An SBError detailing any errors in reading in the breakpoints.
  598. lldb::SBError BreakpointsCreateFromFile(SBFileSpec &source_file,
  599. SBBreakpointList &new_bps);
  600. /// Read breakpoints from source_file and return the newly created
  601. /// breakpoints in bkpt_list.
  602. ///
  603. /// \param[in] source_file
  604. /// The file from which to read the breakpoints.
  605. ///
  606. /// \param[in] matching_names
  607. /// Only read in breakpoints whose names match one of the names in this
  608. /// list.
  609. ///
  610. /// \param[out] new_bps
  611. /// A list of the newly created breakpoints.
  612. ///
  613. /// \return
  614. /// An SBError detailing any errors in reading in the breakpoints.
  615. lldb::SBError BreakpointsCreateFromFile(SBFileSpec &source_file,
  616. SBStringList &matching_names,
  617. SBBreakpointList &new_bps);
  618. /// Write breakpoints to dest_file.
  619. ///
  620. /// \param[in] dest_file
  621. /// The file to which to write the breakpoints.
  622. ///
  623. /// \return
  624. /// An SBError detailing any errors in writing in the breakpoints.
  625. lldb::SBError BreakpointsWriteToFile(SBFileSpec &dest_file);
  626. /// Write breakpoints listed in bkpt_list to dest_file.
  627. ///
  628. /// \param[in] dest_file
  629. /// The file to which to write the breakpoints.
  630. ///
  631. /// \param[in] bkpt_list
  632. /// Only write breakpoints from this list.
  633. ///
  634. /// \param[in] append
  635. /// If \b true, append the breakpoints in bkpt_list to the others
  636. /// serialized in dest_file. If dest_file doesn't exist, then a new
  637. /// file will be created and the breakpoints in bkpt_list written to it.
  638. ///
  639. /// \return
  640. /// An SBError detailing any errors in writing in the breakpoints.
  641. lldb::SBError BreakpointsWriteToFile(SBFileSpec &dest_file,
  642. SBBreakpointList &bkpt_list,
  643. bool append = false);
  644. uint32_t GetNumBreakpoints() const;
  645. lldb::SBBreakpoint GetBreakpointAtIndex(uint32_t idx) const;
  646. bool BreakpointDelete(break_id_t break_id);
  647. lldb::SBBreakpoint FindBreakpointByID(break_id_t break_id);
  648. // Finds all breakpoints by name, returning the list in bkpt_list. Returns
  649. // false if the name is not a valid breakpoint name, true otherwise.
  650. bool FindBreakpointsByName(const char *name, SBBreakpointList &bkpt_list);
  651. void GetBreakpointNames(SBStringList &names);
  652. void DeleteBreakpointName(const char *name);
  653. bool EnableAllBreakpoints();
  654. bool DisableAllBreakpoints();
  655. bool DeleteAllBreakpoints();
  656. uint32_t GetNumWatchpoints() const;
  657. lldb::SBWatchpoint GetWatchpointAtIndex(uint32_t idx) const;
  658. bool DeleteWatchpoint(lldb::watch_id_t watch_id);
  659. lldb::SBWatchpoint FindWatchpointByID(lldb::watch_id_t watch_id);
  660. lldb::SBWatchpoint WatchAddress(lldb::addr_t addr, size_t size, bool read,
  661. bool write, SBError &error);
  662. bool EnableAllWatchpoints();
  663. bool DisableAllWatchpoints();
  664. bool DeleteAllWatchpoints();
  665. lldb::SBBroadcaster GetBroadcaster() const;
  666. lldb::SBType FindFirstType(const char *type);
  667. lldb::SBTypeList FindTypes(const char *type);
  668. lldb::SBType GetBasicType(lldb::BasicType type);
  669. lldb::SBValue CreateValueFromAddress(const char *name, lldb::SBAddress addr,
  670. lldb::SBType type);
  671. lldb::SBValue CreateValueFromData(const char *name, lldb::SBData data,
  672. lldb::SBType type);
  673. lldb::SBValue CreateValueFromExpression(const char *name, const char *expr);
  674. SBSourceManager GetSourceManager();
  675. lldb::SBInstructionList ReadInstructions(lldb::SBAddress base_addr,
  676. uint32_t count);
  677. lldb::SBInstructionList ReadInstructions(lldb::SBAddress base_addr,
  678. uint32_t count,
  679. const char *flavor_string);
  680. lldb::SBInstructionList GetInstructions(lldb::SBAddress base_addr,
  681. const void *buf, size_t size);
  682. // The "WithFlavor" is necessary to keep SWIG from getting confused about
  683. // overloaded arguments when using the buf + size -> Python Object magic.
  684. lldb::SBInstructionList GetInstructionsWithFlavor(lldb::SBAddress base_addr,
  685. const char *flavor_string,
  686. const void *buf,
  687. size_t size);
  688. lldb::SBInstructionList GetInstructions(lldb::addr_t base_addr,
  689. const void *buf, size_t size);
  690. lldb::SBInstructionList GetInstructionsWithFlavor(lldb::addr_t base_addr,
  691. const char *flavor_string,
  692. const void *buf,
  693. size_t size);
  694. lldb::SBSymbolContextList FindSymbols(const char *name,
  695. lldb::SymbolType type = eSymbolTypeAny);
  696. bool operator==(const lldb::SBTarget &rhs) const;
  697. bool operator!=(const lldb::SBTarget &rhs) const;
  698. bool GetDescription(lldb::SBStream &description,
  699. lldb::DescriptionLevel description_level);
  700. lldb::SBValue EvaluateExpression(const char *expr);
  701. lldb::SBValue EvaluateExpression(const char *expr,
  702. const SBExpressionOptions &options);
  703. lldb::addr_t GetStackRedZoneSize();
  704. bool IsLoaded(const lldb::SBModule &module) const;
  705. lldb::SBLaunchInfo GetLaunchInfo() const;
  706. void SetLaunchInfo(const lldb::SBLaunchInfo &launch_info);
  707. protected:
  708. friend class SBAddress;
  709. friend class SBBlock;
  710. friend class SBBreakpointList;
  711. friend class SBBreakpointNameImpl;
  712. friend class SBDebugger;
  713. friend class SBExecutionContext;
  714. friend class SBFunction;
  715. friend class SBInstruction;
  716. friend class SBModule;
  717. friend class SBPlatform;
  718. friend class SBProcess;
  719. friend class SBSection;
  720. friend class SBSourceManager;
  721. friend class SBSymbol;
  722. friend class SBValue;
  723. friend class SBVariablesOptions;
  724. // Constructors are private, use static Target::Create function to create an
  725. // instance of this class.
  726. lldb::TargetSP GetSP() const;
  727. void SetSP(const lldb::TargetSP &target_sp);
  728. private:
  729. lldb::TargetSP m_opaque_sp;
  730. };
  731. } // namespace lldb
  732. #endif // LLDB_API_SBTARGET_H