On 1 August 2016 at 07:19, Mike Leach mike.leach@linaro.org wrote:
Deprecated type specific API - createDecoderX fns in favour of createDecoder(name) fn.
Updated C-API handler code and packet lister test program to work with this change.
Signed-off-by: Mike Leach mike.leach@linaro.org
decoder/include/common/ocsd_dcd_tree.h | 22 -- decoder/include/common/ocsd_dcd_tree_elem.h | 148 ++------ decoder/source/c_api/ocsd_c_api.cpp | 146 ++++++-- decoder/source/ocsd_dcd_tree.cpp | 417 +-------------------- .../snapshot_parser_lib/source/ss_to_dcdtree.cpp | 48 +-- decoder/tests/source/trc_pkt_lister.cpp | 16 +- 6 files changed, 177 insertions(+), 620 deletions(-)
diff --git a/decoder/include/common/ocsd_dcd_tree.h b/decoder/include/common/ocsd_dcd_tree.h index 77b69bf..7073a5d 100644 --- a/decoder/include/common/ocsd_dcd_tree.h +++ b/decoder/include/common/ocsd_dcd_tree.h @@ -98,34 +98,12 @@ public: const uint8_t *pDataBlock, uint32_t *numBytesProcessed);
/* create packet processing element only - attach to CSID in config
optionally attach the output interface
*/
ocsd_err_t createETMv3PktProcessor(EtmV3Config *p_config, IPktDataIn<EtmV3TrcPacket> *p_Iout = 0);
ocsd_err_t createETMv4IPktProcessor(EtmV4Config *p_config, IPktDataIn<EtmV4ITrcPacket> *p_Iout = 0);
ocsd_err_t createETMv4DPktProcessor(EtmV4Config *p_config, IPktDataIn<EtmV4DTrcPacket> *p_Iout = 0);
ocsd_err_t createPTMPktProcessor(PtmConfig *p_config, IPktDataIn<PtmTrcPacket> *p_Iout = 0);
ocsd_err_t createSTMPktProcessor(STMConfig *p_config, IPktDataIn<StmTrcPacket> *p_Iout = 0);
/* create full decoder - packet processor + packet decoder - attach to CSID in config
All use the standard generic elements output interface.
*/
ocsd_err_t createETMv3Decoder(EtmV3Config *p_config);
ocsd_err_t createETMv4Decoder(EtmV4Config *p_config, bool bDataChannel = false);
ocsd_err_t createPTMDecoder(PtmConfig *p_config);
/*! Create a decoder by registered name */ ocsd_err_t createDecoder(const std::string &decoderName, const int createFlags, const CSConfig *pConfig);
/* remove a decoder / packet processor attached to an ID - allows another decoder to be substituted. */ ocsd_err_t removeDecoder(const uint8_t CSID);
/* attach custom / external decoders */
ocsd_err_t attachExternPktProcessor(const uint8_t CSID, ITrcDataIn* ext_data_in, void *p_pkt_proc_obj);
ocsd_err_t attachExternDecoder(const uint8_t CSID, ITrcDataIn* ext_data_in, void *p_pkt_proc_obj, void *p_decoder_obj);
/* set key interfaces - attach / replace on any existing tree components? */ void setInstrDecoder(IInstrDecode *i_instr_decode); void setMemAccessI(ITargetMemAccess *i_mem_access);
diff --git a/decoder/include/common/ocsd_dcd_tree_elem.h b/decoder/include/common/ocsd_dcd_tree_elem.h index 31fe011..6969816 100644 --- a/decoder/include/common/ocsd_dcd_tree_elem.h +++ b/decoder/include/common/ocsd_dcd_tree_elem.h @@ -35,6 +35,9 @@ #ifndef ARM_OCSD_DCD_TREE_ELEM_H_INCLUDED #define ARM_OCSD_DCD_TREE_ELEM_H_INCLUDED
+#include "common/ocsd_dcd_mngr_i.h" +#include "common/trc_component.h"
/** @class decoder_elements
- @brief Decode tree element base structure.
- @addtogroup dcd_tree
@@ -46,32 +49,9 @@ */ typedef struct _decoder_elements {
- union {
struct {
TrcPktProcEtmV3 *proc;
TrcPktDecodeEtmV3 *dcd;
} etmv3; /**< ETMv3 decoders */
struct {
TrcPktProcEtmV4I *proc;
TrcPktDecodeEtmV4I *dcd;
} etmv4i; /**< ETMv4 Decoders */
struct {
TrcPktProcEtmV4D *proc;
void * /*TrcPktDecodeEtmV4 **/ dcd; //** TBD
} etmv4d;
struct {
TrcPktProcPtm *proc;
TrcPktDecodePtm *dcd;
} ptm;
struct {
TrcPktProcStm *proc;
void * /*TrcPktDecodeStm **/ dcd; //** TBD
} stm;
struct {
void * proc;
void * dcd;
} extern_custom;
- } decoder;
- std::string dcd_name;
- TraceComponent *dcd_handle;
- IDecoderMngr *dcd_mngr; ocsd_trace_protocol_t protocol; bool created; /**< decode tree created this element (destroy it on tree destruction) */
} decoder_element; @@ -83,113 +63,47 @@ typedef struct _decoder_elements
*/ -class DecodeTreeElement : public decoder_element +class DecodeTreeElement : protected decoder_element { public: DecodeTreeElement(); ~DecodeTreeElement() {};
- void SetProcElement(const ocsd_trace_protocol_t elem_type, void *pkt_proc, const bool created);
- void SetDecoderElement(void *pkt_decode);
- void SetDecoderElement(const std::string &name, IDecoderMngr *dcdMngr, TraceComponent *pHandle, bool bCreated); void DestroyElem();
- TrcPktProcEtmV3 * getEtmV3PktProc() const
- {
if(protocol == OCSD_PROTOCOL_ETMV3)
return decoder.etmv3.proc;
return 0;
- }
- TrcPktProcEtmV4I * getEtmV4IPktProc() const
- {
if(protocol == OCSD_PROTOCOL_ETMV4I)
return decoder.etmv4i.proc;
return 0;
- }
- TrcPktDecodeEtmV4I * getEtmV4IPktDecoder() const
- {
if(protocol == OCSD_PROTOCOL_ETMV4I)
return decoder.etmv4i.dcd;
return 0;
- }
- TrcPktProcEtmV4D * getEtmV4DPktProc() const
- {
if(protocol == OCSD_PROTOCOL_ETMV4D)
return decoder.etmv4d.proc;
return 0;
- }
- TrcPktProcPtm * getPtmPktProc() const
- {
if(protocol == OCSD_PROTOCOL_PTM)
return decoder.ptm.proc;
return 0;
- }
- TrcPktDecodePtm * getPtmPktDecoder() const
- {
if(protocol == OCSD_PROTOCOL_PTM)
return decoder.ptm.dcd;
return 0;
- }
- TrcPktProcStm * getStmPktProc() const
- {
if(protocol == OCSD_PROTOCOL_STM)
return decoder.stm.proc;
return 0;
- }
- void * getExternPktProc() const
- {
if(protocol == OCSD_PROTOCOL_EXTERN)
return decoder.extern_custom.proc;
return 0;
- }
- TrcPktDecodeI * getDecoderBaseI() const
- {
TrcPktDecodeI *pDecoder = 0;
switch(protocol)
{
case OCSD_PROTOCOL_ETMV3:
pDecoder = dynamic_cast<TrcPktDecodeI *>(decoder.etmv3.dcd);
break;
case OCSD_PROTOCOL_ETMV4I:
pDecoder = dynamic_cast<TrcPktDecodeI *>(decoder.etmv4i.dcd);
break;
case OCSD_PROTOCOL_ETMV4D:
//pDecoder = dynamic_cast<TrcPktDecodeI *>(decoder.etmv4d.dcd);
break;
case OCSD_PROTOCOL_PTM:
pDecoder = dynamic_cast<TrcPktDecodeI *>(decoder.ptm.dcd);
break;
case OCSD_PROTOCOL_STM:
//pDecoder = dynamic_cast<TrcPktDecodeI *>(decoder.stm.dcd);
break;
case OCSD_PROTOCOL_EXTERN:
pDecoder = static_cast<TrcPktDecodeI *>(decoder.extern_custom.dcd);
break;
}
return pDecoder;
- }
- const std::string &getDecoderTypeName() { return dcd_name; };
- IDecoderMngr *getDecoderMngr() { return dcd_mngr; }; ocsd_trace_protocol_t getProtocol() const { return protocol; };
- TraceComponent *getDecoderHandle() { return dcd_handle; };
};
inline DecodeTreeElement::DecodeTreeElement() {
- // set one element in union to zero all.
- decoder.extern_custom.dcd = 0;
- decoder.extern_custom.proc = 0;
- dcd_name = "unknown";
- dcd_mngr = 0;
- dcd_handle = 0; protocol = OCSD_PROTOCOL_END; created = false;
}
+inline void DecodeTreeElement::SetDecoderElement(const std::string &name, IDecoderMngr *dcdMngr, TraceComponent *pHandle, bool bCreated) +{
- dcd_name = name;
- dcd_mngr = dcdMngr;
- dcd_handle = pHandle;
- protocol = OCSD_PROTOCOL_EXTERN;
- if(dcd_mngr)
protocol = dcd_mngr->getProtocolType();
- created = bCreated;
+}
+inline void DecodeTreeElement::DestroyElem() +{
- if(created && (dcd_mngr != 0) && (dcd_handle != 0))
dcd_mngr->destroyDecoder(dcd_handle);
+}
#endif // ARM_OCSD_DCD_TREE_ELEM_H_INCLUDED
/* End of File ocsd_dcd_tree_elem.h */ diff --git a/decoder/source/c_api/ocsd_c_api.cpp b/decoder/source/c_api/ocsd_c_api.cpp index c1d8215..d66cdb0 100644 --- a/decoder/source/c_api/ocsd_c_api.cpp +++ b/decoder/source/c_api/ocsd_c_api.cpp @@ -49,6 +49,10 @@ namespace std { const nothrow_t nothrow = nothrow_t(); } #endif #endif
+/*******************************************************************************/ +/* C API internal helper function declarations */ +/*******************************************************************************/ +static ocsd_err_t ocsd_dt_attach_pkt_mon(const dcd_tree_handle_t handle, const uint8_t trc_chan_id, ocsd_trace_protocol_t protocol, ITrcTypedBase *pPktMonIf, TraceElemCBBase *pCBObj);
/*******************************************************************************/ /* C library data - additional data on top of the C++ library objects */ @@ -153,8 +157,17 @@ OCSD_C_API ocsd_err_t ocsd_dt_create_etmv4i_pkt_proc(const dcd_tree_handle_t han err = OCSD_ERR_MEM;
if(err == OCSD_OK)
err = ((DecodeTree *)handle)->createETMv4IPktProcessor(&cfg,p_CBObj);
{
err = ((DecodeTree *)handle)->createDecoder(OCSD_BUILTIN_DCD_ETMV4I,OCSD_CREATE_FLG_PACKET_PROC,&cfg);
if(err == OCSD_OK)
{
DecodeTreeElement *pTElem = ((DecodeTree *)handle)->getDecoderElement(cfg.getTraceID());
if(pTElem)
err = pTElem->getDecoderMngr()->attachPktSink(pTElem->getDecoderHandle(),p_CBObj);
else
err = OCSD_ERR_INVALID_PARAM_VAL;
}
} if(err == OCSD_OK) { std::map<dcd_tree_handle_t, lib_dt_data_list *>::iterator it;
@@ -181,7 +194,7 @@ OCSD_C_API ocsd_err_t ocsd_dt_create_etmv4i_decoder(const dcd_tree_handle_t hand
// no need for a spcific CB object here - standard generic elements output used. if(err == OCSD_OK)
err = ((DecodeTree *)handle)->createETMv4Decoder(&cfg);
} else err = OCSD_ERR_INVALID_PARAM_VAL;err = ((DecodeTree *)handle)->createDecoder(OCSD_BUILTIN_DCD_ETMV4I,OCSD_CREATE_FLG_FULL_DECODER,&cfg);
@@ -200,13 +213,18 @@ OCSD_C_API ocsd_err_t ocsd_dt_attach_etmv4i_pkt_mon(const dcd_tree_handle_t hand EtmV4IPktMonCBObj *pktMonObj = new (std::nothrow) EtmV4IPktMonCBObj(pPktFn, p_context); if(pktMonObj != 0) {
pDTElem->getEtmV4IPktProc()->getRawPacketMonAttachPt()->attach(pktMonObj);
err = pDTElem->getDecoderMngr()->attachPktMonitor(pDTElem->getDecoderHandle(),pktMonObj);
// save object pointer for destruction later.
std::map<dcd_tree_handle_t, lib_dt_data_list *>::iterator it;
it = s_data_map.find(handle);
if(it != s_data_map.end())
it->second->cb_objs.push_back(pktMonObj);
if(err == OCSD_OK)
{
// save object pointer for destruction later.
std::map<dcd_tree_handle_t, lib_dt_data_list *>::iterator it;
it = s_data_map.find(handle);
if(it != s_data_map.end())
it->second->cb_objs.push_back(pktMonObj);
}
else
delete pktMonObj; } else err = OCSD_ERR_MEM;
@@ -232,7 +250,17 @@ OCSD_C_API ocsd_err_t ocsd_dt_create_etmv3_pkt_proc(const dcd_tree_handle_t hand err = OCSD_ERR_MEM;
if(err == OCSD_OK)
err = ((DecodeTree *)handle)->createETMv3PktProcessor(&cfg,p_CBObj);
{
err = ((DecodeTree *)handle)->createDecoder(OCSD_BUILTIN_DCD_ETMV3,OCSD_CREATE_FLG_PACKET_PROC,&cfg);
if(err == OCSD_OK)
{
DecodeTreeElement *pTElem = ((DecodeTree *)handle)->getDecoderElement(cfg.getTraceID());
if(pTElem)
err = pTElem->getDecoderMngr()->attachPktSink(pTElem->getDecoderHandle(),p_CBObj);
else
err = OCSD_ERR_INVALID_PARAM_VAL;
}
} if(err == OCSD_OK) {
@@ -259,7 +287,7 @@ OCSD_C_API ocsd_err_t ocsd_dt_create_etmv3_decoder(const dcd_tree_handle_t handl
// no need for a spcific CB object here - standard generic elements output used. if(err == OCSD_OK)
err = ((DecodeTree *)handle)->createETMv3Decoder(&cfg);
} else err = OCSD_ERR_INVALID_PARAM_VAL;err = ((DecodeTree *)handle)->createDecoder(OCSD_BUILTIN_DCD_ETMV3,OCSD_CREATE_FLG_FULL_DECODER,&cfg);
@@ -278,13 +306,18 @@ OCSD_C_API ocsd_err_t ocsd_dt_attach_etmv3_pkt_mon(const dcd_tree_handle_t handl EtmV3PktMonCBObj *pktMonObj = new (std::nothrow) EtmV3PktMonCBObj(pPktFn, p_context); if(pktMonObj != 0) {
pDTElem->getEtmV3PktProc()->getRawPacketMonAttachPt()->attach(pktMonObj);
err = pDTElem->getDecoderMngr()->attachPktMonitor(pDTElem->getDecoderHandle(),pktMonObj);
// save object pointer for destruction later.
std::map<dcd_tree_handle_t, lib_dt_data_list *>::iterator it;
it = s_data_map.find(handle);
if(it != s_data_map.end())
it->second->cb_objs.push_back(pktMonObj);
if(err == OCSD_OK)
{
// save object pointer for destruction later.
std::map<dcd_tree_handle_t, lib_dt_data_list *>::iterator it;
it = s_data_map.find(handle);
if(it != s_data_map.end())
it->second->cb_objs.push_back(pktMonObj);
}
else
delete pktMonObj; } else err = OCSD_ERR_MEM;
@@ -311,7 +344,17 @@ OCSD_C_API ocsd_err_t ocsd_dt_create_ptm_pkt_proc(const dcd_tree_handle_t handle err = OCSD_ERR_MEM;
if(err == OCSD_OK)
err = ((DecodeTree *)handle)->createPTMPktProcessor(&cfg,p_CBObj);
{
err = ((DecodeTree *)handle)->createDecoder(OCSD_BUILTIN_DCD_PTM,OCSD_CREATE_FLG_PACKET_PROC,&cfg);
if(err == OCSD_OK)
{
DecodeTreeElement *pTElem = ((DecodeTree *)handle)->getDecoderElement(cfg.getTraceID());
if(pTElem)
err = pTElem->getDecoderMngr()->attachPktSink(pTElem->getDecoderHandle(),p_CBObj);
else
err = OCSD_ERR_INVALID_PARAM_VAL;
}
} if(err == OCSD_OK) {
@@ -338,7 +381,7 @@ OCSD_C_API ocsd_err_t ocsd_dt_create_ptm_decoder(const dcd_tree_handle_t handle,
// no need for a spcific CB object here - standard generic elements output used. if(err == OCSD_OK)
err = ((DecodeTree *)handle)->createPTMDecoder(&cfg);
} else err = OCSD_ERR_INVALID_PARAM_VAL;err = ((DecodeTree *)handle)->createDecoder(OCSD_BUILTIN_DCD_PTM,OCSD_CREATE_FLG_FULL_DECODER,&cfg);
@@ -347,7 +390,14 @@ OCSD_C_API ocsd_err_t ocsd_dt_create_ptm_decoder(const dcd_tree_handle_t handle,
OCSD_C_API ocsd_err_t ocsd_dt_attach_ptm_pkt_mon(const dcd_tree_handle_t handle, const uint8_t trc_chan_id, FnPtmPktMonDataIn pPktFn, const void *p_context) {
- ocsd_err_t err = OCSD_OK;
- PtmPktMonCBObj *pktMonObj = new (std::nothrow) PtmPktMonCBObj(pPktFn, p_context);
- err = ocsd_dt_attach_pkt_mon(handle,trc_chan_id,OCSD_PROTOCOL_PTM,pktMonObj,pktMonObj);
- if(err != OCSD_OK)
delete pktMonObj;
+#if 0
What is this for? Perhaps debug code you want to keep? If so I suggest adding a #define DEGUB [0,1] at the top of the file.
if(handle != C_API_INVALID_TREE_HANDLE) { DecodeTree *pDT = static_cast<DecodeTree *>(handle);
@@ -357,13 +407,18 @@ OCSD_C_API ocsd_err_t ocsd_dt_attach_ptm_pkt_mon(const dcd_tree_handle_t handle, PtmPktMonCBObj *pktMonObj = new (std::nothrow) PtmPktMonCBObj(pPktFn, p_context); if(pktMonObj != 0) {
pDTElem->getPtmPktProc()->getRawPacketMonAttachPt()->attach(pktMonObj);
// save object pointer for destruction later.
std::map<dcd_tree_handle_t, lib_dt_data_list *>::iterator it;
it = s_data_map.find(handle);
if(it != s_data_map.end())
it->second->cb_objs.push_back(pktMonObj);
err = pDTElem->getDecoderMngr()->attachPktMonitor(pDTElem->getDecoderHandle(),pktMonObj);
if(err == OCSD_OK)
{
// save object pointer for destruction later.
std::map<dcd_tree_handle_t, lib_dt_data_list *>::iterator it;
it = s_data_map.find(handle);
if(it != s_data_map.end())
it->second->cb_objs.push_back(pktMonObj);
}
else
delete pktMonObj; } else err = OCSD_ERR_MEM;
@@ -373,11 +428,11 @@ OCSD_C_API ocsd_err_t ocsd_dt_attach_ptm_pkt_mon(const dcd_tree_handle_t handle, } else err = OCSD_ERR_INVALID_PARAM_VAL;
- return err;
+#endif
- return err;
}
OCSD_C_API ocsd_err_t ocsd_dt_create_stm_pkt_proc(const dcd_tree_handle_t handle, const void *stm_cfg, FnStmPacketDataIn pPktFn, const void *p_context) { ocsd_err_t err = OCSD_OK; @@ -391,7 +446,7 @@ OCSD_C_API ocsd_err_t ocsd_dt_create_stm_pkt_proc(const dcd_tree_handle_t handle err = OCSD_ERR_MEM;
if(err == OCSD_OK)
err = ((DecodeTree *)handle)->createSTMPktProcessor(&cfg,p_CBObj);
err = ((DecodeTree *)handle)->createDecoder(OCSD_BUILTIN_DCD_STM,OCSD_CREATE_FLG_FULL_DECODER,&cfg); if(err == OCSD_OK) {
@@ -684,6 +739,39 @@ OCSD_C_API void ocsd_tl_log_mapped_mem_ranges(const dcd_tree_handle_t handle) }
/*******************************************************************************/ +/* C API local fns */ +/*******************************************************************************/ +static ocsd_err_t ocsd_dt_attach_pkt_mon( const dcd_tree_handle_t handle,
const uint8_t trc_chan_id,
ocsd_trace_protocol_t protocol,
ITrcTypedBase *pPktMonIf,
TraceElemCBBase *pCBObj)
+{
- ocsd_err_t err = OCSD_OK;
- if(handle == C_API_INVALID_TREE_HANDLE)
return OCSD_ERR_INVALID_PARAM_VAL;
- DecodeTree *pDT = static_cast<DecodeTree *>(handle);
- DecodeTreeElement *pDTElem = pDT->getDecoderElement(trc_chan_id);
- if((pDTElem != 0) && (pDTElem->getProtocol() == protocol))
- {
err = pDTElem->getDecoderMngr()->attachPktMonitor(pDTElem->getDecoderHandle(),pPktMonIf);
if(err == OCSD_OK)
{
// save object pointer for destruction later.
std::map<dcd_tree_handle_t, lib_dt_data_list *>::iterator it;
it = s_data_map.find(handle);
if(it != s_data_map.end())
it->second->cb_objs.push_back(pCBObj);
}
- }
- else
err = OCSD_ERR_INVALID_PARAM_VAL; // trace ID not found or not match for element protocol type.
- return err;
+}
+/*******************************************************************************/ /* C API Helper objects */ /*******************************************************************************/
diff --git a/decoder/source/ocsd_dcd_tree.cpp b/decoder/source/ocsd_dcd_tree.cpp index c6c0a04..cd0995b 100644 --- a/decoder/source/ocsd_dcd_tree.cpp +++ b/decoder/source/ocsd_dcd_tree.cpp @@ -37,67 +37,6 @@ #include "common/ocsd_lib_dcd_register.h" #include "mem_acc/trc_mem_acc_mapper.h"
-void DecodeTreeElement::SetProcElement(const ocsd_trace_protocol_t protocol_type, void *pkt_proc, const bool decoder_created) -{
created = decoder_created;
protocol = protocol_type;
// as pointers are in a union, assume types OK and just set the extern void types.
decoder.extern_custom.proc = pkt_proc;
-}
-void DecodeTreeElement::SetDecoderElement(void *pkt_decode) -{
- decoder.extern_custom.dcd = pkt_decode;
-} -// destroy the elements using correctly typed pointers to ensure destructors are called. -void DecodeTreeElement::DestroyElem() -{
- if(created)
- {
switch(protocol)
{
case OCSD_PROTOCOL_ETMV3:
delete decoder.etmv3.proc;
decoder.etmv3.proc = 0;
delete decoder.etmv3.dcd;
decoder.etmv3.dcd = 0;
break;
case OCSD_PROTOCOL_ETMV4I:
delete decoder.etmv4i.proc;
decoder.etmv4i.proc = 0;
delete decoder.etmv4i.dcd;
decoder.etmv4i.dcd = 0;
break;
case OCSD_PROTOCOL_ETMV4D:
delete decoder.etmv4d.proc;
decoder.etmv4d.proc = 0;
//TBD: delete decoder.etmv4d.dcd;
decoder.etmv4d.dcd = 0;
break;
case OCSD_PROTOCOL_PTM:
delete decoder.ptm.proc;
decoder.ptm.proc = 0;
delete decoder.ptm.dcd;
decoder.ptm.dcd = 0;
break;
case OCSD_PROTOCOL_STM:
delete decoder.stm.proc;
decoder.stm.proc = 0;
// TBD: delete decoder.stm.dcd;
decoder.stm.dcd = 0;
break;
}
- }
-}
/***************************************************************/ ITraceErrorLog *DecodeTree::s_i_error_logger = &DecodeTree::s_error_logger; std::list<DecodeTree *> DecodeTree::s_trace_dcd_trees; /**< list of pointers to decode tree objects */ @@ -192,16 +131,11 @@ void DecodeTree::setInstrDecoder(IInstrDecode *i_instr_decode) { uint8_t elemID; DecodeTreeElement *pElem = 0;
TrcPktDecodeI *pDecoder;
pElem = getFirstElement(elemID); while(pElem != 0) {
pDecoder = pElem->getDecoderBaseI();
if(pDecoder)
{
pDecoder->getInstrDecodeAttachPt()->attach(i_instr_decode);
}
}pElem->getDecoderMngr()->attachInstrDecoder(pElem->getDecoderHandle(),i_instr_decode); pElem = getNextElement(elemID);
} @@ -210,16 +144,11 @@ void DecodeTree::setMemAccessI(ITargetMemAccess *i_mem_access) { uint8_t elemID; DecodeTreeElement *pElem = 0;
- TrcPktDecodeI *pDecoder;
- pElem = getFirstElement(elemID); while(pElem != 0) {
pDecoder = pElem->getDecoderBaseI();
if(pDecoder)
{
pDecoder->getMemoryAccessAttachPt()->attach(i_mem_access);
}
} m_i_mem_access = i_mem_access;pElem->getDecoderMngr()->attachMemAccessor(pElem->getDecoderHandle(),i_mem_access); pElem = getNextElement(elemID);
@@ -229,16 +158,11 @@ void DecodeTree::setGenTraceElemOutI(ITrcGenElemIn *i_gen_trace_elem) { uint8_t elemID; DecodeTreeElement *pElem = 0;
TrcPktDecodeI *pDecoder;
pElem = getFirstElement(elemID); while(pElem != 0) {
pDecoder = pElem->getDecoderBaseI();
if(pDecoder)
{
pDecoder->getTraceElemOutAttachPt()->attach(i_gen_trace_elem);
}
}pElem->getDecoderMngr()->attachOutputSink(pElem->getDecoderHandle(),i_gen_trace_elem); pElem = getNextElement(elemID);
} @@ -311,328 +235,6 @@ void DecodeTree::logMappedRanges() m_default_mapper->logMappedRanges(); }
-/* create packet processing element only - attach to CSID in config */ -ocsd_err_t DecodeTree::createETMv3PktProcessor(EtmV3Config *p_config, IPktDataIn<EtmV3TrcPacket> *p_Iout /*= 0*/) -{
- ocsd_err_t err = OCSD_OK;
- uint8_t CSID = 0; // default for single stream decoder (no deformatter) - we ignore the ID
- if(usingFormatter())
CSID = p_config->getTraceID();
- // see if we can attach to the desire CSID point
- if((err = createDecodeElement(CSID)) == OCSD_OK)
- {
TrcPktProcEtmV3 *pProc = new (std::nothrow) TrcPktProcEtmV3(CSID);
if(!pProc)
return OCSD_ERR_MEM;
// set the configuration
err = pProc->setProtocolConfig(p_config);
// attach the decoder if passed in.
if((err == OCSD_OK) && p_Iout)
err = pProc->getPacketOutAttachPt()->attach(p_Iout);
// attach the error logger
if(err == OCSD_OK)
pProc->getErrorLogAttachPt()->attach(DecodeTree::s_i_error_logger);
// attach to the frame demuxer.
if(usingFormatter() && (err == OCSD_OK))
err = m_frame_deformatter_root->getIDStreamAttachPt(p_config->getTraceID())->attach(pProc);
if(err != OCSD_OK)
{
// unable to attach as in use - delete the processor and return.
delete pProc;
destroyDecodeElement(CSID);
}
else
{
if(!usingFormatter())
setSingleRoot(pProc);
m_decode_elements[CSID]->SetProcElement(OCSD_PROTOCOL_ETMV3,pProc,true);
}
- }
- return err;
-}
-ocsd_err_t DecodeTree::createETMv4IPktProcessor(EtmV4Config *p_config, IPktDataIn<EtmV4ITrcPacket> *p_Iout/* = 0*/) -{
- ocsd_err_t err = OCSD_ERR_NOT_INIT;
- uint8_t CSID = 0; // default for single stream decoder (no deformatter) - we ignore the ID
- if(usingFormatter())
CSID = p_config->getTraceID();
- // see if we can attach to the desired CSID point
- if((err = createDecodeElement(CSID)) == OCSD_OK)
- {
TrcPktProcEtmV4I *pProc = 0;
pProc = new (std::nothrow) TrcPktProcEtmV4I(CSID);
if(!pProc)
return OCSD_ERR_MEM;
err = pProc->setProtocolConfig(p_config);
if((err == OCSD_OK) && p_Iout)
err = pProc->getPacketOutAttachPt()->attach(p_Iout);
if(err == OCSD_OK)
err = pProc->getErrorLogAttachPt()->attach(DecodeTree::s_i_error_logger);
if(usingFormatter() && (err == OCSD_OK))
err = m_frame_deformatter_root->getIDStreamAttachPt(p_config->getTraceID())->attach(pProc);
if(err != OCSD_OK)
{
// error - delete the processor and return
delete pProc;
destroyDecodeElement(CSID);
}
else
{
// register with decode element list
if(!usingFormatter())
setSingleRoot(pProc);
m_decode_elements[CSID]->SetProcElement(OCSD_PROTOCOL_ETMV4I,pProc,true);
}
- }
- return err;
-}
-ocsd_err_t DecodeTree::createETMv4DPktProcessor(EtmV4Config *p_config, IPktDataIn<EtmV4DTrcPacket> *p_Iout/* = 0*/) -{
- ocsd_err_t err = OCSD_ERR_NOT_INIT;
- uint8_t CSID = 0; // default for single stream decoder (no deformatter) - we ignore the ID
- if(usingFormatter())
CSID = p_config->getTraceID();
- // see if we can attach to the desired CSID point
- if((err = createDecodeElement(CSID)) == OCSD_OK)
- {
TrcPktProcEtmV4D *pProc = 0;
err = pProc->setProtocolConfig(p_config);
if((err == OCSD_OK) && p_Iout)
err = pProc->getPacketOutAttachPt()->attach(p_Iout);
if(err == OCSD_OK)
err = pProc->getErrorLogAttachPt()->attach(DecodeTree::s_i_error_logger);
if(usingFormatter() && (err == OCSD_OK))
err = m_frame_deformatter_root->getIDStreamAttachPt(p_config->getTraceID())->attach(pProc);
if(err != OCSD_OK)
{
// error - delete the processor and return
delete pProc;
destroyDecodeElement(CSID);
}
else
{
// register with decode element list
if(!usingFormatter())
setSingleRoot(pProc);
m_decode_elements[CSID]->SetProcElement(OCSD_PROTOCOL_ETMV4D,pProc,true);
}
- }
- return err;
-}
-ocsd_err_t DecodeTree::createPTMPktProcessor(PtmConfig *p_config, IPktDataIn<PtmTrcPacket> *p_Iout /*= 0*/) -{
- ocsd_err_t err = OCSD_OK;
- uint8_t CSID = 0; // default for single stream decoder (no deformatter) - we ignore the ID
- if(usingFormatter())
CSID = p_config->getTraceID();
- // see if we can attach to the desire CSID point
- if((err = createDecodeElement(CSID)) == OCSD_OK)
- {
TrcPktProcPtm *pProc = new (std::nothrow) TrcPktProcPtm(CSID);
if(!pProc)
return OCSD_ERR_MEM;
// set the configuration
err = pProc->setProtocolConfig(p_config);
// attach the decoder if passed in.
if((err == OCSD_OK) && p_Iout)
err = pProc->getPacketOutAttachPt()->attach(p_Iout);
// attach the error logger
if(err == OCSD_OK)
pProc->getErrorLogAttachPt()->attach(DecodeTree::s_i_error_logger);
// attach to the frame demuxer.
if(usingFormatter() && (err == OCSD_OK))
err = m_frame_deformatter_root->getIDStreamAttachPt(p_config->getTraceID())->attach(pProc);
if(err != OCSD_OK)
{
// unable to attach as in use - delete the processor and return.
delete pProc;
destroyDecodeElement(CSID);
}
else
{
if(!usingFormatter())
setSingleRoot(pProc);
m_decode_elements[CSID]->SetProcElement(OCSD_PROTOCOL_PTM,pProc,true);
}
- }
- return err;
-}
-ocsd_err_t DecodeTree::createSTMPktProcessor(STMConfig *p_config, IPktDataIn<StmTrcPacket> *p_Iout/* = 0*/) -{
- ocsd_err_t err = OCSD_ERR_NOT_INIT;
- uint8_t CSID = 0; // default for single stream decoder (no deformatter) - we ignore the ID
- if(usingFormatter())
CSID = p_config->getTraceID();
- // see if we can attach to the desired CSID point
- if((err = createDecodeElement(CSID)) == OCSD_OK)
- {
TrcPktProcStm *pProc = 0;
pProc = new (std::nothrow) TrcPktProcStm(CSID);
if(!pProc)
return OCSD_ERR_MEM;
err = pProc->setProtocolConfig(p_config);
if((err == OCSD_OK) && p_Iout)
err = pProc->getPacketOutAttachPt()->attach(p_Iout);
if(err == OCSD_OK)
err = pProc->getErrorLogAttachPt()->attach(DecodeTree::s_i_error_logger);
if(usingFormatter() && (err == OCSD_OK))
err = m_frame_deformatter_root->getIDStreamAttachPt(p_config->getTraceID())->attach(pProc);
if(err != OCSD_OK)
{
// error - delete the processor and return
delete pProc;
destroyDecodeElement(CSID);
}
else
{
// register with decode element list
if(!usingFormatter())
setSingleRoot(pProc);
m_decode_elements[CSID]->SetProcElement(OCSD_PROTOCOL_STM,pProc,true);
}
- }
- return err;
-}
-/* create full decoder - packet processor + packet decoder - attach to CSID in config */ -ocsd_err_t DecodeTree::createETMv3Decoder(EtmV3Config *p_config) -{
- ocsd_err_t err = OCSD_ERR_NOT_INIT;
- uint8_t CSID = 0; // default for single stream decoder (no deformatter) - we ignore the ID
- if(usingFormatter())
CSID = p_config->getTraceID();
- TrcPktDecodeEtmV3 *pProc = 0;
- pProc = new (std::nothrow) TrcPktDecodeEtmV3(CSID);
- if(!pProc)
return OCSD_ERR_MEM;
- err = createETMv3PktProcessor(p_config,pProc);
- if(err == OCSD_OK)
- {
m_decode_elements[CSID]->SetDecoderElement(pProc);
err = pProc->setProtocolConfig(p_config);
if(m_i_instr_decode && (err == OCSD_OK))
err = pProc->getInstrDecodeAttachPt()->attach(m_i_instr_decode);
if(m_i_mem_access && (err == OCSD_OK))
err = pProc->getMemoryAccessAttachPt()->attach(m_i_mem_access);
if( m_i_gen_elem_out && (err == OCSD_OK))
err = pProc->getTraceElemOutAttachPt()->attach(m_i_gen_elem_out);
if(err == OCSD_OK)
err = pProc->getErrorLogAttachPt()->attach(DecodeTree::s_i_error_logger);
if(err != OCSD_OK)
destroyDecodeElement(CSID);
- }
- return err;
-}
-ocsd_err_t DecodeTree::createETMv4Decoder(EtmV4Config *p_config, bool bDataChannel /*= false*/) -{
- ocsd_err_t err = OCSD_ERR_NOT_INIT;
- uint8_t CSID = 0; // default for single stream decoder (no deformatter) - we ignore the ID
- if(usingFormatter())
CSID = p_config->getTraceID();
- if(!bDataChannel)
- {
TrcPktDecodeEtmV4I *pProc = 0;
pProc = new (std::nothrow) TrcPktDecodeEtmV4I(CSID);
if(!pProc)
return OCSD_ERR_MEM;
err = createETMv4IPktProcessor(p_config,pProc);
if(err == OCSD_OK)
{
m_decode_elements[CSID]->SetDecoderElement(pProc);
err = pProc->setProtocolConfig(p_config);
if(m_i_instr_decode && (err == OCSD_OK))
err = pProc->getInstrDecodeAttachPt()->attach(m_i_instr_decode);
if(m_i_mem_access && (err == OCSD_OK))
err = pProc->getMemoryAccessAttachPt()->attach(m_i_mem_access);
if( m_i_gen_elem_out && (err == OCSD_OK))
err = pProc->getTraceElemOutAttachPt()->attach(m_i_gen_elem_out);
if(err == OCSD_OK)
err = pProc->getErrorLogAttachPt()->attach(DecodeTree::s_i_error_logger);
if(err != OCSD_OK)
destroyDecodeElement(CSID);
}
- }
- return err;
-}
-ocsd_err_t DecodeTree::createPTMDecoder(PtmConfig *p_config) -{
- ocsd_err_t err = OCSD_ERR_NOT_INIT;
- uint8_t CSID = 0; // default for single stream decoder (no deformatter) - we ignore the ID
- if(usingFormatter())
CSID = p_config->getTraceID();
- TrcPktDecodePtm *pProc = 0;
- pProc = new (std::nothrow) TrcPktDecodePtm(CSID);
- if(!pProc)
return OCSD_ERR_MEM;
- err = createPTMPktProcessor(p_config,pProc);
- if(err == OCSD_OK)
- {
m_decode_elements[CSID]->SetDecoderElement(pProc);
err = pProc->setProtocolConfig(p_config);
if(m_i_instr_decode && (err == OCSD_OK))
err = pProc->getInstrDecodeAttachPt()->attach(m_i_instr_decode);
if(m_i_mem_access && (err == OCSD_OK))
err = pProc->getMemoryAccessAttachPt()->attach(m_i_mem_access);
if( m_i_gen_elem_out && (err == OCSD_OK))
err = pProc->getTraceElemOutAttachPt()->attach(m_i_gen_elem_out);
if(err == OCSD_OK)
err = pProc->getErrorLogAttachPt()->attach(DecodeTree::s_i_error_logger);
if(err != OCSD_OK)
destroyDecodeElement(CSID);
- }
- return err;
-}
ocsd_err_t DecodeTree::createDecoder(const std::string &decoderName, const int createFlags, const CSConfig *pConfig) { ocsd_err_t err = OCSD_OK; @@ -661,11 +263,10 @@ ocsd_err_t DecodeTree::createDecoder(const std::string &decoderName, const int c return err;
// got the decoder...
- err = pDecoderMngr->createDecoder(crtFlags,(int)CSID,pConfig,&pTraceComp);
- if((err = pDecoderMngr->createDecoder(crtFlags,(int)CSID,pConfig,&pTraceComp)) != OCSD_OK)
return err;
- // TBD: set decode element
- // when elements accept new pointer types -> component handle and decoder manager.
- // m_decode_elements[CSID]->SetDecoderElement(pTraceComp, pDecoderMngr);
m_decode_elements[CSID]->SetDecoderElement(decoderName, pDecoderMngr, pTraceComp, true);
// always attach an error logger if(err == OCSD_OK)
@@ -706,13 +307,11 @@ ocsd_err_t DecodeTree::createDecoder(const std::string &decoderName, const int c
if(err != OCSD_OK) {
// TBD: destroyDecodeElement(CSID); // will destroy decoder as well.
} return err;destroyDecodeElement(CSID); // will destroy decoder as well.
}
ocsd_err_t DecodeTree::removeDecoder(const uint8_t CSID) { ocsd_err_t err = OCSD_OK; diff --git a/decoder/tests/snapshot_parser_lib/source/ss_to_dcdtree.cpp b/decoder/tests/snapshot_parser_lib/source/ss_to_dcdtree.cpp index 349f095..9c6c55b 100644 --- a/decoder/tests/snapshot_parser_lib/source/ss_to_dcdtree.cpp +++ b/decoder/tests/snapshot_parser_lib/source/ss_to_dcdtree.cpp @@ -271,31 +271,17 @@ bool CreateDcdTreeFromSnapShot::createETMv4Decoder(const std::string &coreName, { ocsd_err_t err = OCSD_OK; EtmV4Config configObj(&config);
const char *decoderName = bDataChannel ? OCSD_BUILTIN_DCD_ETMV4D : OCSD_BUILTIN_DCD_ETMV4I;
// test new infrastructure
//
err = m_pDecodeTree->createDecoder("ETMV4I", m_bPacketProcOnly ? OCSD_CREATE_FLG_PACKET_PROC : OCSD_CREATE_FLG_FULL_DECODER,&configObj);
if(m_bPacketProcOnly)
{
if(bDataChannel)
err = m_pDecodeTree->createETMv4DPktProcessor(&configObj);
else
err = m_pDecodeTree->createETMv4IPktProcessor(&configObj);
}
else
{
err = m_pDecodeTree->createETMv4Decoder(&configObj,bDataChannel);
}
err = m_pDecodeTree->createDecoder(decoderName, m_bPacketProcOnly ? OCSD_CREATE_FLG_PACKET_PROC : OCSD_CREATE_FLG_FULL_DECODER,&configObj); if(err == OCSD_OK) createdDecoder = true; else
LogError(ocsdError(OCSD_ERR_SEV_ERROR,err,"Snapshot processor : failed to create decoder on decode tree."));
{
std::string msg = "Snapshot processor : failed to create " + (std::string)decoderName + " decoder on decode tree.";
LogError(ocsdError(OCSD_ERR_SEV_ERROR,err,msg));
}
}
return createdDecoder;
@@ -329,15 +315,12 @@ bool CreateDcdTreeFromSnapShot::createETMv3Decoder(const std::string &coreName, { EtmV3Config config(&cfg_regs); ocsd_err_t err = OCSD_OK;
if(m_bPacketProcOnly)
err = m_pDecodeTree->createETMv3PktProcessor(&config);
else
err = m_pDecodeTree->createETMv3Decoder(&config);
err = m_pDecodeTree->createDecoder(OCSD_BUILTIN_DCD_ETMV3, m_bPacketProcOnly ? OCSD_CREATE_FLG_PACKET_PROC : OCSD_CREATE_FLG_FULL_DECODER,&config); if(err == OCSD_OK) createdDecoder = true; else
LogError(ocsdError(OCSD_ERR_SEV_ERROR,err,"Snapshot processor : failed to create decoder on decode tree."));
} return createdDecoder;LogError(ocsdError(OCSD_ERR_SEV_ERROR,err,"Snapshot processor : failed to create ETMV3 decoder on decode tree."));
} @@ -370,15 +353,12 @@ bool CreateDcdTreeFromSnapShot::createPTMDecoder(const std::string &coreName, Pa { PtmConfig configObj(&config); ocsd_err_t err = OCSD_OK;
if(m_bPacketProcOnly)
err = m_pDecodeTree->createPTMPktProcessor(&configObj);
else
err = m_pDecodeTree->createPTMDecoder(&configObj);
err = m_pDecodeTree->createDecoder(OCSD_BUILTIN_DCD_PTM, m_bPacketProcOnly ? OCSD_CREATE_FLG_PACKET_PROC : OCSD_CREATE_FLG_FULL_DECODER,&configObj); if(err == OCSD_OK) createdDecoder = true; else
LogError(ocsdError(OCSD_ERR_SEV_ERROR,err,"Snapshot processor : failed to create decoder on decode tree."));
} return createdDecoder;LogError(ocsdError(OCSD_ERR_SEV_ERROR,err,"Snapshot processor : failed to create PTM decoder on decode tree."));
} @@ -408,7 +388,7 @@ bool CreateDcdTreeFromSnapShot::createSTMDecoder(Parser::Parsed *devSrc)
// generate the config data from the device data.
ocsd_stm_cfg config;
ocsd_stm_cfg config;
regs_to_access_t regs_to_access[] = { { STMRegTCSR, true, &config.reg_tcsr, 0 }
@@ -419,10 +399,8 @@ bool CreateDcdTreeFromSnapShot::createSTMDecoder(Parser::Parsed *devSrc) { ocsd_err_t err = OCSD_OK; STMConfig configObj(&config);
if(m_bPacketProcOnly)
err = m_pDecodeTree->createSTMPktProcessor(&configObj);
else
err = OCSD_ERR_TEST_SS_TO_DECODER;
err = m_pDecodeTree->createDecoder(OCSD_BUILTIN_DCD_STM, m_bPacketProcOnly ? OCSD_CREATE_FLG_PACKET_PROC : OCSD_CREATE_FLG_FULL_DECODER,&configObj); if(err == OCSD_OK) createdDecoder = true;
diff --git a/decoder/tests/source/trc_pkt_lister.cpp b/decoder/tests/source/trc_pkt_lister.cpp index 893bc36..d5ef8be 100644 --- a/decoder/tests/source/trc_pkt_lister.cpp +++ b/decoder/tests/source/trc_pkt_lister.cpp @@ -471,10 +471,10 @@ void AttachPacketPrinters( DecodeTree *dcd_tree, std::vector<ItemPrinter *> &pri { // if we are decoding then the decoder is attached to the packet output - attach the printer to the monitor point. if(decode || pkt_mon)
pElement->getEtmV4IPktProc()->getRawPacketMonAttachPt()->attach(pPrinter);
pElement->getDecoderMngr()->attachPktMonitor(pElement->getDecoderHandle(),(IPktRawDataMon<EtmV4ITrcPacket> *)pPrinter); else {
pElement->getEtmV4IPktProc()->getPacketOutAttachPt()->attach(pPrinter);
pElement->getDecoderMngr()->attachPktSink(pElement->getDecoderHandle(),(IPktDataIn<EtmV4ITrcPacket> *)pPrinter); if(test_waits) pPrinter->setTestWaits(test_waits); }
@@ -494,10 +494,10 @@ void AttachPacketPrinters( DecodeTree *dcd_tree, std::vector<ItemPrinter *> &pri { // if we are decoding then the decoder is attached to the packet output - attach the printer to the monitor point. if(decode || pkt_mon)
pElement->getEtmV3PktProc()->getRawPacketMonAttachPt()->attach(pPrinter);
pElement->getDecoderMngr()->attachPktMonitor(pElement->getDecoderHandle(),(IPktRawDataMon<EtmV3TrcPacket> *)pPrinter); else {
pElement->getEtmV3PktProc()->getPacketOutAttachPt()->attach(pPrinter);
pElement->getDecoderMngr()->attachPktSink(pElement->getDecoderHandle(),(IPktDataIn<EtmV3TrcPacket> *)pPrinter); if(test_waits) pPrinter->setTestWaits(test_waits); }
@@ -516,10 +516,10 @@ void AttachPacketPrinters( DecodeTree *dcd_tree, std::vector<ItemPrinter *> &pri { // if we are decoding then the decoder is attached to the packet output - attach the printer to the monitor point. if(decode || pkt_mon)
pElement->getPtmPktProc()->getRawPacketMonAttachPt()->attach(pPrinter);
pElement->getDecoderMngr()->attachPktMonitor(pElement->getDecoderHandle(),(IPktRawDataMon<PtmTrcPacket> *)pPrinter); else {
pElement->getPtmPktProc()->getPacketOutAttachPt()->attach(pPrinter);
pElement->getDecoderMngr()->attachPktSink(pElement->getDecoderHandle(),(IPktDataIn<PtmTrcPacket> *)pPrinter); if(test_waits) pPrinter->setTestWaits(test_waits); }
@@ -539,10 +539,10 @@ void AttachPacketPrinters( DecodeTree *dcd_tree, std::vector<ItemPrinter *> &pri { // if we are decoding then the decoder is attached to the packet output - attach the printer to the monitor point. if(decode || pkt_mon)
pElement->getStmPktProc()->getRawPacketMonAttachPt()->attach(pPrinter);
pElement->getDecoderMngr()->attachPktMonitor(pElement->getDecoderHandle(),(IPktRawDataMon<StmTrcPacket> *)pPrinter); else {
pElement->getStmPktProc()->getPacketOutAttachPt()->attach(pPrinter);
pElement->getDecoderMngr()->attachPktSink(pElement->getDecoderHandle(),(IPktDataIn<StmTrcPacket> *)pPrinter); if(test_waits) pPrinter->setTestWaits(test_waits); }
-- 2.7.4
CoreSight mailing list CoreSight@lists.linaro.org https://lists.linaro.org/mailman/listinfo/coresight