简体   繁体   English

LLDB:是否可以从lldb会话显示图形?

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

I would like to display a plot from LLDB session, is that possible? 我想显示LLDB会话中的图,可以吗?

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"; 现在,当我通过“命令脚本导入〜/ script.py”进行操作时; the session is stuck! 会话卡住了!

This works correctly in command-line lldb (or at least it does for me...) 这可以在命令行lldb中正常工作(或者至少对我有用...)

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. 尝试与Xcode共享到Window Server的连接时不起作用(因为lldb在Xcode应用程序进程中运行)并不完全令人惊讶。 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. 做plt.figure()似乎停滞了,尽管我还不清楚我在调用该方法时Python认为它在做什么。 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. 我不认为lldb与这一种或另一种方式有任何关系(尤其是因为命令行lldb可以工作。)您更有可能通过询问MatPlotLib人员是否有经验来弄清楚如何使其工作当python是嵌入式解释器时,尤其是在Xcode之类的复杂程序中,共享GUI。

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. 这可能会绕过Xcode内部的复杂性。

I had a similar issue while plotting custom objects in Xcode. 在Xcode中绘制自定义对象时遇到类似的问题。 The lldb session crashed when calling plt.plot(). 调用plt.plot()时,lldb会话崩溃。

I used matplotlib with the Agg backend and was able to plot and save the generated plots at a convenient location. 我将matplotlib与Agg后端一起使用,并且能够在方便的位置绘制并保存生成的图。 However you won't be able to show them directly from lldb in Xcode with the Agg backend. 但是,您将无法使用Agg后端直接从Xcode中的lldb显示它们。

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. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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