Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import lldb
- import tempfile
- import subprocess
- def get_gst_parent(gst_obj):
- return gst_obj.GetChildMemberWithName("parent")
- def get_gst_name(gst_obj):
- return gst_object.GetChildMemberWithName("name")
- def get_gst_root(gst_obj):
- parent = get_gst_parent(gst_obj)
- while parent.GetValueAsUnsigned() != 0:
- gst_obj = parent
- parent = get_gst_parent(gst_obj)
- return gst_obj
- def gst_dot(debugger, command, result, dict):
- error = lldb.SBError()
- gst_obj = lldb.frame.FindVariable(command).GetChildMemberWithName("object")
- root = get_gst_root(gst_obj)
- # FIXME: There must be a better way than EvaluateExpression
- # to execute a function.
- GST_DEBUG_GRAPH_SHOW_ALL = "(GstDebugGraphDetails)15";
- dot_data = lldb.frame.EvaluateExpression(
- 'gst_debug_bin_to_dot_data((GstBin*){}, {})'
- .format(
- root.GetValueAsUnsigned(),
- GST_DEBUG_GRAPH_SHOW_ALL))
- if dot_data.GetError().Fail():
- # Can happen if GStreamer is static and gst_debug_bin_to_dot_data is not referenced
- print dot_data.GetError().GetCString()
- return
- if dot_data.GetValueAsUnsigned() == 0:
- print "Error generating Graphviz data for {}".format(command)
- return
- dot_str = lldb.process.ReadCStringFromMemory(dot_data.GetValueAsUnsigned(), 0xffffff, error)
- if not error.Success:
- print "Error reading Graphviz data from memory!"
- return
- f = tempfile.NamedTemporaryFile(suffix = ".dot")
- f.write(dot_str)
- opener = "open"
- subprocess.call([opener, f.name])
- def __lldb_init_module (debugger, dict):
- debugger.HandleCommand('command script add -f gst.gst_dot gst_dot')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement