Added create by name API to decode tree class. Update error printer to handle added error codes.
Signed-off-by: Mike Leach mike.leach@linaro.org --- decoder/include/common/ocsd_dcd_tree.h | 3 + decoder/source/etmv3/trc_pkt_proc_etmv3.cpp | 2 +- decoder/source/etmv4/trc_cmp_cfg_etmv4.cpp | 6 ++ decoder/source/ocsd_dcd_tree.cpp | 80 ++++++++++++++++++++++ decoder/source/ocsd_error.cpp | 6 ++ .../snapshot_parser_lib/source/ss_to_dcdtree.cpp | 10 ++- 6 files changed, 105 insertions(+), 2 deletions(-)
diff --git a/decoder/include/common/ocsd_dcd_tree.h b/decoder/include/common/ocsd_dcd_tree.h index 843a7b5..77b69bf 100644 --- a/decoder/include/common/ocsd_dcd_tree.h +++ b/decoder/include/common/ocsd_dcd_tree.h @@ -116,6 +116,9 @@ public: 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);
diff --git a/decoder/source/etmv3/trc_pkt_proc_etmv3.cpp b/decoder/source/etmv3/trc_pkt_proc_etmv3.cpp index 9f79c60..e7465b3 100644 --- a/decoder/source/etmv3/trc_pkt_proc_etmv3.cpp +++ b/decoder/source/etmv3/trc_pkt_proc_etmv3.cpp @@ -41,7 +41,7 @@ // G++ doesn't like the ## pasting #define ETMV3_PKTS_NAME "PKTP_ETMV3" #else -#define ETMV3_PKTS_NAME OCSD_CMPNAME_PREFIX_PKTPROC##"_ETMV3" +#define ETMV3_PKTS_NAME OCSD_CMPNAME_PREFIX_PKTPROC##"_"##OCSD_BUILTIN_DCD_ETMV3 #endif
static const uint32_t ETMV3_SUPPORTED_OP_FLAGS = OCSD_OPFLG_PKTPROC_COMMON | diff --git a/decoder/source/etmv4/trc_cmp_cfg_etmv4.cpp b/decoder/source/etmv4/trc_cmp_cfg_etmv4.cpp index 5703406..1b90b17 100644 --- a/decoder/source/etmv4/trc_cmp_cfg_etmv4.cpp +++ b/decoder/source/etmv4/trc_cmp_cfg_etmv4.cpp @@ -53,6 +53,12 @@ EtmV4Config::EtmV4Config() PrivateInit(); }
+EtmV4Config::EtmV4Config(const ocsd_etmv4_cfg *cfg_regs) +{ + m_cfg = *cfg_regs; + PrivateInit(); +} + EtmV4Config & EtmV4Config::operator=(const ocsd_etmv4_cfg *p_cfg) { m_cfg = *p_cfg; diff --git a/decoder/source/ocsd_dcd_tree.cpp b/decoder/source/ocsd_dcd_tree.cpp index 8f14af1..c6c0a04 100644 --- a/decoder/source/ocsd_dcd_tree.cpp +++ b/decoder/source/ocsd_dcd_tree.cpp @@ -34,6 +34,7 @@ */
#include "common/ocsd_dcd_tree.h" +#include "common/ocsd_lib_dcd_register.h" #include "mem_acc/trc_mem_acc_mapper.h"
@@ -632,6 +633,85 @@ ocsd_err_t DecodeTree::createPTMDecoder(PtmConfig *p_config) return err; }
+ocsd_err_t DecodeTree::createDecoder(const std::string &decoderName, const int createFlags, const CSConfig *pConfig) +{ + ocsd_err_t err = OCSD_OK; + IDecoderMngr *pDecoderMngr = 0; + TraceComponent *pTraceComp = 0; + int crtFlags = createFlags; + + uint8_t CSID = 0; // default for single stream decoder (no deformatter) - we ignore the ID + if(usingFormatter()) + { + CSID = pConfig->getTraceID(); + crtFlags |= OCSD_CREATE_FLG_INST_ID; + } + + // create the decode element to attach to the channel. + if((err = createDecodeElement(CSID)) != OCSD_OK) + return err; + + // get the libary decoder register. + OcsdLibDcdRegister * lib_reg = OcsdLibDcdRegister::getDecoderRegister(); + if(lib_reg == 0) + return OCSD_ERR_NOT_INIT; + + // find the named decoder + if((err = lib_reg->getDecoderMngrByName(decoderName,&pDecoderMngr)) != OCSD_OK) + return err; + + // got the decoder... + err = pDecoderMngr->createDecoder(crtFlags,(int)CSID,pConfig,&pTraceComp); + + // TBD: set decode element + // when elements accept new pointer types -> component handle and decoder manager. + // m_decode_elements[CSID]->SetDecoderElement(pTraceComp, pDecoderMngr); + + // always attach an error logger + if(err == OCSD_OK) + err = pDecoderMngr->attachErrorLogger(pTraceComp,DecodeTree::s_i_error_logger); + + // if we created a packet decoder it may need additional components. + if(crtFlags & OCSD_CREATE_FLG_FULL_DECODER) + { + if(m_i_instr_decode && (err == OCSD_OK)) + err = pDecoderMngr->attachInstrDecoder(pTraceComp,m_i_instr_decode); + + if(err == OCSD_ERR_DCD_INTERFACE_UNUSED) // ignore if instruction decoder refused + err = OCSD_OK; + + if(m_i_mem_access && (err == OCSD_OK)) + err = pDecoderMngr->attachMemAccessor(pTraceComp,m_i_mem_access); + + if(err == OCSD_ERR_DCD_INTERFACE_UNUSED) // ignore if mem accessor refused + err = OCSD_OK; + + if( m_i_gen_elem_out && (err == OCSD_OK)) + err = pDecoderMngr->attachOutputSink(pTraceComp,m_i_gen_elem_out); + } + + // finally attach the packet processor input to the demux output channel + if(err == OCSD_OK) + { + ITrcDataIn *pDataIn = 0; + if((err = pDecoderMngr->getDataInputI(pTraceComp,&pDataIn)) == OCSD_OK) + { + // got the interface -> attach to demux, or direct to input of decode tree + if(usingFormatter()) + err = m_frame_deformatter_root->getIDStreamAttachPt(CSID)->attach(pDataIn); + else + m_i_decoder_root = pDataIn; + } + } + + if(err != OCSD_OK) + { + // TBD: destroyDecodeElement(CSID); // will destroy decoder as well. + } + return err; +} + +
ocsd_err_t DecodeTree::removeDecoder(const uint8_t CSID) { diff --git a/decoder/source/ocsd_error.cpp b/decoder/source/ocsd_error.cpp index a94b7b2..ca55c20 100644 --- a/decoder/source/ocsd_error.cpp +++ b/decoder/source/ocsd_error.cpp @@ -46,6 +46,7 @@ static const char *s_errorCodeDescs[][2] = { {"OCSD_ERR_INVALID_ID","Invalid CoreSight Trace Source ID."}, {"OCSD_ERR_BAD_HANDLE","Invalid handle passed to component."}, {"OCSD_ERR_INVALID_PARAM_VAL","Invalid value parameter passed to component."}, + {"OCSD_ERR_INVALID_PARAM_TYPE","Type mismatch on abstract interface."}, {"OCSD_ERR_FILE_ERROR","File access error"}, {"OCSD_ERR_NO_PROTOCOL","Trace protocol unsupported"}, /* attachment point errors */ @@ -83,6 +84,11 @@ static const char *s_errorCodeDescs[][2] = { {"OCSD_ERR_TEST_SNAPSHOT_PARSE_INFO", "Test snapshot file parse information"}, {"OCSD_ERR_TEST_SNAPSHOT_READ","test snapshot reader error"}, {"OCSD_ERR_TEST_SS_TO_DECODER","test snapshot to decode tree conversion error"}, + /* decoder registration */ + {"OCSD_ERR_DCDREG_NAME_REPEAT","Attempted to register a decoder with the same name as another one."}, + {"OCSD_ERR_DCDREG_NAME_UNKNOWN","Attempted to find a decoder with a name that is not known in the library."}, + /* decoder config */ + {"OCSD_ERR_DCD_INTERFACE_UNUSED","Attempt to connect or use and inteface not supported by this decoder."}, /* end marker*/ {"OCSD_ERR_LAST", "No error - error code end marker"} }; 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 0a31edd..349f095 100644 --- a/decoder/tests/snapshot_parser_lib/source/ss_to_dcdtree.cpp +++ b/decoder/tests/snapshot_parser_lib/source/ss_to_dcdtree.cpp @@ -272,6 +272,13 @@ bool CreateDcdTreeFromSnapShot::createETMv4Decoder(const std::string &coreName, ocsd_err_t err = OCSD_OK; EtmV4Config configObj(&config);
+ + // 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) @@ -283,6 +290,8 @@ bool CreateDcdTreeFromSnapShot::createETMv4Decoder(const std::string &coreName, { err = m_pDecodeTree->createETMv4Decoder(&configObj,bDataChannel); } + + if(err == OCSD_OK) createdDecoder = true; else @@ -372,7 +381,6 @@ bool CreateDcdTreeFromSnapShot::createPTMDecoder(const std::string &coreName, Pa LogError(ocsdError(OCSD_ERR_SEV_ERROR,err,"Snapshot processor : failed to create decoder on decode tree.")); } return createdDecoder; - }
bool CreateDcdTreeFromSnapShot::createSTDecoder(Parser::Parsed *devSrc)