handle_tbm_buffer_import_with_fd
};
+void _waylend_tbm_monitor_client_print_show_to_file(char* show_str)
+{
+ FILE * f = NULL;
+ static int c = 0;
+ char tmp_file[256];
+
+ snprintf(tmp_file, sizeof(tmp_file), "/tmp/tbm_debug_show_%d%d", getpid(), c++);
+ if ((f = fopen(tmp_file, "a+")) != NULL) {
+ fprintf(f, "%s", show_str);
+ fclose(f);
+ }
+}
+
void _waylend_tbm_monitor_client_show(int argc, char *argv[],
char *reply, int *len, struct wayland_tbm_client *tbm_client)
{
struct wayland_tbm_monitor_path path = {0};
+ char show_str[1024*4] = {0,};
+ int show_len = sizeof(show_str);
_wayland_tbm_util_show_path_parse(argv[2], 0, &path);
if (path.dlog)
tbm_bufmgr_debug_show(tbm_client->bufmgr);
- /* always answer to the server */
- tbm_bufmgr_debug_tbm_info_get(tbm_client->bufmgr, reply, len);
+ /* we have to save result to some file as reply can be very long */
+ tbm_bufmgr_debug_tbm_info_get(tbm_client->bufmgr, show_str, &show_len);
+ _waylend_tbm_monitor_client_print_show_to_file(show_str);
+
+ /* send empty string to close the session */
+ WL_TBM_MONITOR_SNPRINTF(reply, *len, "\n");
}
void _waylend_tbm_monitor_client_dump_snapshot(int argc, char *argv[],
#include "config.h"
+#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
+#include <sys/types.h>
+#include <dirent.h>
+
#include <tbm_surface.h>
#include <tbm_surface_internal.h>
#include <wayland-server.h>
static void _wayland_tbm_monitor_server_usage(struct wayland_tbm_monitore_request *r);
+static int
+_wayland_tbm_monitor_server_collect_files(FILE* f_to_collect, int need_remove)
+{
+ char buf[1024*8];
+ int buf_len = 0;
+
+ DIR *dir_stream;
+ struct dirent *entry;
+ char * dir_name = "/tmp/";
+
+ int fd;
+
+ char *file_name = NULL;
+
+ dir_stream = opendir(dir_name);
+ if (!dir_stream) {
+ WL_TBM_LOG("got an error trying to call 'opendir'.\n");
+ return -1;
+ }
+
+ while ((entry = readdir(dir_stream))) {
+ if (strncmp(entry->d_name, "tbm_debug_show_", strlen("tbm_debug_show_")))
+ continue;
+
+ int tmp = asprintf(&file_name, "%s/%s", dir_name, entry->d_name);
+ if (tmp < 0)
+ continue;
+
+ fd = open(file_name, O_RDONLY);
+ if (fd < 0) {
+ WL_TBM_LOG(" got an error trying to open file");
+ free(file_name);
+ continue;
+ }
+
+ while ((buf_len = read(fd, buf, sizeof(buf))) > 0)
+ fwrite(buf, buf_len, 1, f_to_collect);
+
+ close(fd);
+
+ if (need_remove)
+ unlink(file_name);
+
+ free(file_name);
+ }
+
+ closedir(dir_stream);
+
+ return 0;
+}
+
+void
+_wayland_tbm_monitor_add_info_printf(struct wayland_tbm_monitore_request *r)
+{
+ FILE *f;
+ if (r->path.file[0] != '\0') {
+ if ((f = fopen(r->path.file, "a+")) != NULL) {
+ _wayland_tbm_monitor_server_collect_files(f, r->path.console && r->console ? 0 : 1);
+ fclose(f);
+ }
+ }
+
+ if (r->path.console && r->console)
+ _wayland_tbm_monitor_server_collect_files(r->console, 1);
+}
+
static void
_wayland_tbm_monitor_request_printf(struct wayland_tbm_monitore_request *r, const char *fmt, ...)
{
r->wait_count--;
WL_TBM_TRACE("request_id:%d wait_count:%d\n", r->id, r->wait_count);
if (r->wait_count <= 0) {
+ /* print additional info from clients */
+ _wayland_tbm_monitor_add_info_printf(r);
wl_tbm_monitor_send_done(r->wl_resource, r->msg);
_wayland_tbm_monitor_request_delete(r);
}