forked from git-for-windows/git
-
Notifications
You must be signed in to change notification settings - Fork 106
Trace2 V3 (squash/fixup of V1+V2) #100
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
Merged
jeffhostetler
merged 25 commits into
microsoft:vfs-2.20.1
from
jeffhostetler:gvfs-trace2-v3
Jan 4, 2019
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
81291af
Revert "pack-objects: add trace2 regions"
jeffhostetler b837111
Revert "gvfs:trace2: add trace2 tracing around read_object_process"
jeffhostetler 089a0c7
Revert "gvfs:trace2: add region/data events for status deserialization"
jeffhostetler eebf43a
Revert "trace2: instrument reading and writing the index"
jeffhostetler 2dc5fab
Revert "trace2: add child classification for transport processes"
jeffhostetler 39fa714
Revert "trace2: classify some child processes"
jeffhostetler fed7162
Revert "trace2: add trace2 tracing of major regions in wt-status"
jeffhostetler 095fc20
Revert "trace2: create new combined trace facility"
jeffhostetler c849c28
trace2: (V3) create new combined trace facility
jeffhostetler 3adeefc
trace2: collect platform-specific process information
jeffhostetler ef2f927
trace2:data: add trace2 regions to wt-status
jeffhostetler 0b2eb68
trace2:data: add editor/pager child classification
jeffhostetler a1ab077
trace2:data: add trace2 sub-process classification
jeffhostetler cba8ef2
trace2:data: add trace2 transport child classification
jeffhostetler 9afaef2
trace2:data: add trace2 hook classification
jeffhostetler 517c6d8
trace2:data: add trace2 instrumentation to index read/write
jeffhostetler d9bbeed
pack-objects: add trace2 regions
derrickstolee 0bfdd41
trace2:data: add subverb to checkout command
jeffhostetler b006aff
trace2:data: add subverb to reset command
jeffhostetler 68d0a78
trace2:data: add subverb for rebase
jeffhostetler 7336c10
trace2:data: add vfs stats
jeffhostetler ba1e59f
trace2: t/helper/test-trace2
jeffhostetler a495882
DROPME: keep inherited GIT_TR2 env vars when running test suite
jeffhostetler dc8019e
gvfs:trace2:data: add trace2 tracing around read_object_process
jeffhostetler f4e9264
gvfs:trace2:data add status serialization/deserialization information
jeffhostetler File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| #include "../../cache.h" | ||
| #include "../../json-writer.h" | ||
| #include <Psapi.h> | ||
| #include <tlHelp32.h> | ||
|
|
||
| /* | ||
| * Find the process data for the given PID in the given snapshot | ||
| * and update the PROCESSENTRY32 data. | ||
| */ | ||
| static int find_pid(DWORD pid, HANDLE hSnapshot, PROCESSENTRY32 *pe32) | ||
| { | ||
| pe32->dwSize = sizeof(PROCESSENTRY32); | ||
|
|
||
| if (Process32First(hSnapshot, pe32)) { | ||
| do { | ||
| if (pe32->th32ProcessID == pid) | ||
| return 1; | ||
| } while (Process32Next(hSnapshot, pe32)); | ||
| } | ||
| return 0; | ||
| } | ||
|
|
||
| /* | ||
| * Accumulate JSON array: | ||
| * [ | ||
| * exe-name-parent, | ||
| * exe-name-grand-parent, | ||
| * ... | ||
| * ] | ||
| * | ||
| * Note: we only report the filename of the process executable; the | ||
| * only way to get its full pathname is to use OpenProcess() | ||
| * and GetModuleFileNameEx() or QueryfullProcessImageName() | ||
| * and that seems rather expensive (on top of the cost of | ||
| * getting the snapshot). | ||
| */ | ||
| static void get_processes(struct json_writer *jw, HANDLE hSnapshot) | ||
| { | ||
| PROCESSENTRY32 pe32; | ||
| DWORD pid; | ||
|
|
||
| pid = GetCurrentProcessId(); | ||
|
|
||
| /* We only want parent processes, so skip self. */ | ||
| if (!find_pid(pid, hSnapshot, &pe32)) | ||
| return; | ||
| pid = pe32.th32ParentProcessID; | ||
|
|
||
| while (find_pid(pid, hSnapshot, &pe32)) { | ||
|
|
||
| jw_array_string(jw, pe32.szExeFile); | ||
|
|
||
| pid = pe32.th32ParentProcessID; | ||
| } | ||
| } | ||
|
|
||
| /* | ||
| * Emit JSON data for the current and parent processes. Individual | ||
| * trace2 targets can decide how to actually print it. | ||
| */ | ||
| static void get_ancestry(void) | ||
| { | ||
| HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); | ||
|
|
||
| if (hSnapshot != INVALID_HANDLE_VALUE) { | ||
| struct json_writer jw = JSON_WRITER_INIT; | ||
|
|
||
| jw_array_begin(&jw, 0); | ||
| get_processes(&jw, hSnapshot); | ||
| jw_end(&jw); | ||
|
|
||
| trace2_data_json("process", the_repository, | ||
| "windows/ancestry", &jw); | ||
|
|
||
| jw_release(&jw); | ||
| CloseHandle(hSnapshot); | ||
| } | ||
| } | ||
|
|
||
| /* | ||
| * Is a debugger attached to the current process? | ||
| * | ||
| * This will catch debug runs (where the debugger started the process). | ||
| * This is the normal case. Since this code is called during our startup, | ||
| * it will not report instances where a debugger is attached dynamically | ||
| * to a running git process, but that is relatively rare. | ||
| */ | ||
| static void get_is_being_debugged(void) | ||
| { | ||
| if (IsDebuggerPresent()) | ||
| trace2_data_intmax("process", the_repository, | ||
| "windows/debugger_present", 1); | ||
| } | ||
|
|
||
| void trace2_collect_process_info(void) | ||
| { | ||
| if (!trace2_is_enabled()) | ||
| return; | ||
|
|
||
| get_is_being_debugged(); | ||
| get_ancestry(); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.