Move the custom packet to string function declaration to main C-API header were all the other custom decoder API functions are declared.
Updates to external_custom.md to match latest API types.
Signed-off-by: Mike Leach mike.leach@linaro.org --- decoder/docs/doxygen_config.dox | 2 +- decoder/docs/external_custom.md | 104 +++++++++++++--- decoder/include/c_api/ocsd_c_api_custom.h | 166 +++++++++++++++++++------ decoder/include/c_api/opencsd_c_api.h | 36 +++++- decoder/include/ocsd_if_types.h | 2 +- decoder/source/c_api/ocsd_c_api.cpp | 2 +- decoder/source/c_api/ocsd_c_api_custom_obj.cpp | 6 +- 7 files changed, 255 insertions(+), 63 deletions(-)
diff --git a/decoder/docs/doxygen_config.dox b/decoder/docs/doxygen_config.dox index 7054396..acc6137 100644 --- a/decoder/docs/doxygen_config.dox +++ b/decoder/docs/doxygen_config.dox @@ -38,7 +38,7 @@ PROJECT_NAME = "OpenCSD - CoreSight Trace Decode Library" # could be handy for archiving the generated documentation or if some version # control system is used.
-PROJECT_NUMBER = 0.4 +PROJECT_NUMBER = 0.5
# Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/decoder/docs/external_custom.md b/decoder/docs/external_custom.md index 7efd65d..64e5191 100644 --- a/decoder/docs/external_custom.md +++ b/decoder/docs/external_custom.md @@ -7,7 +7,7 @@ Introduction ------------
An external custom decoder is one which decodes a CoreSight trace byte stream from a source other -than an ARM core which cannot be decoded by the standard builtin decoders within the library. +than an ARM core which cannot be decoded by the standard built-in decoders within the library.
An example of this may be a trace stream from a DSP device.
@@ -16,10 +16,11 @@ same way as the built-in decoders. This means that the external decoder can be c using the decode tree API, and will integrate seamlessly with any ARM processor decoders that are part of the same tree.
-An external decoder will be required to provide two standard structures:- +An external decoder will be required to use three standard structures:-
-- `ocsd_extern_dcd_fact_t` : this is a decoder "factory" that allows the creation of the custom decoders. -- `ocsd_extern_dcd_inst_t` : one of these structures exists for each instance of the custom decoder that is created. +- `ocsd_extern_dcd_fact_t` : This is a decoder "factory" that allows the creation of the custom decoders. +- `ocsd_extern_dcd_inst_t` : This structure provides decoder data to the library for a single decoder instance. +- `ocsd_extern_dcd_cb_fns` : This structure provides a set of callback functions allowing the decoder to use library functionality in the same way as built-in decoders.
These structures consist of data and function pointers to allow integration with the library infrastructure.
@@ -30,7 +31,10 @@ A single API function is provided to allow a decoder to be registered with the l
ocsd_err_t ocsd_register_custom_decoder(const char *name, ocsd_extern_dcd_fact_t *p_dcd_fact);
-This registers the custom decoder with the libary using the supplied name and factory structure. +This registers the custom decoder with the library using the supplied name and factory structure. +As part of the registration function the custom decoder will be assigned a protocol ID which may be used in +API functions requiring this parameter. + Once registered, the standard API functions used with the built-in decoders will work with the custom decoder.
The Factory Structure @@ -51,30 +55,94 @@ The mandatory functions that must be provided include:
-The Decoder Instance Structure ------------------------------- +Creating a Custom Decoder Instance +---------------------------------- + +Once the custom decoder factory has been registered with the library then using the decoder uses the standard creation API:- + +`ocsd_dt_create_decoder(const dcd_tree_handle_t handle, const char *decoder_name, const int create_flags, + const void *decoder_cfg, unsigned char *pCSID)` + + +This creates a decoder by type name in the current decode tree and attaches it to the trace data stream associated with a CoreSight trace ID extracted from +the trace configuration.
-This structure must be filled in by the `fnCreateCustomDecoder` function implmentation. +To create a custom decoder instance simply use the custom name and a pointer to the custom configuration structure.
-There is a single mandatory function in this structure: +Calling this on a custom decoder name will result in a call to the factor function `fnCreateCustomDecoder` function:- +`ocsd_err_t CreateCustomDecoder(const int create_flags, const void *decoder_cfg, const ocsd_extern_dcd_cb_fns *p_lib_callbacks, ocsd_extern_dcd_inst_t *p_decoder_inst)` + +This will first require that the `ocsd_extern_dcd_inst_t` structure is populated. + +There is are two mandatory function calls in this structure that may be called by the library
`fnTraceDataIn` : the decoder must provide this as this is called by the library to provide the raw trace data to the decoder. + + `fn_update_pkt_mon` : Allows the library to communicate when packet sink / packet monitor interfaces are attached to the decoder and in use. + +The decoder creation process will also fill in the additional information to allow the library to correctly call back into the custom decoder using the `decoder_handle` parameter. + +Secondly the library will provide a structure of callback functions - `ocsd_extern_dcd_cb_fns` - that the decoder can use to access standard library functionality. +This includes the standard error and message logging functions, the memory access and ARM instruction decode functions, plus the current output sink for generic +trace elements generated by the decoder. The decoder is not required to use these functions - indeed the ARM instruction decode will not be useful to none ARM +architecture decoders, but should where possible use these functions if being used as part of a combined ARM / custom decoder tree. This will simplify client +use of the external decoders. + +The `create_flags` parameter will describe the expected operational mode for the decoder. The flags are:- +- `OCSD_CREATE_FLG_PACKET_PROC` : Packet processing only - the decoder will split the incoming stream into protocol trace packets and output these. +- `OCSD_CREATE_FLG_FULL_DECODER` : Full decode - the decoder will split the incoming stream into protocol trace packets and further decode and analyse these to produce generic trace output which may describe the program flow. + +Finally the decoder creation function will interpret the custom configuration (`decoder_cfg`) and fill in the CoreSight Trace ID parameter `pCSID` +for this decoder instance. Decoder configuration structures describe registers and parameters used in programming up the trace source. The only +minimum requirement is that it is possible to extract a CoreSight trace ID from the configuration to allow the library to attach the correct byte +stream to the decoder. + + +Example : The echo_test decoder +-------------------------------- + +The echo_test decoder is provided to both test the C-API interfaces provided for using custom decoders and as a worked example for using these interfaces. + +This decoder is initialised and created by the `c_api_pkt_print_test` program when the `-extern` command line option is used. + +In order to use a custom decoder, the header files for that decoder must be included by the client as they are not part of the built-in provided by the standard library includes. + + #include "ext_dcd_echo_test_fact.h" // provides the ext_echo_get_dcd_fact() fn + #include "ext_dcd_echo_test.h" // provides the echo_dcd_cfg_t config structure. + +The `register_extern_decoder()` function in the test shows how simple the API is to use.
-There are a number of optional callback functions. These allow the custom decoder to call into the library -and use the same infrastructure as the builting decoders. The callbacks are registed with the custom decoder -as the libary performs initialisation of connections. +The implementation of the decoder provides an external function to get a factory structure.
-For example, the library will connect the error logging interface to all the decoders. The instance structure -contains the `fnRegisterErrLogCB` function pointer which will register two error logging callbacks with the custom -decoder, `fnLogErrorCB` and `fnLogMsgCB`. These can then be called by the custom decoder, and the errors and -messages will appear in the same place as for the built-in decoders. + p_ext_fact = ext_echo_get_dcd_fact(); + +Assuming this returns a structure then the decoder is registered by name.
-Where a custom decoder does not require or support the optional callbacks, then the registration function is set to -0 in the structure. + if (p_ext_fact) + { + err = ocsd_register_custom_decoder(EXT_DCD_NAME, p_ext_fact); + }
+After this the test uses the same code path as the built in decoders when testing the custom decoder. +The test function `ocsd_err_t create_decoder_extern(dcd_tree_handle_t dcd_tree_h)` is called if the test parameters indicate a custom decoder is needed. +This populates the custom configuration structure specific to the echo_test decoder (`echo_dcd_cfg_t`), then passes this plus the decoder name to the same `create_generic_decoder()` function used when testing the built in decoders.
+ static ocsd_err_t create_decoder_extern(dcd_tree_handle_t dcd_tree_h) + { + echo_dcd_cfg_t trace_cfg_ext;
+ /* setup the custom configuration */ + trace_cfg_ext.cs_id = 0x010; + if (test_trc_id_override != 0) + { + trace_cfg_ext.cs_id = (uint32_t)test_trc_id_override; + }
+ /* create an external decoder - no context needed as we have a single stream to a single handler. */ + return create_generic_decoder(dcd_tree_h, EXT_DCD_NAME, (void *)&trace_cfg_ext, 0); + }
+From the test program perspective, these are the only changes made to the test program to test this decoder. +The `create_generic_decoder()` then uses the normal C-API calls such as `ocsd_dt_create_decoder()` and `ocsd_dt_attach_packet_callback()` to hook the decoder into the decode tree infrastructure. diff --git a/decoder/include/c_api/ocsd_c_api_custom.h b/decoder/include/c_api/ocsd_c_api_custom.h index ea65fd3..ada0a68 100644 --- a/decoder/include/c_api/ocsd_c_api_custom.h +++ b/decoder/include/c_api/ocsd_c_api_custom.h @@ -36,9 +36,29 @@
#include "ocsd_c_api_types.h"
+ + /** @defgroup ocsd_ext_dcd OpenCSD Library : Custom External Decoder C-API + @brief Set of types, structures and interfaces for attaching custom decoders via the C-API + + These types, functions and structures define the required API between a custom external decoder + and the library, which will allow the decoder to interact with the library and use library + resources in the same way as the built-in decoders. + + The external decoder must implement:- + - A set of factory functions that allow the creation and destruction of decoder instances. + - A set of call-in and call-back functions plus data structures allowing interaction with the library. + + @{*/ + + +/**@name External decoder - Input Interfaces +@{*/ + /* Custom decoder C-API interface types. */
-/* Raw trace data input function - a decoder must have one of these */ +/** Raw trace data input function - a decoder must have one of these + Implements ITrcDataIn with the addition of a decoder handle to provide context in the decoder. + */ typedef ocsd_datapath_resp_t (* fnTraceDataIn)( const void *decoder_handle, const ocsd_datapath_op_t op, const ocsd_trc_index_t index, @@ -46,17 +66,57 @@ typedef ocsd_datapath_resp_t (* fnTraceDataIn)( const void *decoder_handle, const uint8_t *pDataBlock, uint32_t *numBytesProcessed);
-/* function to update the in-use flags for the packet sinks - must be implemented in the decoder */ +/** Function to update the in-use flags for the packet sinks + + Defines if the fnPktMonCB or fnPktDataSinkCB callbacks are in use by the library. + If so then it is expected that the decoder should call them when trace protocol packets are generated. + + This function must be implemented in the decoder. + + @param decoder_handle : handle for decoder accessed by this call. + @param flags: Values indicating interfaces in use / not in use. [ OCSD_CUST_DCD_PKT_CB_USE_MON or OCSD_CUST_DCD_PKT_CB_USE_SINK] +*/ typedef void (* fnUpdatePktMonFlags)(const void *decoder_handle, const int flags);
-/* callback function to connect into the generic element output point */ + +/** Flag to indicate the the packet monitor (fnPktMonCB) is in use in the library */ +#define OCSD_CUST_DCD_PKT_CB_USE_MON 0x1 + +/** Flag to indicate the the packet sink (fnPktDataSinkCB) is in use in the library - only if trace packet processing only mode. */ +#define OCSD_CUST_DCD_PKT_CB_USE_SINK 0x2 + +/** Owned by the library instance object, this structure is filled in by the ocsd_extern_dcd_fact_t createDecoder() function. */ +typedef struct _ocsd_extern_dcd_inst { + /* Mandatory decoder call back functions - library initialisation will fail without these. */ + fnTraceDataIn fn_data_in; /**< raw trace data input function to decoder */ + fnUpdatePktMonFlags fn_update_pkt_mon; /**< update the packet monitor / sink usage flags */ + + /* Decoder instance data */ + void *decoder_handle; /**< Instance handle for the decoder - used by library to call the decoder call in functions */ + char *p_decoder_name; /**< type name of the decoder - may be used in logging */ + uint8_t cs_id; /**< Coresight ID for the instance - extracted from the config on creation. */ + +} ocsd_extern_dcd_inst_t; + +/** @}*/ + + +/**@name External decoder - Callback Interfaces +@{*/ + + +/** callback function to connect into the generic element output point + Implements ITrcGenElemIn::TraceElemIn with addition of library context pointer. + */ typedef ocsd_datapath_resp_t (* fnGenElemOpCB)( const void *lib_context, const ocsd_trc_index_t index_sop, const uint8_t trc_chan_id, const ocsd_generic_trace_elem *elem);
-/* callback functions to connect into the library error logging mechanism */ +/** callback functions to connect into the library error logging mechanism + Implements ITraceErrorLog::LogError with addition of library context pointer. +*/ typedef void (* fnLogErrorCB)( const void *lib_context, const ocsd_err_severity_t filter_level, const ocsd_err_t code, @@ -64,12 +124,19 @@ typedef void (* fnLogErrorCB)( const void *lib_context, const uint8_t chan_id, const char *pMsg);
+/** callback functions to connect into the library error logging mechanism + Implements ITraceErrorLog::LogMessage with addition of library context pointer. +*/ typedef void (* fnLogMsgCB)(const void *lib_context, const ocsd_err_severity_t filter_level, const char *msg);
-/* callback function to connect an ARM instruction decoder */ +/** callback function to connect an ARM instruction decoder + Implements IInstrDecode::DecodeInstruction with addition of library context pointer. +*/ typedef ocsd_err_t (* fnDecodeArmInstCB)(const void *lib_context, ocsd_instr_info *instr_info);
-/* callback function to connect the memory accessor interface */ +/** callback function to connect the memory accessor interface + Implements ITargetMemAccess::ReadTargetMemory with addition of library context pointer. +*/ typedef ocsd_err_t (* fnMemAccessCB)(const void *lib_context, const ocsd_vaddr_t address, const uint8_t cs_trace_id, @@ -77,7 +144,9 @@ typedef ocsd_err_t (* fnMemAccessCB)(const void *lib_context, uint32_t *num_bytes, uint8_t *p_buffer);
-/* callback function to connect to the packet monitor interface of the packet processor */ +/** callback function to connect to the packet monitor interface of the packet processor + Implements IPktRawDataMon::RawPacketDataMon <void> with addition of library context pointer. +*/ typedef void (* fnPktMonCB)( const void *lib_context, const ocsd_datapath_op_t op, const ocsd_trc_index_t index_sop, @@ -85,8 +154,11 @@ typedef void (* fnPktMonCB)( const void *lib_context, const uint32_t size, const uint8_t *p_data);
-/* callback function to connect to the packet sink interface, on the main decode - data path - use if decoder created as packet processor only */ +/** callback function to connect to the packet sink interface, on the main decode + data path - use if decoder created as packet processor only + + Implements IPktDataIn::PacketDataIn <void> with addition of library context pointer. +*/ typedef ocsd_datapath_resp_t (* fnPktDataSinkCB)( const void *lib_context, const ocsd_datapath_op_t op, const ocsd_trc_index_t index_sop, @@ -105,34 +177,57 @@ typedef struct _ocsd_extern_dcd_cb_fns { /* CB in use flags. */ int packetCBFlags; /**< Flags to indicate if the packet sink / packet monitor callbacks are in use. ( OCSD_CUST_DCD_PKT_CB_USE_MON / OCSD_CUST_DCD_PKT_CB_USE_SINK) */ /* library context */ - const void *lib_context; /** library context pointer - use in callbacks to allow the library to load the correct context data. */ + const void *lib_context; /**< library context pointer - use in callbacks to allow the library to load the correct context data. */ } ocsd_extern_dcd_cb_fns;
-/** Flag to indicate the the packet monitor is in use in the library */ -#define OCSD_CUST_DCD_PKT_CB_USE_MON 0x1 -/** Flag to indicate the the packet sink is in use in the library */ -#define OCSD_CUST_DCD_PKT_CB_USE_SINK 0x2 +/** @}*/
-/** Owned by the library instance object, this structure is filled in by the ocsd_extern_dcd_fact_t createDecoder() function. */ -typedef struct _ocsd_extern_dcd_inst { - /* Mandatory decoder call back functions - library initialisation will fail without these. */ - fnTraceDataIn fn_data_in; /**< raw trace data input function to decoder */ - fnUpdatePktMonFlags fn_update_pkt_mon; /**< update the packet monitor / sink usage flags */ +/**@name External decoder - Decoder Factory +@{*/
- /* Decoder instance data */ - void *decoder_handle; /**< Instance handle for the decoder - used by library to call the decoder CB functions */ - char *p_decoder_name; /**< type name of the decoder - may be used in logging */ - uint8_t cs_id; /**< Coresight ID for the instance - extracted from the config on creation. */ +/** Function to create a decoder instance
-} ocsd_extern_dcd_inst_t; + Create a decoder instance according to the create_flags parameter and the supplied decoder_cfg structure. + Fill in the p_decoder_inst structure, copy the p_lib_callbacks information for use in the decoder instance. + + Create flags can be: + - OCSD_CREATE_FLG_PACKET_PROC: decoder will split the incoming trace into trace protocol packets and not further decode them. fnPktDataSinkCB likely to be in use. + - OCSD_CREATE_FLG_FULL_DECODER: decoder will split the incoming trace into trace protocol packets and further decode them to recreate program flow or other generic trace output.
-/** function to create a decoder instance - fills in the decoder struct supplied. */ + @param create_flags : Sets the decoder operating mode. + @param *decoder_cfg : Hardware specific configuration for this trace element. + @param *p_lib_callbacks : Library callbacks plus context pointer. + @param *p_decoder_inst : Structure representing the new decoder instance being created. Filled in by create function to contain handle and call-in functions for the library. + + @return ocsd_err_t : Library error code - RCDTL_OK if successful +*/ typedef ocsd_err_t (* fnCreateCustomDecoder)(const int create_flags, const void *decoder_cfg, const ocsd_extern_dcd_cb_fns *p_lib_callbacks, ocsd_extern_dcd_inst_t *p_decoder_inst); -/** Function to destroy a decoder instance - indicated by decoder handle */ + +/** Function to destroy a decoder instance indicated by decoder handle. + + @param decoder_handle : Instance handle for decoder. + + @return ocsd_err_t : Library error code - RCDTL_OK if successful +*/ typedef ocsd_err_t (* fnDestroyCustomDecoder)(const void *decoder_handle); -/** Function to extract the CoreSight Trace ID from the configuration structure */ + +/** Function to extract the CoreSight Trace ID from the configuration structure. + + @param *decoder_cfg : Hardware specific configuration for this trace element. + @parma *p_csid : location to write CoreSight Trace ID value. + + @return ocsd_err_t : Library error code - RCDTL_OK if successful +*/ typedef ocsd_err_t (* fnGetCSIDFromConfig)(const void *decoder_cfg, unsigned char *p_csid); -/** Function to convert a protocol specific trace packet to human readable string */ + +/** Function to convert a protocol specific trace packet to human readable string + + @param *trc_pkt : protocol specific packet structure. + @param *buffer : buffer to fill with string. + @param buflen : length of string buffer. + + @return ocsd_err_t : Library error code - RCDTL_OK if successful +*/ typedef ocsd_err_t (* fnPacketToString)(const void *trc_pkt, char *buffer, const int buflen);
/** set of functions and callbacks to create an extern custom decoder in the library @@ -140,19 +235,18 @@ typedef ocsd_err_t (* fnPacketToString)(const void *trc_pkt, char *buffer, const then decoders of the type can be created on the decode tree. */ typedef struct _ocsd_extern_dcd_fact { - /* mandatory functions */ - fnCreateCustomDecoder createDecoder; /**< [required] Function pointer to create a decoder instance. */ - fnDestroyCustomDecoder destroyDecoder; /**< [required] Function pointer to destroy a decoder instance. */ - fnGetCSIDFromConfig csidFromConfig; /**< [required] Function pointer to extract the CSID from a config structure */ - - /* optional functions */ - fnPacketToString pktToString; /**< [optional] function pointer to print a trace packet in this decoder */ + fnCreateCustomDecoder createDecoder; /**< Function pointer to create a decoder instance. */ + fnDestroyCustomDecoder destroyDecoder; /**< Function pointer to destroy a decoder instance. */ + fnGetCSIDFromConfig csidFromConfig; /**< Function pointer to extract the CSID from a config structure */ + fnPacketToString pktToString; /**< Function pointer to print a trace protocol packet in this decoder */
ocsd_trace_protocol_t protocol_id; /**< protocol ID assigned during registration. */ } ocsd_extern_dcd_fact_t;
+/** @}*/ + +/** @}*/
-ocsd_err_t ocsd_cust_protocol_to_str(const ocsd_trace_protocol_t pkt_protocol, const void *trc_pkt, char *buffer, const int buflen);
#endif // ARM_OCSD_C_API_CUSTOM_H_INCLUDED
diff --git a/decoder/include/c_api/opencsd_c_api.h b/decoder/include/c_api/opencsd_c_api.h index adb3609..798551b 100644 --- a/decoder/include/c_api/opencsd_c_api.h +++ b/decoder/include/c_api/opencsd_c_api.h @@ -386,11 +386,43 @@ OCSD_C_API void ocsd_gen_elem_init(ocsd_generic_trace_elem *p_pkt, const ocsd_ge
/** @}*/
-/** register a custom decoder with the library */ +/** @name Custom Decoder API functions + +@{*/ + +/** Register a custom decoder with the library + + @param *name : Name under which to register the decoder. + @param *p_dcd_fact : Custom decoder factory structure. + + @return ocsd_err_t : Library error code - RCDTL_OK if successful. +*/ OCSD_C_API ocsd_err_t ocsd_register_custom_decoder(const char *name, ocsd_extern_dcd_fact_t *p_dcd_fact); -/** clear all registered decoders - library cleanup */ + +/** Clear all registered decoders - library cleanup + + @return ocsd_err_t : Library error code - RCDTL_OK if successful. +*/ OCSD_C_API ocsd_err_t ocsd_deregister_decoders();
+/** Get a string representation of a custom protocol packet. + + Specific function to extract the packet string for a custom protocol ID only. Custom IDs are allocated to decoder factories + during the ocsd_register_custom_decoder() process. + + This function is called by ocsd_pkt_str() when the incoming protocol is a custom ID. + + @param pkt_protocol : Packet protocol type - must be in the custom ID range ( >= OCSD_PROTOCOL_CUSTOM_0, < OCSD_PROTOCOL_END) + @param *p_pkt : pointer to a valid packet structure of protocol type. cast to void *. + @param *buffer : character buffer for string. + @param buffer_size : size of character buffer. + + @return ocsd_err_t : Library error code - RCDTL_OK if successful, OCSD_ERR_NO_PROTOCOL if input ID not in custom range or not in use. +*/ +OCSD_C_API ocsd_err_t ocsd_cust_protocol_to_str(const ocsd_trace_protocol_t pkt_protocol, const void *trc_pkt, char *buffer, const int buflen); + +/** @}*/ +
/** @}*/
diff --git a/decoder/include/ocsd_if_types.h b/decoder/include/ocsd_if_types.h index 15425e1..14056e6 100644 --- a/decoder/include/ocsd_if_types.h +++ b/decoder/include/ocsd_if_types.h @@ -539,7 +539,7 @@ typedef enum _ocsd_trace_protocol_t { #define OCSD_PROTOCOL_IS_BUILTIN(P) ((P > OCSD_PROTOCOL_UNKNOWN) && (P < OCSD_PROTOCOL_BUILTIN_END))
/** Test if protocol type is a custom external registered decoder */ -#define OCSD_PROTOCOL_IS_CUSTOM(P) ((P > OCSD_PROTOCOL_CUSTOM_0) && (P < OCSD_PROTOCOL_END )) +#define OCSD_PROTOCOL_IS_CUSTOM(P) ((P >= OCSD_PROTOCOL_CUSTOM_0) && (P < OCSD_PROTOCOL_END ))
/** @}*/
diff --git a/decoder/source/c_api/ocsd_c_api.cpp b/decoder/source/c_api/ocsd_c_api.cpp index e38167f..5738798 100644 --- a/decoder/source/c_api/ocsd_c_api.cpp +++ b/decoder/source/c_api/ocsd_c_api.cpp @@ -309,7 +309,7 @@ OCSD_C_API ocsd_err_t ocsd_pkt_str(const ocsd_trace_protocol_t pkt_protocol, con break;
default: - if ((pkt_protocol >= OCSD_PROTOCOL_CUSTOM_0) && (pkt_protocol < OCSD_PROTOCOL_END)) + if (OCSD_PROTOCOL_IS_CUSTOM(pkt_protocol)) err = ocsd_cust_protocol_to_str(pkt_protocol, p_pkt, buffer, buffer_size); else err = OCSD_ERR_NO_PROTOCOL; diff --git a/decoder/source/c_api/ocsd_c_api_custom_obj.cpp b/decoder/source/c_api/ocsd_c_api_custom_obj.cpp index 64f1f24..f06e1c0 100644 --- a/decoder/source/c_api/ocsd_c_api_custom_obj.cpp +++ b/decoder/source/c_api/ocsd_c_api_custom_obj.cpp @@ -88,13 +88,11 @@ OCSD_C_API ocsd_err_t ocsd_deregister_decoders() return OCSD_OK; }
- - -ocsd_err_t ocsd_cust_protocol_to_str(const ocsd_trace_protocol_t pkt_protocol, const void *trc_pkt, char *buffer, const int buflen) +OCSD_C_API ocsd_err_t ocsd_cust_protocol_to_str(const ocsd_trace_protocol_t pkt_protocol, const void *trc_pkt, char *buffer, const int buflen) { OcsdLibDcdRegister *pRegister = OcsdLibDcdRegister::getDecoderRegister(); IDecoderMngr *p_mngr = 0; - if (pRegister->getDecoderMngrByType(pkt_protocol, &p_mngr) == OCSD_OK) + if (OCSD_PROTOCOL_IS_CUSTOM(pkt_protocol) && (pRegister->getDecoderMngrByType(pkt_protocol, &p_mngr) == OCSD_OK)) { CustomDcdMngrWrapper *pWrapper = static_cast<CustomDcdMngrWrapper *>(p_mngr); pWrapper->pktToString(trc_pkt, buffer, buflen);