From 9e164b83f08badfa3b0bd12a1ac09c143c38f45b Mon Sep 17 00:00:00 2001 From: Mark Riddoch Date: Sat, 7 Jun 2014 20:41:58 +0100 Subject: [PATCH] Updates to debug CLI Fix for argument passign to show filter Addition of list dcbs commands --- server/core/dcb.c | 76 ++++++++++++++++++++++++------- server/include/dcb.h | 1 + server/modules/routing/debugcmd.c | 6 ++- 3 files changed, 65 insertions(+), 18 deletions(-) diff --git a/server/core/dcb.c b/server/core/dcb.c index 16ca964ac..517b697cd 100644 --- a/server/core/dcb.c +++ b/server/core/dcb.c @@ -1089,12 +1089,18 @@ printDCB(DCB *dcb) if (dcb->writeq) printf("\tQueued write data: %d\n",gwbuf_length(dcb->writeq)); printf("\tStatistics:\n"); - printf("\t\tNo. of Reads: %d\n", dcb->stats.n_reads); - printf("\t\tNo. of Writes: %d\n", dcb->stats.n_writes); - printf("\t\tNo. of Buffered Writes: %d\n", dcb->stats.n_buffered); - printf("\t\tNo. of Accepts: %d\n", dcb->stats.n_accepts); - printf("\t\tNo. of High Water Events: %d\n", dcb->stats.n_high_water); - printf("\t\tNo. of Low Water Events: %d\n", dcb->stats.n_low_water); + printf("\t\tNo. of Reads: %d\n", + dcb->stats.n_reads); + printf("\t\tNo. of Writes: %d\n", + dcb->stats.n_writes); + printf("\t\tNo. of Buffered Writes: %d\n", + dcb->stats.n_buffered); + printf("\t\tNo. of Accepts: %d\n", + dcb->stats.n_accepts); + printf("\t\tNo. of High Water Events: %d\n", + dcb->stats.n_high_water); + printf("\t\tNo. of Low Water Events: %d\n", + dcb->stats.n_low_water); } /** @@ -1129,13 +1135,17 @@ DCB *dcb; while (dcb) { dcb_printf(pdcb, "DCB: %p\n", (void *)dcb); - dcb_printf(pdcb, "\tDCB state: %s\n", gw_dcb_state2string(dcb->state)); + dcb_printf(pdcb, "\tDCB state: %s\n", + gw_dcb_state2string(dcb->state)); if (dcb->session && dcb->session->service) - dcb_printf(pdcb, "\tService: %s\n", dcb->session->service->name); + dcb_printf(pdcb, "\tService: %s\n", + dcb->session->service->name); if (dcb->remote) - dcb_printf(pdcb, "\tConnected to: %s\n", dcb->remote); + dcb_printf(pdcb, "\tConnected to: %s\n", + dcb->remote); if (dcb->writeq) - dcb_printf(pdcb, "\tQueued write data: %d\n", gwbuf_length(dcb->writeq)); + dcb_printf(pdcb, "\tQueued write data: %d\n", + gwbuf_length(dcb->writeq)); dcb_printf(pdcb, "\tStatistics:\n"); dcb_printf(pdcb, "\t\tNo. of Reads: %d\n", dcb->stats.n_reads); dcb_printf(pdcb, "\t\tNo. of Writes: %d\n", dcb->stats.n_writes); @@ -1148,6 +1158,32 @@ DCB *dcb; spinlock_release(&dcbspin); } +/** + * Diagnotic routine to print DCB data in a tabular form. + * + * @param pdcb DCB to print results to + */ +void +dListDCBs(DCB *pdcb) +{ +DCB *dcb; + + spinlock_acquire(&dcbspin); + dcb = allDCBs; + dcb_printf(pdcb, " %-10s | %-26s | %-20s | %s\n", + "DCB", "State", "Service", "Remote"); + dcb_printf(pdcb, "---------------------------------------------------------------------------\n"); + while (dcb) + { + dcb_printf(pdcb, " %10p | %-26s | %-20s | %s\n", + dcb, gw_dcb_state2string(dcb->state), + (dcb->service ? dcb->service->name : ""), + (dcb->remote ? dcb->remote : "")); + dcb = dcb->next; + } + spinlock_release(&dcbspin); +} + /** * Diagnostic to print a DCB to another DCB * @@ -1161,16 +1197,22 @@ dprintDCB(DCB *pdcb, DCB *dcb) dcb_printf(pdcb, "\tDCB state: %s\n", gw_dcb_state2string(dcb->state)); if (dcb->remote) dcb_printf(pdcb, "\tConnected to: %s\n", dcb->remote); - dcb_printf(pdcb, "\tOwning Session: %d\n", dcb->session); + dcb_printf(pdcb, "\tOwning Session: %p\n", dcb->session); if (dcb->writeq) dcb_printf(pdcb, "\tQueued write data: %d\n", gwbuf_length(dcb->writeq)); dcb_printf(pdcb, "\tStatistics:\n"); - dcb_printf(pdcb, "\t\tNo. of Reads: %d\n", dcb->stats.n_reads); - dcb_printf(pdcb, "\t\tNo. of Writes: %d\n", dcb->stats.n_writes); - dcb_printf(pdcb, "\t\tNo. of Buffered Writes: %d\n", dcb->stats.n_buffered); - dcb_printf(pdcb, "\t\tNo. of Accepts: %d\n", dcb->stats.n_accepts); - dcb_printf(pdcb, "\t\tNo. of High Water Events: %d\n", dcb->stats.n_high_water); - dcb_printf(pdcb, "\t\tNo. of Low Water Events: %d\n", dcb->stats.n_low_water); + dcb_printf(pdcb, "\t\tNo. of Reads: %d\n", + dcb->stats.n_reads); + dcb_printf(pdcb, "\t\tNo. of Writes: %d\n", + dcb->stats.n_writes); + dcb_printf(pdcb, "\t\tNo. of Buffered Writes: %d\n", + dcb->stats.n_buffered); + dcb_printf(pdcb, "\t\tNo. of Accepts: %d\n", + dcb->stats.n_accepts); + dcb_printf(pdcb, "\t\tNo. of High Water Events: %d\n", + dcb->stats.n_high_water); + dcb_printf(pdcb, "\t\tNo. of Low Water Events: %d\n", + dcb->stats.n_low_water); } /** diff --git a/server/include/dcb.h b/server/include/dcb.h index 49a262f73..e7d2ec716 100644 --- a/server/include/dcb.h +++ b/server/include/dcb.h @@ -273,6 +273,7 @@ void printAllDCBs(); /* Debug to print all DCB in the system */ void printDCB(DCB *); /* Debug print routine */ void dprintAllDCBs(DCB *); /* Debug to print all DCB in the system */ void dprintDCB(DCB *, DCB *); /* Debug to print a DCB in the system */ +void dListDCBs(DCB *); /* List all DCBs in the system */ const char *gw_dcb_state2string(int); /* DCB state to string */ void dcb_printf(DCB *, const char *, ...); /* DCB version of printf */ int dcb_isclient(DCB *); /* the DCB is the client of the session */ diff --git a/server/modules/routing/debugcmd.c b/server/modules/routing/debugcmd.c index eb0fc2832..4bd19e957 100644 --- a/server/modules/routing/debugcmd.c +++ b/server/modules/routing/debugcmd.c @@ -116,7 +116,7 @@ struct subcommand showoptions[] = { "Show the poll statistics", "Show the poll statistics", {0, 0, 0} }, - { "filter", 0, dprintFilter, + { "filter", 1, dprintFilter, "Show details of a filter, called with a filter name", "Show details of a filter, called with the address of a filter", {ARG_TYPE_FILTER, 0, 0} }, @@ -168,6 +168,10 @@ struct subcommand showoptions[] = { * The subcommands of the list command */ struct subcommand listoptions[] = { + { "dcbs", 0, dListDCBs, + "List all the DCBs active within MaxScale", + "List all the DCBs active within MaxScale", + {0, 0, 0} }, { "filters", 0, dListFilters, "List all the filters defined within MaxScale", "List all the filters defined within MaxScale",