diff --git a/emulator/main.c b/emulator/main.c
index cb77025..aa269c3 100644
--- a/emulator/main.c
+++ b/emulator/main.c
#include <getopt.h>
#include "src/shared/mainloop.h"
+#include "src/shared/util.h"
+
#include "serial.h"
#include "server.h"
#include "vhci.h"
"Usage:\n");
printf("\tbtvirt [options]\n");
printf("options:\n"
+ "\t-d Enable debug\n"
"\t-S Create local serial port\n"
"\t-s Create local server sockets\n"
"\t-l[num] Number of local controllers\n"
}
static const struct option main_options[] = {
+ { "debug", no_argument, NULL, 'd' },
{ "serial", no_argument, NULL, 'S' },
{ "server", no_argument, NULL, 's' },
{ "local", optional_argument, NULL, 'l' },
{ }
};
+static void vhci_debug(const char *str, void *user_data)
+{
+ int i = PTR_TO_UINT(user_data);
+
+ printf("vhci%u: %s\n", i, str);
+}
+
int main(int argc, char *argv[])
{
struct server *server1;
struct server *server3;
struct server *server4;
struct server *server5;
+ bool debug_enabled = false;
bool server_enabled = false;
bool serial_enabled = false;
int letest_count = 0;
for (;;) {
int opt;
- opt = getopt_long(argc, argv, "Ssl::LBAU::T::vh",
+ opt = getopt_long(argc, argv, "dSsl::LBAU::T::vh",
main_options, NULL);
if (opt < 0)
break;
switch (opt) {
+ case 'd':
+ debug_enabled = true;
+ break;
case 'S':
serial_enabled = true;
break;
fprintf(stderr, "Failed to open Virtual HCI device\n");
return EXIT_FAILURE;
}
+
+ if (debug_enabled)
+ vhci_set_debug(vhci, vhci_debug, UINT_TO_PTR(i), NULL);
}
if (serial_enabled) {