From c97214d4d253f9d7716b0b1089478e8747656437 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Tue, 24 Jun 2008 21:49:57 +0000 Subject: [PATCH] Added initTrace command to exampleApp, registers a verbose initHook. --- src/makeBaseApp/Makefile | 2 ++ src/makeBaseApp/top/exampleApp/src/Makefile | 2 ++ .../top/exampleApp/src/initTrace.c | 34 +++++++++++++++++++ .../top/exampleApp/src/initTrace.dbd | 1 + .../top/exampleBoot/ioc/st.cmd@Common | 13 ++++--- .../top/exampleBoot/ioc/st.cmd@RTEMS | 13 ++++--- .../top/exampleBoot/ioc/st.cmd@vxWorks | 18 +++++----- 7 files changed, 64 insertions(+), 19 deletions(-) create mode 100644 src/makeBaseApp/top/exampleApp/src/initTrace.c create mode 100644 src/makeBaseApp/top/exampleApp/src/initTrace.dbd diff --git a/src/makeBaseApp/Makefile b/src/makeBaseApp/Makefile index 3bacada5f..d59418c8e 100644 --- a/src/makeBaseApp/Makefile +++ b/src/makeBaseApp/Makefile @@ -45,6 +45,8 @@ TEMPLATES += top/exampleApp/src/dbSubExample.dbd TEMPLATES += top/exampleApp/src/_APPNAME_Main.cpp TEMPLATES += top/exampleApp/src/_APPNAME_Hello.c TEMPLATES += top/exampleApp/src/_APPNAME_Hello.dbd +TEMPLATES += top/exampleApp/src/initTrace.c +TEMPLATES += top/exampleApp/src/initTrace.dbd TEMPLATES += top/exampleBoot/Makefile TEMPLATES += top/exampleBoot/nfsCommands@vxWorks diff --git a/src/makeBaseApp/top/exampleApp/src/Makefile b/src/makeBaseApp/top/exampleApp/src/Makefile index 3ab7ca1ac..9f92349be 100644 --- a/src/makeBaseApp/top/exampleApp/src/Makefile +++ b/src/makeBaseApp/top/exampleApp/src/Makefile @@ -33,6 +33,7 @@ _APPNAME__DBD += base.dbd _APPNAME__DBD += xxxSupport.dbd _APPNAME__DBD += dbSubExample.dbd _APPNAME__DBD += _APPNAME_Hello.dbd +_APPNAME__DBD += initTrace.dbd # _registerRecordDeviceDriver.cpp will be created from .dbd _APPNAME__SRCS += _APPNAME__registerRecordDeviceDriver.cpp @@ -42,6 +43,7 @@ _APPNAME__SRCS_vxWorks += -nil- # Add locally compiled object code _APPNAME__SRCS += dbSubExample.c _APPNAME__SRCS += _APPNAME_Hello.c +_APPNAME__SRCS += initTrace.c # The following adds support from base/src/vxWorks _APPNAME__OBJS_vxWorks += $(EPICS_BASE_BIN)/vxComLibrary diff --git a/src/makeBaseApp/top/exampleApp/src/initTrace.c b/src/makeBaseApp/top/exampleApp/src/initTrace.c new file mode 100644 index 000000000..48d8c8319 --- /dev/null +++ b/src/makeBaseApp/top/exampleApp/src/initTrace.c @@ -0,0 +1,34 @@ +/* initTrace.c */ + +/* + * An initHook routine to trace the iocInit() process. + * Prints out the name of each state as it is reached. + */ + +#include + +#include "initHooks.h" +#include "epicsExport.h" +#include "iocsh.h" + + +static void trace(initHookState state) { + printf("iocInit: Reached %s\n", initHookName(state)); +} + +int traceIocInit(void) { + initHookRegister(trace); + puts("iocInit will be traced"); + return 0; +} + + +static const iocshFuncDef traceInitFuncDef = {"traceIocInit", 0, NULL}; +static void traceInitFunc(const iocshArgBuf *args) { + traceIocInit(); +} + +static void initTraceRegister(void) { + iocshRegister(&traceInitFuncDef, traceInitFunc); +} +epicsExportRegistrar(initTraceRegister); diff --git a/src/makeBaseApp/top/exampleApp/src/initTrace.dbd b/src/makeBaseApp/top/exampleApp/src/initTrace.dbd new file mode 100644 index 000000000..8083c0a50 --- /dev/null +++ b/src/makeBaseApp/top/exampleApp/src/initTrace.dbd @@ -0,0 +1 @@ +registrar(initTraceRegister) diff --git a/src/makeBaseApp/top/exampleBoot/ioc/st.cmd@Common b/src/makeBaseApp/top/exampleBoot/ioc/st.cmd@Common index cf29b046a..da313e14a 100644 --- a/src/makeBaseApp/top/exampleBoot/ioc/st.cmd@Common +++ b/src/makeBaseApp/top/exampleBoot/ioc/st.cmd@Common @@ -8,18 +8,21 @@ cd ${TOP} ## Register all support components -dbLoadDatabase("dbd/_APPNAME_.dbd") -_CSAFEAPPNAME__registerRecordDeviceDriver(pdbbase) +dbLoadDatabase "dbd/_APPNAME_.dbd" +_CSAFEAPPNAME__registerRecordDeviceDriver pdbbase ## Load record instances dbLoadTemplate "db/userHost.substitutions" -dbLoadRecords("db/dbSubExample.db","user=_USER_Host") +dbLoadRecords "db/dbSubExample.db", "user=_USER_Host" ## Set this to see messages from mySub #var mySubDebug 1 +## Run this to trace the stages of iocInit +#traceIocInit + cd ${TOP}/iocBoot/${IOC} -iocInit() +iocInit ## Start any sequence programs -#seq sncExample,"user=_USER_Host" +#seq sncExample, "user=_USER_Host" diff --git a/src/makeBaseApp/top/exampleBoot/ioc/st.cmd@RTEMS b/src/makeBaseApp/top/exampleBoot/ioc/st.cmd@RTEMS index 9d67c1b0a..801070d98 100644 --- a/src/makeBaseApp/top/exampleBoot/ioc/st.cmd@RTEMS +++ b/src/makeBaseApp/top/exampleBoot/ioc/st.cmd@RTEMS @@ -6,17 +6,20 @@ #< envPaths ## Register all support components -dbLoadDatabase("dbd/_APPNAME_.dbd") -_CSAFEAPPNAME__registerRecordDeviceDriver(pdbbase) +dbLoadDatabase "dbd/_APPNAME_.dbd" +_CSAFEAPPNAME__registerRecordDeviceDriver pdbbase ## Load record instances dbLoadTemplate "db/user.substitutions" -dbLoadRecords("db/dbSubExample.db","user=_USER_") +dbLoadRecords "db/dbSubExample.db", "user=_USER_" ## Set this to see messages from mySub #var mySubDebug 1 -iocInit() +## Run this to trace the stages of iocInit +#traceIocInit + +iocInit ## Start any sequence programs -#seq sncExample,"user=_USER_" +#seq sncExample, "user=_USER_" diff --git a/src/makeBaseApp/top/exampleBoot/ioc/st.cmd@vxWorks b/src/makeBaseApp/top/exampleBoot/ioc/st.cmd@vxWorks index 243fc03ec..031f0c05f 100644 --- a/src/makeBaseApp/top/exampleBoot/ioc/st.cmd@vxWorks +++ b/src/makeBaseApp/top/exampleBoot/ioc/st.cmd@vxWorks @@ -8,28 +8,28 @@ #< ../nfsCommands cd topbin + ## You may have to change _APPNAME_ to something else ## everywhere it appears in this file - ld < _APPNAME_.munch -## This drvTS initializer is needed if the IOC has a hardware event system -#TSinit - ## Register all support components cd top -dbLoadDatabase("dbd/_APPNAME_.dbd",0,0) -_CSAFEAPPNAME__registerRecordDeviceDriver(pdbbase) +dbLoadDatabase "dbd/_APPNAME_.dbd" +_CSAFEAPPNAME__registerRecordDeviceDriver pdbbase ## Load record instances dbLoadTemplate "db/user.substitutions" -dbLoadRecords("db/dbSubExample.db","user=_USER_") +dbLoadRecords "db/dbSubExample.db", "user=_USER_" ## Set this to see messages from mySub #mySubDebug = 1 +## Run this to trace the stages of iocInit +#traceIocInit + cd startup -iocInit() +iocInit ## Start any sequence programs -#seq &sncExample,"user=_USER_" +#seq &sncExample, "user=_USER_"