-
Notifications
You must be signed in to change notification settings - Fork 566
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
i#725: Re-expose the Windows detach in drconfig #6205
Conversation
The old way to trigger detach on the Windows platform is the no-longer-supported "drcontrol" front-end. Re-exposing the detach feature in drconfig front-end on the Windows platform.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part looks fine. What about testing? We would like an automated test. See e.g. client.attach_test which has support in multiple places to accomplish an attach from another process: see git grep '<attach'
. If you want to separate that out to a separate PR, since it is a little more complex than a regular test, that would be ok: in that case please add to the PR description here how you manually tested this.
I thought it would be clearer to submit the requests separately, so I described my manual testing approach in the PR description. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I will merge this in. Thank you for contributing this PR!
The old way to trigger detach on the Windows platform is the no-longer-supported "drcontrol" front-end. Re-exposing the detach feature in drconfig front-end on the Windows platform. The following briefly describes my manual testing process, and I'll continue to submit an automated testing tool in a new PR soon. I wrote my own continuously running example as a manual test case for DynamoRIO, which counts the time of summing the first 1 billion numbers in real time. I'd like to use the real-time output of the test case to present the running state of the program. ``` #include <iostream> #include <chrono> #define LOOPCOUNT 100000; // Function to perform a computationally intensive task void performTask() { //calculate the sum of the first 1 billion numbers long long unsigned sum = 0; for (int i = 1; i <= 1000000000; ++i) { sum += i; } std::cout << "The sum of the first 1 billion numbers: " << sum << std::endl; } void single_loop() { // Start the timer auto start = std::chrono::high_resolution_clock::now(); // Perform the computationally intensive task performTask(); // Stop the timer auto end = std::chrono::high_resolution_clock::now(); // Calculate the elapsed time auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(end - start); // Print the elapsed time std::cout << "Elapsed time: " << duration.count() << " milliseconds" << std::endl; } int main() { int counts = LOOPCOUNT; for (int i = 0; i < counts;i++) { single_loop(); } return 0; } ``` Here are the steps to perform a manual test: 1. Execute our test case: ./SumOneBillion.exe 2. Use the "ps" command to get the target process ID: ps | grep SumOneBillion 3. Use "-attach" option to instrument the target process ID: .\drrun.exe -attach pid -c64 D:\dynamorio\build_debug\api\bin\inscount.dll 4. Use "-detach" option to stop the instrumentation:.\drconfig.exe -detach pid The output of the test case and the DynamoRIO in debug version is like following. > The sum of the first 1 billion numbers: 500000000500000000 > Elapsed time: 192 milliseconds > The sum of the first 1 billion numbers: 500000000500000000 > Elapsed time: 191 milliseconds > The sum of the first 1 billion numbers: 500000000500000000 > Elapsed time: 191 milliseconds **> <Starting application D:\vs_demos_repos\SumOneBillion\x64\Release\SumOneBillion.exe (16300)> > <cannot remove dll from rbtree: at root/min + can't find real tree> > <Running on newer-than-this-build "Microsoft Windows 10-2009 x64"> > <Early threads found> > <Initial options = -no_dynamic_options -client_lib 'D:\dynamorio\build_debug\api\bin\inscount.dll;0;' -client_lib64 'D:\dynamorio\build_debug\api\bin\inscount.dll;0;' -code_api -probe_api -stack_size 56K -max_elide_jmp 0 -max_elide_call 0 -no_inline_ignored_syscalls -native_exec_default_list '' -no_native_exec_managed_code -skip_terminating_threads -no_indcall2direct > > Client inscount is running** > <CURIOSITY : instr_get_opcode(instr_new) != instr_get_opcode(instr_old) in file D:\DynamoRIODetach\dynamorio-master\core\win32\callback.c line 2079 > version 9.93.19549, custom build > -no_dynamic_options -client_lib 'D:\dynamorio\build_debug\api\bin\inscount.dll;0;' -client_lib64 'D:\dynamorio\build_debug\api\bin\inscount.dll;0;' -code_api -probe_api -stack_size 56K -max_elide_jmp 0 -max_elide_call 0 -no_inline_ignored_syscalls -native_exec_default_list '' > D:\dynamorio\build_debug\lib64\debug\dynamorio.dll=0x0000000015000000 > D:\dynamorio\build_debug\api\bin\inscount.dll=0x00007ff721f90000 > C:\WINDOWS/system32/KERNEL32.dll=0x0000026257e00000 > C:\WINDOWS/system32/KERNELBASE.dll=0x0000026257f40000 > D:\dynamorio\build_debug\ext\lib64\debug/drmgr.dll=0x00007ff721ff0000> > <CURIOSITY : instr_new == instrlist_first(ilist) || instr_new == instr_get_next(instrlist_first(ilist)) in file D:\dynamorio\core\win32\callback.c line 2082 > version 9.93.19549, custom build > -no_dynamic_options -client_lib 'D:\dynamorio\build_debug\api\bin\inscount.dll;0;' -client_lib64 'D:\dynamorio\build_debug\api\bin\inscount.dll;0;' -code_api -probe_api -stack_size 56K -max_elide_jmp 0 -max_elide_call 0 -no_inline_ignored_syscalls -native_exec_default_list '' > D:\dynamorio\build_debug\lib64\debug\dynamorio.dll=0x0000000015000000 > D:\dynamorio\build_debug\api\bin\inscount.dll=0x00007ff721f90000 > C:\WINDOWS/system32/KERNEL32.dll=0x0000026257e00000 > C:\WINDOWS/system32/KERNELBASE.dll=0x0000026257f40000 > D:\dynamorio\build_debug\ext\lib64\debug/drmgr.dll=0x00007ff721ff0000> > <Cleaning hooked Nt wrapper @0x00007ffeba790800 sysnum=0x1c2> > The sum of the first 1 billion numbers: 500000000500000000 > Elapsed time: 417 milliseconds > The sum of the first 1 billion numbers: 500000000500000000 > Elapsed time: 552 milliseconds > The sum of the first 1 billion numbers: 500000000500000000 > Elapsed time: 545 milliseconds > The sum of the first 1 billion numbers: 500000000500000000 > Elapsed time: 537 milliseconds > The sum of the first 1 billion numbers: 500000000500000000 > Elapsed time: 543 milliseconds > The sum of the first 1 billion numbers: 500000000500000000 > Elapsed time: 539 milliseconds > The sum of the first 1 billion numbers: 500000000500000000 > Elapsed time: 538 milliseconds **> <curiosity: rex.w on OPSZ_6_irex10_short4!> > <received nudge mask=0x4 id=0x00000000 arg=0x0000000000000000> > <Detaching from application D:\vs_demos_repos\SumOneBillion\x64\Release\SumOneBillion.exe (16300)> > <Detaching from process, entering final cleanup> > Instrumentation results: 20766267822 instructions executed** > The sum of the first 1 billion numbers: 500000000500000000 > Elapsed time: 194 milliseconds > The sum of the first 1 billion numbers: 500000000500000000 > Elapsed time: 194 milliseconds > The sum of the first 1 billion numbers: 500000000500000000 > Elapsed time: 194 milliseconds > Issue: [DynamoRIO#725](DynamoRIO#725)
The old way to trigger detach on the Windows platform is the no-longer-supported "drcontrol" front-end.
Re-exposing the detach feature in drconfig front-end on the Windows platform.
The following briefly describes my manual testing process, and I'll continue to submit an automated testing tool in a new PR soon.
I wrote my own continuously running example as a manual test case for DynamoRIO, which counts the time of summing the first 1 billion numbers in real time. I'd like to use the real-time output of the test case to present the running state of the program.
Here are the steps to perform a manual test:
The output of the test case and the DynamoRIO in debug version is like following.
Issue: #725