pdb: add 'dbgl' iocsh command
This commit is contained in:
@ -718,6 +718,28 @@ FieldName::lookup(const epics::pvData::PVStructurePtr& S, epics::pvData::PVField
|
||||
return ret;
|
||||
}
|
||||
|
||||
void FieldName::show() const
|
||||
{
|
||||
if(parts.empty()) {
|
||||
printf("/");
|
||||
return;
|
||||
}
|
||||
|
||||
bool first = true;
|
||||
for(size_t i=0, N=parts.size(); i<N; i++)
|
||||
{
|
||||
if(!first) {
|
||||
printf(".");
|
||||
} else {
|
||||
first = false;
|
||||
}
|
||||
if(parts[i].isArray())
|
||||
printf("%s[%u]", parts[i].name.c_str(), (unsigned)parts[i].index);
|
||||
else
|
||||
printf("%s", parts[i].name.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
epicsExportAddress(int, PDBProviderDebug);
|
||||
}
|
||||
|
@ -25,6 +25,9 @@ struct PDBPV
|
||||
epics::pvAccess::Channel::shared_pointer
|
||||
connect(const std::tr1::shared_ptr<PDBProvider>& prov,
|
||||
const epics::pvAccess::ChannelRequester::shared_pointer& req) =0;
|
||||
|
||||
// print info to stdout (with iocsh redirection)
|
||||
virtual void show(int lvl) {}
|
||||
};
|
||||
|
||||
struct epicsShareClass PDBProvider : public epics::pvAccess::ChannelProvider,
|
||||
|
@ -1,6 +1,9 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
// rediect stdio/stderr for iocsh
|
||||
#include <epicsStdio.h>
|
||||
|
||||
#include <epicsAtomic.h>
|
||||
#include <dbAccess.h>
|
||||
|
||||
@ -217,6 +220,26 @@ void PDBGroupPV::finalizeMonitor()
|
||||
}
|
||||
}
|
||||
|
||||
void PDBGroupPV::show(int lvl)
|
||||
{
|
||||
// no locking as we only print things which are const after initialization
|
||||
|
||||
printf(" Atomic Get/Put:%s Monitor:%s Members:%zu\n",
|
||||
pgatomic?"yes":"no", monatomic?"yes":"no", members.size());
|
||||
|
||||
if(lvl<=1)
|
||||
return;
|
||||
|
||||
for(members_t::const_iterator it(members.begin()), end(members.end());
|
||||
it != end; ++it)
|
||||
{
|
||||
const Info& info = *it;
|
||||
printf(" ");
|
||||
info.attachment.show(); // printf()s
|
||||
printf("\t<-> %s\n", dbChannelName(info.chan));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PDBGroupChannel::PDBGroupChannel(const PDBGroupPV::shared_pointer& pv,
|
||||
const std::tr1::shared_ptr<pva::ChannelProvider>& prov,
|
||||
|
@ -124,11 +124,13 @@ struct epicsShareClass PDBGroupPV : public PDBPV
|
||||
virtual
|
||||
epics::pvAccess::Channel::shared_pointer
|
||||
connect(const std::tr1::shared_ptr<PDBProvider>& prov,
|
||||
const epics::pvAccess::ChannelRequester::shared_pointer& req);
|
||||
const epics::pvAccess::ChannelRequester::shared_pointer& req) OVERRIDE;
|
||||
|
||||
void addMonitor(PDBGroupMonitor*);
|
||||
void removeMonitor(PDBGroupMonitor*);
|
||||
void finalizeMonitor();
|
||||
|
||||
virtual void show(int lvl) OVERRIDE;
|
||||
};
|
||||
|
||||
struct epicsShareClass PDBGroupChannel : public BaseChannel,
|
||||
|
@ -56,7 +56,9 @@ struct epicsShareClass DBCH {
|
||||
void swap(DBCH&);
|
||||
|
||||
operator dbChannel*() { return chan; }
|
||||
operator const dbChannel*() const { return chan; }
|
||||
dbChannel *operator->() { return chan; }
|
||||
const dbChannel *operator->() const { return chan; }
|
||||
private:
|
||||
DBCH(const DBCH&);
|
||||
DBCH& operator=(const DBCH&);
|
||||
@ -287,6 +289,7 @@ struct epicsShareClass FieldName
|
||||
epics::pvData::PVFieldPtr
|
||||
lookup(const epics::pvData::PVStructurePtr& S, epics::pvData::PVField** ppenclose) const;
|
||||
|
||||
void show() const;
|
||||
private:
|
||||
FieldName(const FieldName&);
|
||||
FieldName& operator=(const FieldName&);
|
||||
|
@ -3,6 +3,8 @@
|
||||
#include <initHooks.h>
|
||||
#include <epicsExit.h>
|
||||
#include <epicsThread.h>
|
||||
#include <epicsString.h>
|
||||
#include <epicsStdio.h>
|
||||
|
||||
#include <dbAccess.h>
|
||||
#include <dbChannel.h>
|
||||
@ -43,13 +45,52 @@ void QSRVRegistrar_counters()
|
||||
epics::registerRefCounter("PDBProvider", &PDBProvider::num_instances);
|
||||
}
|
||||
|
||||
static
|
||||
namespace {
|
||||
|
||||
void dbgl(int lvl, const char *pattern)
|
||||
{
|
||||
if(!pattern)
|
||||
pattern = "";
|
||||
|
||||
try {
|
||||
PDBProvider::shared_pointer prov(
|
||||
std::tr1::dynamic_pointer_cast<PDBProvider>(
|
||||
pva::ChannelProviderRegistry::servers()->getProvider("QSRV")));
|
||||
if(!prov)
|
||||
throw std::runtime_error("No Provider (PVA server not running?)");
|
||||
|
||||
PDBProvider::persist_pv_map_t pvs;
|
||||
{
|
||||
epicsGuard<epicsMutex> G(prov->transient_pv_map.mutex());
|
||||
pvs = prov->persist_pv_map; // copy map
|
||||
}
|
||||
|
||||
for(PDBProvider::persist_pv_map_t::const_iterator it(pvs.begin()), end(pvs.end());
|
||||
it != end; ++it)
|
||||
{
|
||||
if(pattern[0] && epicsStrGlobMatch(it->first.c_str(), pattern)==0)
|
||||
continue;
|
||||
|
||||
printf("%s\n", it->first.c_str());
|
||||
if(lvl<=0)
|
||||
continue;
|
||||
it->second->show(lvl);
|
||||
}
|
||||
|
||||
}catch(std::exception& e){
|
||||
fprintf(stderr, "Error: %s\n", e.what());
|
||||
}
|
||||
}
|
||||
|
||||
void QSRVRegistrar()
|
||||
{
|
||||
QSRVRegistrar_counters();
|
||||
pva::ChannelProviderRegistry::servers()->addSingleton<PDBProvider>("QSRV");
|
||||
epics::iocshRegister<int, const char*, &dbgl>("dbgl", "level", "pattern");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
extern "C" {
|
||||
epicsExportRegistrar(QSRVRegistrar);
|
||||
}
|
||||
|
Reference in New Issue
Block a user