def runScenario(assembly, debugger, target): process = target.GetProcess() res = lldb.SBCommandReturnObject() ci = debugger.GetCommandInterpreter() # Run debugger, wait until libcoreclr is loaded, # set breakpoint at Test.Main and stop there test.stop_in_main(debugger, assembly) ci.HandleCommand("clrstack", res) print(res.GetOutput()) print(res.GetError()) # Interpreter must have this command and able to run it test.assertTrue(res.Succeeded()) output = res.GetOutput() # Output is not empty test.assertTrue(len(output) > 0) match = re.search('OS Thread Id', output) # Specific string must be in the output test.assertTrue(match) match = re.search('Failed to start', output) # Check if a fail was reported test.assertFalse(match) # TODO: test other use cases # Continue current process and checks its exit code test.exit_lldb(debugger, assembly)
def runScenario(assembly, debugger, target): process = target.GetProcess() res = lldb.SBCommandReturnObject() ci = debugger.GetCommandInterpreter() # Run debugger, wait until libcoreclr is loaded, # set breakpoint at Test.Main and stop there test.stop_in_main(debugger, assembly) ci.HandleCommand("clrthreads", res) print(res.GetOutput()) print(res.GetError()) # Interpreter must have this command and able to run it test.assertTrue(res.Succeeded()) output = res.GetOutput() # Output is not empty test.assertTrue(len(output) > 0) # Specific string must be in the output test.assertNotEqual(output.find("ThreadCount:"), -1) # TODO: test other use cases # Continue current process and checks its exit code test.exit_lldb(debugger, assembly)
def runScenario(assembly, debugger, target): process = target.GetProcess() res = lldb.SBCommandReturnObject() ci = debugger.GetCommandInterpreter() # Run debugger, wait until libcoreclr is loaded, # set breakpoint at Test.Main and stop there test.stop_in_main(debugger, assembly) md_addr = test.get_methoddesc(debugger, assembly, "Test.DumpIL") ci.HandleCommand("dumpil " + md_addr, res) print(res.GetOutput()) print(res.GetError()) # Interpreter must have this command and able to run it test.assertTrue(res.Succeeded()) insts = res.GetOutput() print(insts) # Function must have some instructions test.assertTrue(len(insts) > 0) match = re.search(r'IL_\w{4}:\sldstr.*test\sdumpil.*' + r'IL_\w{4}:\scall.*System\.Console::WriteLine.*' + r'IL_\w{4}:\sret', insts.replace('\n', ' ')) # Must have ldstr, call and ret instructions test.assertTrue(match) # TODO: test other use cases # Continue current process and checks its exit code test.exit_lldb(debugger, assembly)
def runScenario(assembly, debugger, target): process = target.GetProcess() res = lldb.SBCommandReturnObject() ci = debugger.GetCommandInterpreter() # Run debugger, wait until libcoreclr is loaded, # set breakpoint at Test.Main and stop there test.stop_in_main(debugger, assembly) # Set breakpoint ci.HandleCommand("bpmd " + assembly + " Test.UnlikelyInlined", res) out_msg = res.GetOutput() err_msg = res.GetError() print(out_msg) print(err_msg) # Interpreter must have this command and able to run it test.assertTrue(res.Succeeded()) # Output is not empty # Should be at least 'Adding pending breakpoints...' test.assertTrue(res.GetOutputSize() > 0) # Error message is empty test.assertTrue(res.GetErrorSize() == 0) # Delete all breakpoints ci.HandleCommand("bpmd -clearall", res) out_msg = res.GetOutput() err_msg = res.GetError() print(out_msg) print(err_msg) # Interpreter must have this command and able to run it test.assertTrue(res.Succeeded()) match = re.search('All pending breakpoints cleared.', out_msg) # Check for specific output test.assertTrue(match) # Error message is empty test.assertTrue(res.GetErrorSize() == 0) process.Continue() process.Continue() # Process must be exited test.assertEqual(process.GetState(), lldb.eStateExited) # The reason of this stop must be a breakpoint test.assertEqual(process.GetSelectedThread().GetStopReason(), lldb.eStopReasonNone) # # Delete all breakpoints, continue current process and checks its exit code test.exit_lldb(debugger, assembly)
def runScenario(assembly, debugger, target): process = target.GetProcess() res = lldb.SBCommandReturnObject() ci = debugger.GetCommandInterpreter() # Run debugger, wait until libcoreclr is loaded, # set breakpoint at Test.Main and stop there test.stop_in_main(debugger, assembly) ci.HandleCommand("dso", res) print(res.GetOutput()) print(res.GetError()) # Interpreter must have this command and able to run it test.assertTrue(res.Succeeded()) output = res.GetOutput() # Output is not empty test.assertTrue(len(output) > 0) # Get all objects objects = [] for line in output.split('\n'): match = re.match('([0-9a-fA-F]+)\s+([0-9a-fA-F]+)\s', line) # Not all lines list objects if match: groups = match.groups() # Match has exactly two subgroups test.assertEqual(len(groups), 2) obj_addr = groups[1] # Address must be a hex number test.assertTrue(test.is_hexnum(obj_addr)) objects.append(obj_addr) # There must be at least one object test.assertTrue(len(objects) > 0) for obj in objects: ci.HandleCommand("histobjfind " + obj, res) print(res.GetOutput()) print(res.GetError()) # Interpreter must have this command and able to run it test.assertTrue(res.Succeeded()) output = res.GetOutput() # Output is not empty test.assertTrue(len(output) > 0) match = re.search('GCCount', output) test.assertTrue(match) # TODO: test other use cases # Continue current process and checks its exit code test.exit_lldb(debugger, assembly)
def runScenario(assembly, debugger, target): process = target.GetProcess() res = lldb.SBCommandReturnObject() ci = debugger.GetCommandInterpreter() # Run debugger, wait until libcoreclr is loaded, # set breakpoint at Test.Main and stop there test.stop_in_main(debugger, assembly) # Set breakpoint ci.HandleCommand("bpmd " + assembly + " Test.UnlikelyInlined", res) out_msg = res.GetOutput() err_msg = res.GetError() print(out_msg) print(err_msg) # Interpreter must have this command and able to run it test.assertTrue(res.Succeeded()) # Output is not empty # Should be at least 'Adding pending breakpoints...' test.assertTrue(len(out_msg) > 0) # Error message is empty test.assertTrue(len(err_msg) == 0) # Delete all breakpoints ci.HandleCommand("bpmd -clearall", res) out_msg = res.GetOutput() err_msg = res.GetError() print(out_msg) print(err_msg) # Interpreter must have this command and able to run it test.assertTrue(res.Succeeded()) match = re.search('All pending breakpoints cleared.', out_msg) # Check for specific output test.assertTrue(match) # Error message is empty test.assertEqual(err_msg, '') process.Continue() # Process must be exited test.assertEqual(process.GetState(), lldb.eStateExited) # The reason of this stop must be a breakpoint test.assertEqual(process.GetSelectedThread().GetStopReason(), lldb.eStopReasonNone) # # Delete all breakpoints, continue current process and checks its exit code test.exit_lldb(debugger, assembly)
def runScenario(assembly, debugger, target): process = target.GetProcess() res = lldb.SBCommandReturnObject() ci = debugger.GetCommandInterpreter() # Run debugger, wait until libcoreclr is loaded, # set breakpoint at Test.Main and stop there test.stop_in_main(debugger, assembly) ci.HandleCommand("name2ee " + assembly + " Test.Main", res) print(res.GetOutput()) print(res.GetError()) # Interpreter must have this command and able to run it test.assertTrue(res.Succeeded()) output = res.GetOutput() # Output is not empty test.assertTrue(len(output) > 0) match = re.search('JITTED Code Address:\s+([0-9a-fA-F]+)', output) # Line matched test.assertTrue(match) groups = match.groups() # Match has a single subgroup test.assertEqual(len(groups), 1) jit_addr = groups[0] # Address must be a hex number test.assertTrue(test.is_hexnum(jit_addr)) ci.HandleCommand("ip2md " + jit_addr, res) print(res.GetOutput()) print(res.GetError()) # Interpreter must have this command and able to run it test.assertTrue(res.Succeeded()) output = res.GetOutput() # Output is not empty test.assertTrue(len(output) > 0) # Specific string must be in the output test.assertNotEqual(output.find("MethodDesc:"), -1) # TODO: test other use cases # Continue current process and checks its exit code test.exit_lldb(debugger, assembly)
def runScenario(assembly, debugger, target): process = target.GetProcess() res = lldb.SBCommandReturnObject() ci = debugger.GetCommandInterpreter() # Run debugger, wait until libcoreclr is loaded, # set breakpoint at Test.Main and stop there test.stop_in_main(debugger, assembly) ci.HandleCommand("name2ee " + assembly + " Test.Main", res) print(res.GetOutput()) print(res.GetError()) # Interpreter must have this command and able to run it test.assertTrue(res.Succeeded()) output = res.GetOutput() # Output is not empty test.assertTrue(len(output) > 0) match = re.search('Module:\s+[0-9a-fA-F]+', output) test.assertTrue(match) match = re.search('Assembly:\s+\S+', output) test.assertTrue(match) match = re.search('Token:\s+[0-9a-fA-F]+', output) test.assertTrue(match) match = re.search('MethodDesc:\s+[0-9a-fA-F]+', output) test.assertTrue(match) match = re.search('Name:\s+\S+', output) test.assertTrue(match) process.Continue() # Process must exit test.assertEqual(process.GetState(), lldb.eStateExited) # Process must exit with zero code test.assertEqual(process.GetExitStatus(), 0) # TODO: test other use cases # Continue current process and checks its exit code test.exit_lldb(debugger, assembly)
def runScenario(assembly, debugger, target): process = target.GetProcess() res = lldb.SBCommandReturnObject() ci = debugger.GetCommandInterpreter() # Process must be stopped here while libcoreclr loading. # This test usually fails on release version of coreclr # since we depend on 'LoadLibraryExW' symbol present. test.assertEqual(process.GetState(), lldb.eStateStopped) # The reason of this stop must be a breakpoint test.assertEqual(process.GetSelectedThread().GetStopReason(), lldb.eStopReasonBreakpoint) ci.HandleCommand("bpmd -nofuturemodule " + assembly + " Test.Main", res) out_msg = res.GetOutput() err_msg = res.GetError() print(out_msg) print(err_msg) # Interpreter must have this command and able to run it test.assertTrue(res.Succeeded()) # Output is not empty # Should be at least 'Adding pending breakpoints...' test.assertTrue(len(out_msg) == 0) # Error message is empty test.assertTrue(len(err_msg) == 0) process.Continue() # Process must be exited because of -nofuturemodule flag test.assertEqual(process.GetState(), lldb.eStateExited) # The reason of this stop must be a breakpoint test.assertEqual(process.GetSelectedThread().GetStopReason(), lldb.eStopReasonNone) # # Delete all breakpoints, continue current process and checks its exit code test.exit_lldb(debugger, assembly)
def runScenario(assembly, debugger, target): process = target.GetProcess() res = lldb.SBCommandReturnObject() ci = debugger.GetCommandInterpreter() # Run debugger, wait until libcoreclr is loaded, # set breakpoint at Test.Main and stop there test.stop_in_main(debugger, assembly) md_addr = test.get_methoddesc(debugger, assembly, "Test.UnlikelyInlined") ci.HandleCommand("bpmd -md %s" % md_addr, res) out_msg = res.GetOutput() err_msg = res.GetError() print(out_msg) print(err_msg) # Interpreter must have this command and able to run it test.assertTrue(res.Succeeded()) # Output is not empty # Should be at least 'Adding pending breakpoints...' test.assertTrue(len(out_msg) > 0) # Error message is empty test.assertTrue(len(err_msg) == 0) process.Continue() # Process must be stopped at UnlinkelyInlined test.assertEqual(process.GetState(), lldb.eStateStopped) # The reason of this stop must be a breakpoint test.assertEqual(process.GetSelectedThread().GetStopReason(), lldb.eStopReasonBreakpoint) # # Continue current process and checks its exit code test.exit_lldb(debugger, assembly)