{"action":"created","comment":{"url":"https://api.github.com/repos/namhyung/uftrace/pulls/comments/218344979","pull_request_review_id":156259789,"id":218344979,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxODM0NDk3OQ==","diff_hunk":"@@ -0,0 +1,120 @@\n+#\n+# report-open-files.py\n+#\n+# uftrace-option: --nest-libcall -T open@filter,arg1/s,arg2/e:uft_open_flag,retval/i -T openat@filter,arg1,arg2/s,arg3/e:uft_open_flag,retval/i -T fopen@filter,arg1/s,arg2/s,retval\n+#\n+\n+from __future__ import print_function\n+import os\n+\n+UFTRACE_FUNC = [ \"open\", \"openat\", \"fopen\" ]\n+\n+UFT_OPEN_MODE_MASK = 0x3\n+uft_open_mode = [ \"O_RDONLY\", \"O_WRONLY\", \"O_RDWR\", \"O_XXX\" ]\n+\n+uft_open_flag = {\n+        \"O_CREAT\": 0100,\n+        \"O_EXCL\": 0200,\n+        \"O_NOCTTY\": 0400,\n+        \"O_TRUNC\": 01000,\n+        \"O_APPEND\": 02000,\n+        \"O_NONBLOCK\": 04000,\n+        \"O_DSYNC\": 010000,\n+        \"O_ASYNC\": 020000,\n+        \"O_DIRECT\": 040000,\n+        \"O_LARGEFILE\": 0100000,\n+        \"O_DIRECTORY\": 0200000,\n+        \"O_NOATIME\": 01000000,\n+        \"O_CLOEXEC\": 02000000,\n+        \"O_SYNC\": 04010000,\n+        \"O_PATH\": 010000000,\n+}\n+\n+open_map = {}\n+openat_map = {}\n+fopen_map = {}\n+open_pathname = \"\"\n+\n+def uftrace_begin():\n+    pass\n+\n+def uftrace_entry(ctx):\n+    global open_pathname\n+    if ctx.has_key(\"args\"):\n+        open_pathname = ctx[\"args\"][0]\n+        if ctx[\"name\"] == \"open\":\n+            open_mode = ctx[\"args\"][1]\n+            open_map[open_pathname] = open_mode\n+        elif ctx[\"name\"] == \"openat\":\n+            open_mode = ctx[\"args\"][2]\n+            openat_map[open_pathname] = open_mode\n+        elif ctx[\"name\"] == \"fopen\":\n+            open_mode = ctx[\"args\"][1]\n+            fopen_map[open_pathname] = open_mode\n+\n+def uftrace_exit(ctx):\n+    global open_pathname\n+    if ctx.has_key(\"retval\"):\n+        if ctx[\"name\"] == \"open\":\n+            #if ctx[\"retval\"] == -1:\n+            if ctx[\"retval\"] == 18446744073709551615:","path":"scripts/report-open-files.py","position":60,"original_position":60,"commit_id":"bbeaedeb01267ccd845ac20e2f56d9877750d897","original_commit_id":"bbeaedeb01267ccd845ac20e2f56d9877750d897","user":{"login":"namhyung","id":48503,"node_id":"MDQ6VXNlcjQ4NTAz","avatar_url":"https://avatars0.githubusercontent.com/u/48503?v=4","gravatar_id":"","url":"https://api.github.com/users/namhyung","html_url":"https://github.com/namhyung","followers_url":"https://api.github.com/users/namhyung/followers","following_url":"https://api.github.com/users/namhyung/following{/other_user}","gists_url":"https://api.github.com/users/namhyung/gists{/gist_id}","starred_url":"https://api.github.com/users/namhyung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/namhyung/subscriptions","organizations_url":"https://api.github.com/users/namhyung/orgs","repos_url":"https://api.github.com/users/namhyung/repos","events_url":"https://api.github.com/users/namhyung/events{/privacy}","received_events_url":"https://api.github.com/users/namhyung/received_events","type":"User","site_admin":false},"body":"This is because python deals with big numbers more than 64 bit.  It's hex: `0xffffffffffffffff`.  I don't know what's the best way to handle this.","created_at":"2018-09-18T08:42:48Z","updated_at":"2018-09-18T08:42:48Z","html_url":"https://github.com/namhyung/uftrace/pull/286#discussion_r218344979","pull_request_url":"https://api.github.com/repos/namhyung/uftrace/pulls/286","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/namhyung/uftrace/pulls/comments/218344979"},"html":{"href":"https://github.com/namhyung/uftrace/pull/286#discussion_r218344979"},"pull_request":{"href":"https://api.github.com/repos/namhyung/uftrace/pulls/286"}}},"pull_request":{"url":"https://api.github.com/repos/namhyung/uftrace/pulls/286","id":157747708,"node_id":"MDExOlB1bGxSZXF1ZXN0MTU3NzQ3NzA4","html_url":"https://github.com/namhyung/uftrace/pull/286","diff_url":"https://github.com/namhyung/uftrace/pull/286.diff","patch_url":"https://github.com/namhyung/uftrace/pull/286.patch","issue_url":"https://api.github.com/repos/namhyung/uftrace/issues/286","number":286,"state":"open","locked":false,"title":"script: Add report-open-files.py","user":{"login":"honggyukim","id":19642328,"node_id":"MDQ6VXNlcjE5NjQyMzI4","avatar_url":"https://avatars3.githubusercontent.com/u/19642328?v=4","gravatar_id":"","url":"https://api.github.com/users/honggyukim","html_url":"https://github.com/honggyukim","followers_url":"https://api.github.com/users/honggyukim/followers","following_url":"https://api.github.com/users/honggyukim/following{/other_user}","gists_url":"https://api.github.com/users/honggyukim/gists{/gist_id}","starred_url":"https://api.github.com/users/honggyukim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/honggyukim/subscriptions","organizations_url":"https://api.github.com/users/honggyukim/orgs","repos_url":"https://api.github.com/users/honggyukim/repos","events_url":"https://api.github.com/users/honggyukim/events{/privacy}","received_events_url":"https://api.github.com/users/honggyukim/received_events","type":"User","site_admin":false},"body":"This patch adds report-open-files.py that collects all the open files\r\nbased on open() calls and shows its summary at the end of execution.\r\n\r\nThe output of this script is as follows:\r\n\r\n```\r\n  $ uftrace record -S scripts/report-open-files.py /usr/bin/gcc ~/hello.c\r\n    # 160 files are opened by 'cc1' (pid: 31754)\r\n\r\n           open mode    pathname\r\n    =================  ================================================\r\n            O_NOCTTY    /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed/bits/types.h\r\n            O_NOCTTY    /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed/stdlib.h\r\n            O_NOCTTY    /usr/include/x86_64-linux-gnu/bits/waitstatus.h\r\n            O_NOCTTY    /usr/local/include/bits/types.h\r\n            O_NOCTTY    /usr/lib/gcc/x86_64-linux-gnu/5/include/bits/stdio_lim.h\r\n            O_NOCTTY    /usr/lib/gcc/x86_64-linux-gnu/5/include/libio.h\r\n            O_NOCTTY    /usr/include/x86_64-linux-gnu/sys/mman.h\r\n               ...        ...\r\n\r\n  # 0 files are opened by 'as' (pid: 31755)\r\n\r\n  # 11 files are opened by 'ld' (pid: 31757)\r\n\r\n         open mode    pathname\r\n  =================  ================================================\r\n          O_RDONLY    /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crti.o\r\n          O_RDONLY    /usr/lib/gcc/x86_64-linux-gnu/5/crtbegin.o\r\n          O_RDONLY    /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2\r\n          O_RDONLY    /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o\r\n          O_RDONLY    /usr/lib/gcc/x86_64-linux-gnu/5/libgcc_s.so\r\n          O_RDONLY    /usr/lib/x86_64-linux-gnu/libc_nonshared.a\r\n          O_RDONLY    /lib/x86_64-linux-gnu/libc.so.6\r\n          O_RDONLY    /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libc.so\r\n          O_RDONLY    /tmp/ccQpg4sP.o\r\n          O_RDONLY    /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crtn.o\r\n          O_RDONLY    /usr/lib/gcc/x86_64-linux-gnu/5/crtend.o\r\n             ...        ...\r\n\r\n  # 2 files are opened by 'collect2' (pid: 31756)\r\n\r\n                 open mode    pathname\r\n  =========================  ================================================\r\n  O_CREAT|O_WRONLY|O_TRUNC    /tmp/ccGNm49Q.le\r\n  O_CREAT|O_WRONLY|O_TRUNC    /tmp/ccwGj2HX.ld\r\n\r\n  # 0 files are opened by 'gcc' (pid: 31743)\r\n```\r\n\r\nSigned-off-by: Honggyu Kim <honggyu.kp@gmail.com>","created_at":"2017-12-12T06:36:31Z","updated_at":"2018-09-18T08:42:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c43ee7617a00f9fd5410e3e8a279ab4efed55b50","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/namhyung/uftrace/pulls/286/commits","review_comments_url":"https://api.github.com/repos/namhyung/uftrace/pulls/286/comments","review_comment_url":"https://api.github.com/repos/namhyung/uftrace/pulls/comments{/number}","comments_url":"https://api.github.com/repos/namhyung/uftrace/issues/286/comments","statuses_url":"https://api.github.com/repos/namhyung/uftrace/statuses/bbeaedeb01267ccd845ac20e2f56d9877750d897","head":{"label":"honggyukim:script/report-open-files","ref":"script/report-open-files","sha":"bbeaedeb01267ccd845ac20e2f56d9877750d897","user":{"login":"honggyukim","id":19642328,"node_id":"MDQ6VXNlcjE5NjQyMzI4","avatar_url":"https://avatars3.githubusercontent.com/u/19642328?v=4","gravatar_id":"","url":"https://api.github.com/users/honggyukim","html_url":"https://github.com/honggyukim","followers_url":"https://api.github.com/users/honggyukim/followers","following_url":"https://api.github.com/users/honggyukim/following{/other_user}","gists_url":"https://api.github.com/users/honggyukim/gists{/gist_id}","starred_url":"https://api.github.com/users/honggyukim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/honggyukim/subscriptions","organizations_url":"https://api.github.com/users/honggyukim/orgs","repos_url":"https://api.github.com/users/honggyukim/repos","events_url":"https://api.github.com/users/honggyukim/events{/privacy}","received_events_url":"https://api.github.com/users/honggyukim/received_events","type":"User","site_admin":false},"repo":{"id":63523736,"node_id":"MDEwOlJlcG9zaXRvcnk2MzUyMzczNg==","name":"uftrace","full_name":"honggyukim/uftrace","private":false,"owner":{"login":"honggyukim","id":19642328,"node_id":"MDQ6VXNlcjE5NjQyMzI4","avatar_url":"https://avatars3.githubusercontent.com/u/19642328?v=4","gravatar_id":"","url":"https://api.github.com/users/honggyukim","html_url":"https://github.com/honggyukim","followers_url":"https://api.github.com/users/honggyukim/followers","following_url":"https://api.github.com/users/honggyukim/following{/other_user}","gists_url":"https://api.github.com/users/honggyukim/gists{/gist_id}","starred_url":"https://api.github.com/users/honggyukim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/honggyukim/subscriptions","organizations_url":"https://api.github.com/users/honggyukim/orgs","repos_url":"https://api.github.com/users/honggyukim/repos","events_url":"https://api.github.com/users/honggyukim/events{/privacy}","received_events_url":"https://api.github.com/users/honggyukim/received_events","type":"User","site_admin":false},"html_url":"https://github.com/honggyukim/uftrace","description":"Function (graph) tracer for user-space","fork":true,"url":"https://api.github.com/repos/honggyukim/uftrace","forks_url":"https://api.github.com/repos/honggyukim/uftrace/forks","keys_url":"https://api.github.com/repos/honggyukim/uftrace/keys{/key_id}","collaborators_url":"https://api.github.com/repos/honggyukim/uftrace/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/honggyukim/uftrace/teams","hooks_url":"https://api.github.com/repos/honggyukim/uftrace/hooks","issue_events_url":"https://api.github.com/repos/honggyukim/uftrace/issues/events{/number}","events_url":"https://api.github.com/repos/honggyukim/uftrace/events","assignees_url":"https://api.github.com/repos/honggyukim/uftrace/assignees{/user}","branches_url":"https://api.github.com/repos/honggyukim/uftrace/branches{/branch}","tags_url":"https://api.github.com/repos/honggyukim/uftrace/tags","blobs_url":"https://api.github.com/repos/honggyukim/uftrace/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/honggyukim/uftrace/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/honggyukim/uftrace/git/refs{/sha}","trees_url":"https://api.github.com/repos/honggyukim/uftrace/git/trees{/sha}","statuses_url":"https://api.github.com/repos/honggyukim/uftrace/statuses/{sha}","languages_url":"https://api.github.com/repos/honggyukim/uftrace/languages","stargazers_url":"https://api.github.com/repos/honggyukim/uftrace/stargazers","contributors_url":"https://api.github.com/repos/honggyukim/uftrace/contributors","subscribers_url":"https://api.github.com/repos/honggyukim/uftrace/subscribers","subscription_url":"https://api.github.com/repos/honggyukim/uftrace/subscription","commits_url":"https://api.github.com/repos/honggyukim/uftrace/commits{/sha}","git_commits_url":"https://api.github.com/repos/honggyukim/uftrace/git/commits{/sha}","comments_url":"https://api.github.com/repos/honggyukim/uftrace/comments{/number}","issue_comment_url":"https://api.github.com/repos/honggyukim/uftrace/issues/comments{/number}","contents_url":"https://api.github.com/repos/honggyukim/uftrace/contents/{+path}","compare_url":"https://api.github.com/repos/honggyukim/uftrace/compare/{base}...{head}","merges_url":"https://api.github.com/repos/honggyukim/uftrace/merges","archive_url":"https://api.github.com/repos/honggyukim/uftrace/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/honggyukim/uftrace/downloads","issues_url":"https://api.github.com/repos/honggyukim/uftrace/issues{/number}","pulls_url":"https://api.github.com/repos/honggyukim/uftrace/pulls{/number}","milestones_url":"https://api.github.com/repos/honggyukim/uftrace/milestones{/number}","notifications_url":"https://api.github.com/repos/honggyukim/uftrace/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/honggyukim/uftrace/labels{/name}","releases_url":"https://api.github.com/repos/honggyukim/uftrace/releases{/id}","deployments_url":"https://api.github.com/repos/honggyukim/uftrace/deployments","created_at":"2016-07-17T09:15:21Z","updated_at":"2018-08-15T04:34:01Z","pushed_at":"2018-09-18T06:19:10Z","git_url":"git://github.com/honggyukim/uftrace.git","ssh_url":"git@github.com:honggyukim/uftrace.git","clone_url":"https://github.com/honggyukim/uftrace.git","svn_url":"https://github.com/honggyukim/uftrace","homepage":"","size":4812,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"gpl-2.0","name":"GNU General Public License v2.0","spdx_id":"GPL-2.0","url":"https://api.github.com/licenses/gpl-2.0","node_id":"MDc6TGljZW5zZTg="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"namhyung:master","ref":"master","sha":"a2ca9a104adfdd7b2ac31e4807edabfb529f1f3d","user":{"login":"namhyung","id":48503,"node_id":"MDQ6VXNlcjQ4NTAz","avatar_url":"https://avatars0.githubusercontent.com/u/48503?v=4","gravatar_id":"","url":"https://api.github.com/users/namhyung","html_url":"https://github.com/namhyung","followers_url":"https://api.github.com/users/namhyung/followers","following_url":"https://api.github.com/users/namhyung/following{/other_user}","gists_url":"https://api.github.com/users/namhyung/gists{/gist_id}","starred_url":"https://api.github.com/users/namhyung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/namhyung/subscriptions","organizations_url":"https://api.github.com/users/namhyung/orgs","repos_url":"https://api.github.com/users/namhyung/repos","events_url":"https://api.github.com/users/namhyung/events{/privacy}","received_events_url":"https://api.github.com/users/namhyung/received_events","type":"User","site_admin":false},"repo":{"id":16727749,"node_id":"MDEwOlJlcG9zaXRvcnkxNjcyNzc0OQ==","name":"uftrace","full_name":"namhyung/uftrace","private":false,"owner":{"login":"namhyung","id":48503,"node_id":"MDQ6VXNlcjQ4NTAz","avatar_url":"https://avatars0.githubusercontent.com/u/48503?v=4","gravatar_id":"","url":"https://api.github.com/users/namhyung","html_url":"https://github.com/namhyung","followers_url":"https://api.github.com/users/namhyung/followers","following_url":"https://api.github.com/users/namhyung/following{/other_user}","gists_url":"https://api.github.com/users/namhyung/gists{/gist_id}","starred_url":"https://api.github.com/users/namhyung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/namhyung/subscriptions","organizations_url":"https://api.github.com/users/namhyung/orgs","repos_url":"https://api.github.com/users/namhyung/repos","events_url":"https://api.github.com/users/namhyung/events{/privacy}","received_events_url":"https://api.github.com/users/namhyung/received_events","type":"User","site_admin":false},"html_url":"https://github.com/namhyung/uftrace","description":"Function (graph) tracer for user-space","fork":false,"url":"https://api.github.com/repos/namhyung/uftrace","forks_url":"https://api.github.com/repos/namhyung/uftrace/forks","keys_url":"https://api.github.com/repos/namhyung/uftrace/keys{/key_id}","collaborators_url":"https://api.github.com/repos/namhyung/uftrace/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/namhyung/uftrace/teams","hooks_url":"https://api.github.com/repos/namhyung/uftrace/hooks","issue_events_url":"https://api.github.com/repos/namhyung/uftrace/issues/events{/number}","events_url":"https://api.github.com/repos/namhyung/uftrace/events","assignees_url":"https://api.github.com/repos/namhyung/uftrace/assignees{/user}","branches_url":"https://api.github.com/repos/namhyung/uftrace/branches{/branch}","tags_url":"https://api.github.com/repos/namhyung/uftrace/tags","blobs_url":"https://api.github.com/repos/namhyung/uftrace/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/namhyung/uftrace/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/namhyung/uftrace/git/refs{/sha}","trees_url":"https://api.github.com/repos/namhyung/uftrace/git/trees{/sha}","statuses_url":"https://api.github.com/repos/namhyung/uftrace/statuses/{sha}","languages_url":"https://api.github.com/repos/namhyung/uftrace/languages","stargazers_url":"https://api.github.com/repos/namhyung/uftrace/stargazers","contributors_url":"https://api.github.com/repos/namhyung/uftrace/contributors","subscribers_url":"https://api.github.com/repos/namhyung/uftrace/subscribers","subscription_url":"https://api.github.com/repos/namhyung/uftrace/subscription","commits_url":"https://api.github.com/repos/namhyung/uftrace/commits{/sha}","git_commits_url":"https://api.github.com/repos/namhyung/uftrace/git/commits{/sha}","comments_url":"https://api.github.com/repos/namhyung/uftrace/comments{/number}","issue_comment_url":"https://api.github.com/repos/namhyung/uftrace/issues/comments{/number}","contents_url":"https://api.github.com/repos/namhyung/uftrace/contents/{+path}","compare_url":"https://api.github.com/repos/namhyung/uftrace/compare/{base}...{head}","merges_url":"https://api.github.com/repos/namhyung/uftrace/merges","archive_url":"https://api.github.com/repos/namhyung/uftrace/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/namhyung/uftrace/downloads","issues_url":"https://api.github.com/repos/namhyung/uftrace/issues{/number}","pulls_url":"https://api.github.com/repos/namhyung/uftrace/pulls{/number}","milestones_url":"https://api.github.com/repos/namhyung/uftrace/milestones{/number}","notifications_url":"https://api.github.com/repos/namhyung/uftrace/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/namhyung/uftrace/labels{/name}","releases_url":"https://api.github.com/repos/namhyung/uftrace/releases{/id}","deployments_url":"https://api.github.com/repos/namhyung/uftrace/deployments","created_at":"2014-02-11T10:44:50Z","updated_at":"2018-09-18T08:20:15Z","pushed_at":"2018-09-18T08:20:12Z","git_url":"git://github.com/namhyung/uftrace.git","ssh_url":"git@github.com:namhyung/uftrace.git","clone_url":"https://github.com/namhyung/uftrace.git","svn_url":"https://github.com/namhyung/uftrace","homepage":"","size":4911,"stargazers_count":952,"watchers_count":952,"language":"C","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":136,"mirror_url":null,"archived":false,"open_issues_count":63,"license":{"key":"gpl-2.0","name":"GNU General Public License v2.0","spdx_id":"GPL-2.0","url":"https://api.github.com/licenses/gpl-2.0","node_id":"MDc6TGljZW5zZTg="},"forks":136,"open_issues":63,"watchers":952,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/namhyung/uftrace/pulls/286"},"html":{"href":"https://github.com/namhyung/uftrace/pull/286"},"issue":{"href":"https://api.github.com/repos/namhyung/uftrace/issues/286"},"comments":{"href":"https://api.github.com/repos/namhyung/uftrace/issues/286/comments"},"review_comments":{"href":"https://api.github.com/repos/namhyung/uftrace/pulls/286/comments"},"review_comment":{"href":"https://api.github.com/repos/namhyung/uftrace/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/namhyung/uftrace/pulls/286/commits"},"statuses":{"href":"https://api.github.com/repos/namhyung/uftrace/statuses/bbeaedeb01267ccd845ac20e2f56d9877750d897"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"namhyung"}}