6import isystem.connect
as ic
7from typing
import Tuple
9EXAMPLE_TRD_FILE =
"example.trd"
10EXAMPLE_XML_TRACE_FILE_NAME =
"example_trace_data.xml"
11EXAMPLE_BIN_TRACE_FILE_NAME = f
"{EXAMPLE_XML_TRACE_FILE_NAME}.BIN"
14def export_data(conn_mgr: ic.ConnectionMgr) -> Tuple[str, str]:
16 Export example .trd data to trace XML, and return path to a created XML file.
17 NOTE: Only export files
if they do
not exists yet.
19 ide_ctrl = ic.CIDEController(conn_mgr)
20 workspace_dir = ide_ctrl.getPath(ic.CIDEController.WORKSPACE_DIR)
22 trd_file_path = EXAMPLE_TRD_FILE
23 xml_file_path = os.path.join(workspace_dir, EXAMPLE_XML_TRACE_FILE_NAME)
24 bin_file_path = os.path.join(workspace_dir, EXAMPLE_BIN_TRACE_FILE_NAME)
26 if os.path.exists(xml_file_path)
and os.path.exists(bin_file_path):
27 print(
"Trace data files already exists, nothing to do...")
29 print(
"Exporting .trd data to trace XML...")
31 trace_ctrl = ic.CTraceController(conn_mgr, trd_file_path,
"u")
32 trace_ctrl.waitUntilLoaded(10000, isThrow=
True)
34 trace_data = ic.CTraceData.createInstance(trace_ctrl, xml_file_path, 0, 0,
False)
35 trace_data.closeParser()
36 assert os.path.exists(xml_file_path)
38 trace_data = ic.CTraceData.createInstance(trace_ctrl, bin_file_path, 0, 0,
True)
39 trace_data.closeParser()
40 assert os.path.exists(bin_file_path)
41 trace_ctrl.closeDiscard()
42 print(f
"\t{xml_file_path}\n\t{bin_file_path}")
44 return xml_file_path, bin_file_path