<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/81795>81795</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            LLDB python: 'unknown error' when calling EvaluateExpression
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          briandw
      </td>
    </tr>
</table>

<pre>
    I'm trying to use the EvaluateExpression functionality from LLDB in Python.
It looks like it works but the return type is always Error.

Run the included sample below and it will call the function foo, but the result is 'unknown error' 

```
from pathlib import Path
import lldb
import os
from lldb import SBError, SBThread

def main():
    
    c_code = \
"""
#include <stdio.h>

void foo(int i){
    printf(\"Hello from foo %i\\n\", i);
}

int main(void){
  return 0;
}
"""
   #Compile the main code
    main_file = Path("main.c")
    main_file.write_text(c_code)
    os.system('clang -g -O0 main.c -o main')
    
    debugger = lldb.SBDebugger.Create()
    debugger.SetAsync(False)
    target = debugger.CreateTarget("main")
    break_point_main = target.BreakpointCreateByName("main")

    launch_info = lldb.SBLaunchInfo(["./main"])
 launch_info.SetWorkingDirectory(os.getcwd())
    error = SBError()
 process = target.Launch(launch_info, error)
    
    assert target.IsValid()
    assert process.IsValid()
    assert break_point_main.IsValid()
    
    state = process.GetState()
 assert state == lldb.eStateStopped

    thread: SBThread = process.GetSelectedThread()
    frame = thread.GetSelectedFrame()
 assert frame.IsValid()
    assert thread.IsValid()

    expr1: str = "int $x=4"
    result_t = target.EvaluateExpression(expr1)
 error_t: SBError = result_t.GetError()
    print(f"result_t: {result_t}, {error_t}")

    expr2: str = "(void)foo($x)"
    result_f = frame.EvaluateExpression(expr2)
    error_f: SBError = result_t.GetError()
    print(f"result_t: {result_f}, {error_f}")
 #Result should be something other than error
    
    # foo prints out the message, as seen in the stdout, so why is there an error?
    text = process.GetSTDOUT(1024)
    print(text)
    
if __name__ == "__main__":
    main()```
 
I'm running this on 
lldb version 17.0.6   
Python 3.11.0

Both mac M2 and a x86_64 Ubuntu machine.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0Vk1v4zgP_jXKhajhyE6dHnKYJM37FpjdGUw7u0dDtulYW1kKJLpp_v1CspM4H4M5LRC0iUg-D0mRFIVzcqsRF2y2ZLP1RHTUGLsorBS62k8KUx0WL4xnLZA9SL0FMtA5BGoQnj-E6gTh8-fOonPSaKg7XZI0WihJB6itaeHr1_USpIbvB2qMjli8ZvGXFwJlzLsDJd8RJMHe2HcHRUcB2SJ1VgMddgjSgVB7cXDwbK2xA0D_90eng77UpeoqrMCJdqcQClRmD0JXAVoqBaVQKqgePYTaGMZXI0rXKfJsjGedftdmrwE9I-MZjEnZYzx8ws8Q5E5Qo2QBst0ZS_BdUNNLhwOlquLiwLiRtZceTV-Xzz3pCl6Xb41FUY3JK6yhFVIzPmf8iSXDMQDA-VuZl6ZCYMka2Gw1mHM-fIafyZA0YMnKUSVN1LDkecz1YWTVp2kuNYH0hNnyTLOzUlPtPZmtGOf_R6VMf-e1McD4THrBbKV7uQ8pYCQDBsvWYzrPMYTmmS_ZhoqI7xhfBuYTwZOVaXdS9WXqMcEn5Oy5P8prr-BzFG7L55P786gMcE93tKO9lYQ54ScxPu-zfKFpXOQOjrANcFmphN7CwxYevsXQY8ODGYLMLizP3yosuu0WbXDNV0b0ulwPZ9HKoiAcLv_GJHpF-uIOumR8vhHKXTpHwm6RAmx1ifcWJOcUXCegsCje852RmvKQTY_Rw0VLLwuiHmt5-FO0eB_rjKhEp8sml7o24zi_huMXXZtQVUvGecT45ogzW5_dGiH4sP829l3q7VpaLMnYA-Nz46ItUrmvhnSNIwqNHZhP_TZK6c6aEp0bh9l7xvh8xOsLepgQd29SOIeWjggv7i-hZHV9d4PSQPkbreuL-JX6-ZsjQX2VHxn-h_RK10U04J-0T3eCQfeVzG6H1fUtUj-eki-nUXXDhApLwmoYZFdu1la0vXM90thiY49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