commit | d4b0619012c46f9ed357cffaa7e70f98cbb468f1 | [log] [tgz] |
---|---|---|
author | Wenlong Mu <muwl182@163.com> | Wed Jul 19 18:59:14 2023 |
committer | GitHub <noreply@github.com> | Wed Jul 19 18:59:14 2023 |
tree | f31193728b7888c9f3b4134916f2e932f5cef98b | |
parent | 639c6233cd5f66b2386df76e250569205bf2db44 [diff] |
i#725: Re-expose the Windows detach in drconfig (#6205) 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: [#725](https://github.com/DynamoRIO/dynamorio/issues/725)
DynamoRIO is a runtime code manipulation system that supports code transformations on any part of a program, while it executes. DynamoRIO exports an interface for building dynamic tools for a wide variety of uses: program analysis and understanding, profiling, instrumentation, optimization, translation, etc. Unlike many dynamic tool systems, DynamoRIO is not limited to insertion of callouts/trampolines and allows arbitrary modifications to application instructions via a powerful IA-32/AMD64/ARM/AArch64 instruction manipulation library. DynamoRIO provides efficient, transparent, and comprehensive manipulation of unmodified applications running on stock operating systems (Windows, Linux, or Android) and commodity IA-32, AMD64, ARM, and AArch64 hardware. Mac OSX support is in progress.
DynamoRIO is the basis for some well-known external tools:
Tools built on DynamoRIO and available in the release package include:
DynamoRIO‘s powerful API abstracts away the details of the underlying infrastructure and allows the tool builder to concentrate on analyzing or modifying the application’s runtime code stream. API documentation is included in the release package and can also be browsed online. Slides from our past tutorials are also available.
DynamoRIO is available free of charge as a binary package for both Windows and Linux. DynamoRIO's source code is available primarily under a BSD license.
Use the discussion list to ask questions.
To report a bug, use the issue tracker.
See also the DynamoRIO home page: http://dynamorio.org/