LLDB  mainline
ScriptInterpreter.cpp
Go to the documentation of this file.
1 //===-- ScriptInterpreter.cpp -----------------------------------*- 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 
10 
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <string>
14 
17 #include "lldb/Utility/Status.h"
18 #include "lldb/Utility/Stream.h"
20 
21 using namespace lldb;
22 using namespace lldb_private;
23 
24 ScriptInterpreter::ScriptInterpreter(Debugger &debugger,
25  lldb::ScriptLanguage script_lang)
26  : m_debugger(debugger), m_script_lang(script_lang) {}
27 
29 
31  std::vector<BreakpointOptions *> &bp_options_vec,
32  CommandReturnObject &result) {
34  result.AppendError(
35  "ScriptInterpreter::GetScriptCommands(StringList &) is not implemented.");
36 }
37 
39  WatchpointOptions *bp_options, CommandReturnObject &result) {
41  result.AppendError(
42  "ScriptInterpreter::GetScriptCommands(StringList &) is not implemented.");
43 }
44 
46  std::string return_value;
47 
48  switch (language) {
50  return_value = "None";
51  break;
53  return_value = "Python";
54  break;
56  return_value = "Unknown";
57  break;
58  }
59 
60  return return_value;
61 }
62 
64 ScriptInterpreter::StringToLanguage(const llvm::StringRef &language) {
65  if (language.equals_lower(LanguageToString(eScriptLanguageNone)))
66  return eScriptLanguageNone;
67  if (language.equals_lower(LanguageToString(eScriptLanguagePython)))
68  return eScriptLanguagePython;
70 }
71 
73  std::vector<BreakpointOptions *> &bp_options_vec,
74  const char *callback_text) {
75  Status return_error;
76  for (BreakpointOptions *bp_options : bp_options_vec) {
77  return_error = SetBreakpointCommandCallback(bp_options, callback_text);
78  if (return_error.Success())
79  break;
80  }
81  return return_error;
82 }
83 
85  std::vector<BreakpointOptions *> &bp_options_vec,
86  const char *function_name) {
87  for (BreakpointOptions *bp_options : bp_options_vec) {
88  SetBreakpointCommandCallbackFunction(bp_options, function_name);
89  }
90 }
91 
92 std::unique_ptr<ScriptInterpreterLocker>
94  return std::unique_ptr<ScriptInterpreterLocker>(
96 }
A class to manage flag bits.
Definition: Debugger.h:82
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
static std::string LanguageToString(lldb::ScriptLanguage language)
virtual std::unique_ptr< ScriptInterpreterLocker > AcquireInterpreterLock()
static lldb::ScriptLanguage StringToLanguage(const llvm::StringRef &string)
bool Success() const
Test for success condition.
Definition: Status.cpp:287
virtual void CollectDataForBreakpointCommandCallback(std::vector< BreakpointOptions *> &options, CommandReturnObject &result)
Status SetBreakpointCommandCallback(std::vector< BreakpointOptions *> &bp_options_vec, const char *callback_text)
Set the specified text as the callback for the breakpoint.
"lldb/Breakpoint/WatchpointOptions.h" Class that manages the options on a watchpoint.
void void AppendError(llvm::StringRef in_string)
"lldb/Breakpoint/BreakpointOptions.h" Class that manages the options on a breakpoint or breakpoint lo...
Definition: SBAddress.h:15
void SetBreakpointCommandCallbackFunction(std::vector< BreakpointOptions *> &bp_options_vec, const char *function_name)
virtual void CollectDataForWatchpointCommandCallback(WatchpointOptions *wp_options, CommandReturnObject &result)
void SetStatus(lldb::ReturnStatus status)
An error handling class.
Definition: Status.h:44