shdr_dump.c revision 32001f49
1/* 2 * Copyright 2009 VMware, Inc. 3 * All Rights Reserved. 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the "Software"), 7 * to deal in the Software without restriction, including without limitation 8 * on the rights to use, copy, modify, merge, publish, distribute, sub 9 * license, and/or sell copies of the Software, and to permit persons to whom 10 * the Software is furnished to do so, subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice (including the next 13 * paragraph) shall be included in all copies or substantial portions of the 14 * Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 19 * VMWARE AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, 20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 22 * USE OR OTHER DEALINGS IN THE SOFTWARE. 23 */ 24 25#include "pipe/p_compiler.h" 26#include "pipe/p_format.h" 27#include "util/u_memory.h" 28#include "util/u_debug.h" 29#include "util/u_network.h" 30 31#include "rbug/rbug.h" 32 33#include "tgsi/tgsi_dump.h" 34 35static void shader_info(struct rbug_connection *con, rbug_context_t ctx) 36{ 37 struct rbug_header *header; 38 struct rbug_proto_shader_list_reply *list; 39 struct rbug_proto_shader_info_reply *info; 40 int i; 41 42 debug_printf("Sending get shaders to %llu\n", (unsigned long long)ctx); 43 rbug_send_shader_list(con, ctx, NULL); 44 45 debug_printf("Waiting for shaders from %llu\n", (unsigned long long)ctx); 46 header = rbug_get_message(con, NULL); 47 assert(header->opcode == RBUG_OP_SHADER_LIST_REPLY); 48 list = (struct rbug_proto_shader_list_reply *)header; 49 50 debug_printf("Got shaders:\n"); 51 for (i = 0; i < list->shaders_len; i++) { 52 rbug_send_shader_info(con, ctx, list->shaders[i], NULL); 53 54 header = rbug_get_message(con, NULL); 55 assert(header->opcode == RBUG_OP_SHADER_INFO_REPLY); 56 info = (struct rbug_proto_shader_info_reply *)header; 57 58 debug_printf("#####################################################\n"); 59 debug_printf("ctx: %llu shdr: %llu disabled %u\n", 60 (unsigned long long)ctx, 61 (unsigned long long)list->shaders[i], 62 info->disabled); 63 64 /* just to be sure */ 65 assert(sizeof(struct tgsi_token) == 4); 66 67 debug_printf("-----------------------------------------------------\n"); 68 tgsi_dump((struct tgsi_token *)info->original, 0); 69 70 if (info->replaced_len > 0) { 71 debug_printf("-----------------------------------------------------\n"); 72 tgsi_dump((struct tgsi_token *)info->replaced, 0); 73 } 74 75 rbug_free_header(header); 76 } 77 78 debug_printf("#####################################################\n"); 79 rbug_free_header(&list->header); 80} 81 82static void talk() 83{ 84 int c = u_socket_connect("localhost", 13370); 85 struct rbug_connection *con = rbug_from_socket(c); 86 struct rbug_header *header; 87 struct rbug_proto_context_list_reply *list; 88 int i; 89 90 assert(c >= 0); 91 assert(con); 92 debug_printf("Connection get!\n"); 93 94 debug_printf("Sending get contexts\n"); 95 rbug_send_context_list(con, NULL); 96 97 debug_printf("Waiting for contexts\n"); 98 header = rbug_get_message(con, NULL); 99 assert(header->opcode == RBUG_OP_CONTEXT_LIST_REPLY); 100 list = (struct rbug_proto_context_list_reply *)header; 101 102 debug_printf("Got contexts:\n"); 103 for (i = 0; i < list->contexts_len; i++) { 104 shader_info(con, list->contexts[i]); 105 } 106 107 rbug_free_header(&list->header); 108 rbug_disconnect(con); 109} 110 111int main(int argc, char** argv) 112{ 113 talk(); 114 return 0; 115} 116