[hwc] adopt COMMIT_PER_VBLANK functionality for each ouptut
[platform/core/uifw/libtdm.git] / src / tdm_monitor_server.c
1 /**************************************************************************
2  *
3  * libtdm
4  *
5  * Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
6  *
7  * Contact: Eunchul Kim <chulspro.kim@samsung.com>,
8  *          JinYoung Jeon <jy0.jeon@samsung.com>,
9  *          Taeheon Kim <th908.kim@samsung.com>,
10  *          YoungJun Cho <yj44.cho@samsung.com>,
11  *          SooChan Lim <sc1.lim@samsung.com>,
12  *          Boram Park <sc1.lim@samsung.com>
13  *
14  * Permission is hereby granted, free of charge, to any person obtaining a
15  * copy of this software and associated documentation files (the
16  * "Software"), to deal in the Software without restriction, including
17  * without limitation the rights to use, copy, modify, merge, publish,
18  * distribute, sub license, and/or sell copies of the Software, and to
19  * permit persons to whom the Software is furnished to do so, subject to
20  * the following conditions:
21  *
22  * The above copyright notice and this permission notice (including the
23  * next paragraph) shall be included in all copies or substantial portions
24  * of the Software.
25  *
26  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
27  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
29  * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
30  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
31  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
32  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33  *
34 **************************************************************************/
35
36 #include <stdio.h>
37 #include <string.h>
38 #include <stdlib.h>
39 #include <stdint.h>
40
41 #include "tdm.h"
42 #include "tdm_private.h"
43 #include "tdm_helper.h"
44 #include "tdm_log.h"
45
46 #define TDM_DBG_SERVER_ARGS_MAX         32
47
48 static void _tdm_monitor_server_usage(char *app_name, char *reply, int *len);
49
50 static void
51 _tdm_monitor_server_query(unsigned int pid, char *cwd, int argc, char *argv[], char *reply, int *len, tdm_display *dpy)
52 {
53         tdm_display_lock(dpy);
54         tdm_helper_get_display_information(dpy, reply, len);
55         tdm_display_unlock(dpy);
56 }
57
58 static void
59 _tdm_monitor_server_protocol_trace(unsigned int pid, char *cwd, int argc, char *argv[], char *reply, int *len, tdm_display *dpy)
60 {
61         int enable;
62
63         if (argc < 3) {
64                 _tdm_monitor_server_usage(argv[0], reply, len);
65                 return;
66         }
67
68         enable = atoi(argv[2]);
69
70         tdm_event_loop_trace_enable(dpy, enable);
71
72         TDM_SNPRINTF(reply, len, "protocol trace: '%s'\n", (enable) ? "enabled" : "disabled");
73 }
74
75 static void
76 _tdm_monitor_server_dpms(unsigned int pid, char *cwd, int argc, char *argv[], char *reply, int *len, tdm_display *dpy)
77 {
78         tdm_output *output;
79         int output_idx, dpms_value;
80         char *arg;
81         char *end;
82         tdm_error ret;
83
84         if (argc < 3) {
85                 _tdm_monitor_server_usage(argv[0], reply, len);
86                 return;
87         }
88
89         arg = argv[2];
90         output_idx = strtol(arg, &end, 10);
91         if (*end != ':') {
92                 TDM_SNPRINTF(reply, len, "failed: no onoff value\n");
93                 return;
94         }
95
96         arg = end + 1;
97         dpms_value = strtol(arg, &end, 10);
98
99         output = tdm_display_get_output(dpy, output_idx, &ret);
100         TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE && output != NULL);
101
102         ret = tdm_output_set_dpms(output, dpms_value);
103         TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
104
105         TDM_SNPRINTF(reply, len, "done: DPMS %s\n", tdm_dpms_str(dpms_value));
106 }
107
108 static void
109 _tdm_monitor_server_ttrace_vblank(unsigned int pid, char *cwd, int argc, char *argv[], char *reply, int *len, tdm_display *dpy)
110 {
111         int enable, output_id = 0;
112         tdm_output *output;
113         char *arg;
114         char *end;
115         tdm_error ret;
116         tdm_output_type type;
117
118         if (argc < 3) {
119                 _tdm_monitor_server_usage(argv[0], reply, len);
120                 return;
121         }
122
123         arg = argv[2];
124         enable = strtol(arg, &end, 10);
125
126         if (*end == '@') {
127                 arg = end + 1;
128                 output_id = strtol(arg, &end, 10);
129         }
130
131         output = tdm_display_get_output(dpy, output_id, NULL);
132         if (!output) {
133                 TDM_SNPRINTF(reply, len, "can't find the output_id(%d)\n", output_id);
134                 return;
135         }
136
137         ret = tdm_output_get_output_type(output, &type);
138         if (ret != TDM_ERROR_NONE) {
139                 TDM_SNPRINTF(reply, len, "can't find the type of output_id(%d)\n", output_id);
140                 return;
141         }
142
143         tdm_display_enable_ttrace_vblank(dpy, output, enable);
144
145         TDM_SNPRINTF(reply, len, "%s ttrace vblank for '%s'\n",
146                                  (enable) ? "enable" : "disable", tdm_conn_str(type));
147 }
148
149 static void
150 _tdm_monitor_server_debug(unsigned int pid, char *cwd, int argc, char *argv[], char *reply, int *len, tdm_display *dpy)
151 {
152         int level;
153         char *arg;
154         char *end;
155
156         if (argc < 3) {
157                 _tdm_monitor_server_usage(argv[0], reply, len);
158                 return;
159         }
160
161         arg = argv[2];
162         level = strtol(arg, &end, 10);
163
164         tdm_log_set_debug_level(level);
165         TDM_SNPRINTF(reply, len, "debug level: %d\n", level);
166
167         if (*end == '@') {
168                 char *arg = end + 1;
169
170                 tdm_display_enable_debug_module((const char *)arg);
171
172                 TDM_SNPRINTF(reply, len, "debugging... '%s'\n", arg);
173         }
174 }
175
176 static void
177 _tdm_monitor_server_log_path(unsigned int pid, char *cwd, int argc, char *argv[], char *reply, int *len, tdm_display *dpy)
178 {
179         static int old_stdout = -1;
180         char fd_name[TDM_PATH_LEN];
181         char *path;
182
183         if (argc < 3) {
184                 _tdm_monitor_server_usage(argv[0], reply, len);
185                 return;
186         }
187
188         if (old_stdout == -1)
189                 old_stdout = dup(STDOUT_FILENO);
190
191         path = argv[2];
192         TDM_DBG_RETURN_IF_FAIL(path != NULL);
193
194         tdm_log_enable_dlog(0);
195
196         if (!strncmp(path, "dlog", 4)) {
197                 tdm_log_enable_dlog(1);
198                 goto done;
199         } else if (!strncmp(path, "console", 7))
200                 snprintf(fd_name, TDM_PATH_LEN, "/proc/%d/fd/1", pid);
201         else {
202                 if (path[0] == '/')
203                         snprintf(fd_name, TDM_PATH_LEN, "%s", path);
204                 else {
205                         if (cwd)
206                                 snprintf(fd_name, TDM_PATH_LEN, "%s/%s", cwd, path);
207                         else
208                                 snprintf(fd_name, TDM_PATH_LEN, "%s", path);
209                 }
210                 tdm_log_enable_color(0);
211         }
212
213         if (tdm_display_enable_path((const char*)fd_name) != TDM_ERROR_NONE) {
214                 TDM_SNPRINTF(reply, len, "failed: '%s'\n", path);
215                 return;
216         }
217
218 done:
219         TDM_SNPRINTF(reply, len, "log path: '%s'\n", path);
220 }
221
222 static void
223 _tdm_monitor_server_choose_commit_per_vblank_mode(unsigned int pid, char *cwd, int argc, char *argv[], char *reply, int *len, tdm_display *dpy)
224 {
225         int output_idx;
226         int mode;
227         char *arg;
228         char *end;
229         tdm_error err;
230
231         /* TODO: do we have to provide an ability to choose commit_per_vblank mode outside? */
232
233         if (argc < 4) {
234                 _tdm_monitor_server_usage(argv[0], reply, len);
235                 return;
236         }
237
238         arg = argv[2];
239         output_idx = strtol(arg, &end, 10);
240
241         arg = argv[3];
242         mode = strtol(arg, &end, 10);
243
244         err = tdm_output_choose_commit_per_vblank_mode(tdm_display_get_output(dpy, output_idx, NULL), mode);
245         if (err != TDM_ERROR_NONE) {
246                 TDM_SNPRINTF(reply, len, "an error: output_idx or mode is wrong\n");
247                 return;
248         }
249
250         TDM_SNPRINTF(reply, len, "the mode's been set\n");
251 }
252
253 static void
254 _tdm_monitor_server_fps(unsigned int pid, char *cwd, int argc, char *argv[], char *reply, int *len, tdm_display *dpy)
255 {
256         int enable;
257         char *arg;
258         char *end;
259
260         if (argc < 3) {
261                 _tdm_monitor_server_usage(argv[0], reply, len);
262                 return;
263         }
264
265         arg = argv[2];
266         enable = strtol(arg, &end, 10);
267
268         tdm_display_enable_fps(dpy, enable);
269
270         TDM_SNPRINTF(reply, len, "%s to print fps\n", (enable) ? "enable" : "disable");
271 }
272
273 static void
274 _tdm_monitor_server_vblank_list(unsigned int pid, char *cwd, int argc, char *argv[],
275                                                                 char *reply, int *len, tdm_display *dpy)
276 {
277         tdm_vblank_get_vblank_list_information(dpy, reply, len);
278 }
279
280 static void
281 _tdm_monitor_server_vblank_fps(unsigned int pid, char *cwd, int argc, char *argv[],
282                                                            char *reply, int *len, tdm_display *dpy)
283 {
284         unsigned int target_pid, fps;
285         char *arg;
286         char *end;
287         char name[TDM_NAME_LEN];
288         tdm_error ret;
289
290         if (argc < 3) {
291                 _tdm_monitor_server_usage(argv[0], reply, len);
292                 return;
293         }
294
295         arg = argv[2];
296         target_pid = strtol(arg, &end, 10);
297
298         if (*end == ',') {
299                 arg = end + 1;
300                 end = strtostr(name, TDM_NAME_LEN, arg, TDM_DELIM);
301         } else {
302                 strncpy(name, TDM_VBLANK_DEFAULT_NAME, TDM_NAME_LEN - 1);
303                 name[TDM_NAME_LEN - 1] = '\0';
304         }
305
306         if (*end != '@') {
307                 TDM_SNPRINTF(reply, len, "failed: no fps value\n");
308                 return;
309         }
310
311         arg = end + 1;
312         fps = strtol(arg, &end, 10);
313
314         ret = tdm_vblank_set_client_vblank_fps(target_pid, name, fps);
315         if (ret != TDM_ERROR_NONE) {
316                 TDM_SNPRINTF(reply, len, "can't set '%u' fps to '%s' client vblank(PID:%u)\n", fps, name, target_pid);
317                 return;
318         }
319
320         TDM_SNPRINTF(reply, len, "success: '%u' fps for '%s' client vblank(PID:%u)\n", fps, name, target_pid);
321 }
322
323 static void
324 _tdm_monitor_server_global_fps(unsigned int pid, char *cwd, int argc, char *argv[],
325                                                            char *reply, int *len, tdm_display *dpy)
326 {
327         unsigned int fps;
328         char *arg;
329         char *end;
330         tdm_error ret;
331
332         if (argc < 3) {
333                 _tdm_monitor_server_usage(argv[0], reply, len);
334                 return;
335         }
336
337         arg = argv[2];
338         fps = strtol(arg, &end, 10);
339
340         if (fps > 0)
341                 ret = tdm_vblank_enable_global_fps(1, fps);
342         else
343                 ret = tdm_vblank_enable_global_fps(0, 0);
344
345         if (ret != TDM_ERROR_NONE) {
346                 TDM_SNPRINTF(reply, len, "can't set '%u' fps to global fps\n", fps);
347                 return;
348         }
349
350         TDM_SNPRINTF(reply, len, "success: '%u' global fps\n", fps);
351 }
352
353 static void
354 _tdm_monitor_server_prop(unsigned int pid, char *cwd, int argc, char *argv[], char *reply, int *len, tdm_display *dpy)
355 {
356         tdm_output *output;
357         tdm_output *layer = NULL;
358         int output_idx, layer_idx = -1;
359         int cnt, i, done = 0;
360         tdm_value value;
361         char temp[TDM_PATH_LEN];
362         char *prop_name;
363         char *arg;
364         char *end;
365         tdm_error ret;
366         const tdm_prop *props;
367
368         if (argc < 3) {
369                 _tdm_monitor_server_usage(argv[0], reply, len);
370                 return;
371         }
372
373         snprintf(temp, TDM_PATH_LEN, "%s", argv[2]);
374         arg = temp;
375
376         output_idx = strtol(arg, &end, 10);
377         if (*end == ',') {
378                 arg = end + 1;
379                 layer_idx = strtol(arg, &end, 10);
380         }
381
382         if (*end != ':') {
383                 TDM_SNPRINTF(reply, len, "failed: no prop_name\n");
384                 return;
385         }
386
387         arg = end + 1;
388         prop_name = strtok_r(arg, ",", &end);
389         if (!prop_name) {
390                 TDM_SNPRINTF(reply, len, "failed: get prop_name by strtok_r\n");
391                 return;
392         }
393
394         if (*end == '\0') {
395                 TDM_SNPRINTF(reply, len, "failed: no value\n");
396                 return;
397         }
398
399         arg = strtok_r(NULL, TDM_DELIM, &end);
400         if (!arg) {
401                 TDM_SNPRINTF(reply, len, "failed: get arg by strtok_r\n");
402                 return;
403         }
404         value.u32 = strtol(arg, &end, 10);
405
406         output = tdm_display_get_output(dpy, output_idx, &ret);
407         TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE && output != NULL);
408
409         if (layer_idx != -1) {
410                 layer = tdm_output_get_layer(output, layer_idx, &ret);
411                 TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE && layer != NULL);
412         }
413
414         if (layer) {
415                 ret = tdm_layer_get_available_properties(layer, &props, &cnt);
416                 TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
417
418                 for (i = 0; i < cnt; i++) {
419                         if (!strncmp(props[i].name, prop_name, TDM_NAME_LEN)) {
420                                 ret = tdm_layer_set_property(layer, props[i].id, value);
421                                 TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
422                                 done = 1;
423                                 break;
424                         }
425                 }
426         } else {
427                 ret = tdm_output_get_available_properties(output, &props, &cnt);
428                 TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
429
430                 for (i = 0; i < cnt; i++) {
431                         if (!strncmp(props[i].name, prop_name, TDM_NAME_LEN)) {
432                                 ret = tdm_output_set_property(output, props[i].id, value);
433                                 TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
434                                 done = 1;
435                                 break;
436                         }
437                 }
438         }
439
440         if (done)
441                 TDM_SNPRINTF(reply, len, "done: %s:%d \n", prop_name, value.u32);
442         else
443                 TDM_SNPRINTF(reply, len, "no '%s' propperty \n", prop_name);
444 }
445
446 static void
447 _tdm_monitor_server_dump(unsigned int pid, char *cwd, int argc, char *argv[], char *reply, int *len, tdm_display *dpy)
448 {
449         if (argc < 3) {
450                 _tdm_monitor_server_usage(argv[0], reply, len);
451                 return;
452         }
453
454         tdm_display_enable_dump(dpy, (const char*)argv[2], reply, len);
455 }
456
457 static void
458 _tdm_monitor_server_punch(unsigned int pid, char *cwd, int argc, char *argv[], char *reply, int *len, tdm_display *dpy)
459 {
460         char *arg, *end;
461         unsigned int output_id, layer_id;
462         tdm_output *output;
463         tdm_layer *layer;
464         tbm_surface_h buffer;
465
466         arg = argv[2];
467
468         output_id = strtol(arg, &end, 10);
469         output = tdm_display_get_output(dpy, output_id, NULL);
470         if (!output) {
471                 TDM_SNPRINTF(reply, len, "not found output\n");
472                 return;
473         }
474         if (*end != ',') {
475                 TDM_SNPRINTF(reply, len, "not found ',<layer_idx>'\n");
476                 return;
477         }
478
479         arg = end + 1;
480         layer_id = strtol(arg, &end, 10);
481         layer = tdm_output_get_layer(output, layer_id, NULL);
482         if (!layer) {
483                 TDM_SNPRINTF(reply, len, "not found layer\n");
484                 return;
485         }
486
487         buffer = tdm_layer_get_displaying_buffer(layer, NULL);
488         if (!buffer) {
489                 TDM_SNPRINTF(reply, len, "not found buffer\n");
490                 return;
491         }
492
493         if (*end == ':') {
494                 tdm_pos pos = {0,};
495
496                 arg = end + 1;
497                 pos.w = strtol(arg, &end, 10);
498                 TDM_EXIT_IF_FAIL(*end == 'x');
499                 arg = end + 1;
500                 pos.h = strtol(arg, &end, 10);
501                 if (*end == '+') {
502                         arg = end + 1;
503                         pos.x = strtol(arg, &end, 10);
504                         TDM_EXIT_IF_FAIL(*end == '+');
505                         arg = end + 1;
506                         pos.y = strtol(arg, &end, 10);
507                 }
508
509                 tdm_helper_clear_buffer_pos(buffer, &pos);
510         } else
511                 tdm_helper_clear_buffer(buffer);
512 }
513
514 static struct {
515         const char *opt;
516         void (*func)(unsigned int pid, char *cwd, int argc, char *argv[], char *reply, int *len, tdm_display *dpy);
517         const char *desc;
518         const char *arg;
519         const char *ex;
520 } option_proc[] = {
521         {
522                 "info", _tdm_monitor_server_query,
523                 "show tdm output, layer information", NULL, NULL
524         },
525         {
526                 "trace", _tdm_monitor_server_protocol_trace,
527                 "enable/disable the wl protocol",
528                 "<enable>",
529                 "0 or 1"
530         },
531         {
532                 "dpms", _tdm_monitor_server_dpms,
533                 "set output dpms", "<output_idx>:<dpms>", "0:3 or 0:0"
534         },
535         {
536                 "ttrace_vblank", _tdm_monitor_server_ttrace_vblank,
537                 "enable/disable the vblank for ttrace [0:disable 1:enable]",
538                 "<enable>[@<output_idx>]", "0 or 1"
539         },
540         {
541                 "debug", _tdm_monitor_server_debug,
542                 "set the debug level and modules(module: none, mutex, buffer, thread, vblank)",
543                 "<level>[@<module1>[,<module2>]]",
544                 NULL
545         },
546         {
547                 "log_path", _tdm_monitor_server_log_path,
548                 "set the log path (console,dlog,filepath)",
549                 "<path>",
550                 "console"
551         },
552         {
553                 "choose_commit_per_vblank_mode", _tdm_monitor_server_choose_commit_per_vblank_mode,
554                 "choose a commit_per_vblank mode for the output",
555                 "<output_idx> <mode>",
556                 "0 1 or 1 2 or 2 0"
557         },
558         {
559                 "fps", _tdm_monitor_server_fps,
560                 "enable/disable to print fps",
561                 "<enable>",
562                 "0 or 1"
563         },
564         {
565                 "vblank_list", _tdm_monitor_server_vblank_list,
566                 "print the client vblank list",
567                 NULL,
568                 NULL
569         },
570         {
571                 "vblank_fps", _tdm_monitor_server_vblank_fps,
572                 "set the client vblank fps for the given process ID and client vblank name",
573                 "<pid>[,<vblank_name>]@<fps>",
574                 NULL
575         },
576         {
577                 "global_fps", _tdm_monitor_server_global_fps,
578                 "set the global vblank fps for the entire system",
579                 "<fps>",
580                 NULL
581         },
582         {
583                 "prop", _tdm_monitor_server_prop,
584                 "set the property of a output or a layer",
585                 "<output_idx>[,<layer_idx>]:<prop_name>,<value>",
586                 NULL
587         },
588         {
589                 "dump", _tdm_monitor_server_dump,
590                 "dump buffers (type: none, layer, pp, capture, current)\n"
591                 "\t\t  layer, pp, capture - start to dump buffers of layer, pp, capture\n"
592                 "\t\t  none               - stop to dump buffers\n"
593                 "\t\t  current            - dump the current buffer of all layers",
594                 "<object_type1>[,<object_type2>[,...]][@<directory_path>]",
595                 NULL
596         },
597         {
598                 "punch", _tdm_monitor_server_punch,
599                 "punch a layer",
600                 "<output_idx>,<layer_idx>[:<w>x<h>[+<x>+<y>]]",
601                 NULL
602         },
603 };
604
605 static void
606 _tdm_monitor_server_usage(char *app_name, char *reply, int *len)
607 {
608         int opt_size = sizeof(option_proc) / sizeof(option_proc[0]);
609         int i;
610
611         TDM_SNPRINTF(reply, len, "usage: %s \n\n", app_name);
612
613         for (i = 0; i < opt_size; i++) {
614                 TDM_SNPRINTF(reply, len, "\t-%s\t%s\n", option_proc[i].opt, option_proc[i].desc);
615                 if (option_proc[i].arg)
616                         TDM_SNPRINTF(reply, len, "\t\t  %s\n", option_proc[i].arg);
617                 if (option_proc[i].ex)
618                         TDM_SNPRINTF(reply, len, "\t\t  ex) %s\n", option_proc[i].ex);
619                 TDM_SNPRINTF(reply, len, "\n");
620         }
621 }
622
623 static void
624 _tdm_monitor_server_command(unsigned int pid, char *cwd, tdm_display *dpy, int argc, char *argv[], char *reply, int *len)
625 {
626         int opt_size = sizeof(option_proc) / sizeof(option_proc[0]);
627         int i;
628
629         if (argc < 2) {
630                 _tdm_monitor_server_usage(argv[0], reply, len);
631                 return;
632         }
633
634         for (i = 0; i < opt_size; i++) {
635                 if (argv[1][0] == '-' && !strncmp(argv[1] + 1, option_proc[i].opt, 32)) {
636                         if (option_proc[i].func) {
637                                 option_proc[i].func(pid, cwd, argc, argv, reply, len, dpy);
638                                 return;
639                         } else {
640                                 TDM_SNPRINTF(reply, len, "'%s' not implemented.\n", argv[1]);
641                                 return;
642                         }
643                 }
644         }
645
646         _tdm_monitor_server_usage(argv[0], reply, len);
647         return;
648 }
649
650
651 INTERN void
652 tdm_monitor_server_command(tdm_display *dpy, const char *options, char *reply, int *len)
653 {
654         unsigned int pid;
655         char cwd[1024];
656         int argc = 0;
657         char *argv[TDM_DBG_SERVER_ARGS_MAX] = {0,};
658         char temp[1024];
659         char *arg;
660         char *end = NULL, *e;
661
662         snprintf(temp, sizeof(temp), "%s", options);
663
664         arg = strtok_r(temp, " ", &end);
665         if (!arg) {
666                 TDM_SNPRINTF(reply, len, "no pid for tdm-monitor");
667                 return;
668         }
669         pid = strtol(arg, &e, 10);
670
671         arg = strtok_r(NULL, " ", &end);
672         if (!arg) {
673                 TDM_SNPRINTF(reply, len, "no cwd for tdm-monitor");
674                 return;
675         }
676         snprintf(cwd, sizeof(cwd), "%s", arg);
677
678         TDM_DBG("pid(%d) cwd(%s)", pid, cwd);
679
680         argv[argc] = strtok_r(NULL, " ", &end);
681         while (argv[argc]) {
682                 argc++;
683                 if (argc == TDM_DBG_SERVER_ARGS_MAX) {
684                         TDM_SNPRINTF(reply, len, "too many arguments for tdm-monitor");
685                         break;
686                 }
687                 argv[argc] = strtok_r(NULL, " ", &end);
688         }
689
690         _tdm_monitor_server_command(pid, cwd, dpy, argc, argv, reply, len);
691 }