File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33 * SPDX-License-Identifier: MIT
44 */
55
6- #include " stats.h"
6+ #include " include_internal/hipfile- stats.h"
77#include < iostream>
88#include < unistd.h>
99#include < cstring>
@@ -47,17 +47,37 @@ main(int argc, char *argv[])
4747 return 1 ;
4848 }
4949 }
50- hipFile::StatsClient client{pid};
51- if (!client.connectServer ()) {
52- std::cerr << " Failed to collect info from target process.\n " ;
50+
51+ hipFileStatsContext_t *context;
52+ if (createContext (&context, pid) != hipFileStatsSuccess) {
53+ std::cerr << " Failed to create context for target process.\n " ;
54+ return 1 ;
55+ }
56+ if (connectToTargetProcess (context) != hipFileStatsSuccess) {
57+ std::cerr << " Failed to connect to target process.\n " ;
58+ closeContext (context);
5359 return 1 ;
5460 }
5561 if (!imm) {
56- client.pollProcess (-1 );
62+ if (pollTargetProcess (context, -1 ) != hipFileStatsSuccess) {
63+ std::cerr << " Failed to poll target process.\n " ;
64+ closeContext (context);
65+ return 1 ;
66+ }
67+ }
68+ int fd{dup (STDOUT_FILENO)};
69+ if (fd < 0 ) {
70+ std::cerr << " Failed to duplicate stdout file descriptor.\n " ;
71+ closeContext (context);
72+ return 1 ;
5773 }
58- if (!client.generateReport (std::cout)) {
59- std::cerr << " No stats could be collected from target process.\n " ;
74+ if (generateReport (context, fd) != hipFileStatsSuccess) {
75+ std::cerr << " Failed to generate report from target process.\n " ;
76+ close (fd);
77+ closeContext (context);
6078 return 1 ;
6179 }
80+ close (fd);
81+ closeContext (context);
6282 return 0 ;
6383}
You can’t perform that action at this time.
0 commit comments