diff options
author | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2021-02-19 15:18:24 -0800 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2021-02-19 15:21:12 -0800 |
commit | 17e208f6a63fdd888066a83948be99672c62173b (patch) | |
tree | 05be5f9ab1f8b1aaa525a015acb79a20a94abe24 /emulator | |
parent | 441ab748ccb51a4199fe2ae1535b40f8d854bc6c (diff) | |
download | bluez-17e208f6a63fdd888066a83948be99672c62173b.tar.gz |
emulator: Add option for enabling debug with btvirt
This adds -d/--debug options which enables debug of vhci instance on
btvirt.
Diffstat (limited to 'emulator')
-rw-r--r-- | emulator/main.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/emulator/main.c b/emulator/main.c index cb77025aa..aa269c3f0 100644 --- a/emulator/main.c +++ b/emulator/main.c @@ -19,6 +19,8 @@ #include <getopt.h> #include "src/shared/mainloop.h" +#include "src/shared/util.h" + #include "serial.h" #include "server.h" #include "vhci.h" @@ -41,6 +43,7 @@ static void usage(void) "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" @@ -53,6 +56,7 @@ static void usage(void) } 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' }, @@ -66,6 +70,13 @@ static const struct option main_options[] = { { } }; +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; @@ -73,6 +84,7 @@ int main(int argc, char *argv[]) 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; @@ -86,12 +98,15 @@ int main(int argc, char *argv[]) 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; @@ -172,6 +187,9 @@ int main(int argc, char *argv[]) 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) { |