简体   繁体   中英

LLDB: is it possible to display graphics from lldb session?

I would like to display a plot from LLDB session, is that possible?

plt.figure()
plt.title('Test')
plt.imshow(array, cmap='gray')
plt.show()

Right now, when i do that through the "command script import ~/script.py"; the session is stuck!

This works correctly in command-line lldb (or at least it does for me...)

That it doesn't work when trying to share the connection to the Window Server with Xcode (since lldb is running in the Xcode app process) is not entirely surprising. Doing plt.figure() seems to stall, though it wasn't immediately clear to me what Python thought it was doing when you called this method. It was not stalled somewhere obvious.

I don't think lldb has anything to do with this one way or the other (especially since command-line lldb works.) You're more likely to figure out how to get this working by asking the MatPlotLib folks if they have any experience sharing GUI's when the python is an embedded interpreter, especially in something complex like Xcode.

You might also see if they have any way to call out to an out-of-process renderer. That might get around the complexities of living inside Xcode.

I had a similar issue while plotting custom objects in Xcode. The lldb session crashed when calling plt.plot().

I used matplotlib with the Agg backend and was able to plot and save the generated plots at a convenient location. However you won't be able to show them directly from lldb in Xcode with the Agg backend.

Here is how my code looked like:

import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import numpy as np


plt.plot([1,2,3,4,5])
plt.title("Title")
plt.savefig("your/path")
plt.close()

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM