gallium: add target-helpers/wrap_screen.c to C_SOURCES
[mesa/mesa-lb.git] / progs / rbug / ctx_rule.c
blobdccebfb79fb2e53aea6cb8107a5ecccb7d299706
1 /*
2 * Copyright 2009 VMware, Inc.
3 * All Rights Reserved.
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:
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.
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.
25 #include <stdio.h>
27 #include "pipe/p_compiler.h"
28 #include "pipe/p_format.h"
29 #include "util/u_memory.h"
30 #include "util/u_debug.h"
31 #include "util/u_network.h"
33 #include "rbug/rbug.h"
35 static void talk(rbug_context_t ctx, rbug_shader_t shdr)
37 int c = u_socket_connect("localhost", 13370);
38 struct rbug_connection *con;
39 struct rbug_header *header;
41 if (c < 0)
42 c = u_socket_connect("localhost", 13370);
44 con = rbug_from_socket(c);
45 assert(c >= 0);
46 assert(con);
47 debug_printf("Connection get!\n");
49 rbug_send_context_draw_rule(con, ctx, 0, shdr, 0, 0, RBUG_BLOCK_AFTER, NULL);
51 rbug_send_ping(con, NULL);
53 debug_printf("Sent waiting for reply\n");
54 header = rbug_get_message(con, NULL);
56 if (header->opcode != RBUG_OP_PING_REPLY)
57 debug_printf("Error\n");
58 else
59 debug_printf("Ok!\n");
61 rbug_free_header(header);
62 rbug_disconnect(con);
65 static void print_usage()
67 printf("Usage ctx_rule <context> <fragment>\n");
68 exit(-1);
71 int main(int argc, char** argv)
73 long ctx;
74 long shdr;
76 if (argc < 3)
77 print_usage();
79 ctx = atol(argv[1]);
80 shdr = atol(argv[2]);
82 if (ctx <= 0 && ctx <= 0)
83 print_usage();
85 talk((uint64_t)ctx, (uint64_t)shdr);
87 return 0;