static IsoString GetDemangledFunctionName( const char* symbol, IsoString& addrStr ) { IsoString symbolStr( symbol ); addrStr.Clear(); // Get mangled function name. Example: // /opt/PixInsight/bin/lib/libQtGui.so.4(_ZN7QWidget5eventEP6QEvent+0x411) [0x7fa271347811] StringList tokens; symbolStr.Break( tokens, '(' , true/*trim*/ ); if ( tokens.Length() != 2 ) return symbolStr; // Take second token and split again. StringList tokens2; tokens[1].Break( tokens2, '+' , true/*trim*/ ); if ( tokens2.Length() != 2 ) return symbolStr; // If there is no function name, do not set the addr string. if ( !tokens2[0].IsEmpty() ) { addrStr = tokens2[1]; addrStr.DeleteChar( '(' ); addrStr.DeleteChar( ')' ); } // The first token of tokens2 contains the mangled string. Demangle it. size_t funcnameSize = 256; char funcname[ funcnameSize ]; int status; IsoString token( tokens2[0] ); const char* demangledFuncname = abi::__cxa_demangle( token.c_str(), funcname, &funcnameSize, &status ); return (status == 0) ? IsoString( demangledFuncname ) : symbolStr; }
void ZBarFilterImpl::busMessage (GstMessage *message) { if (GST_MESSAGE_SRC (message) == GST_OBJECT (zbar) && GST_MESSAGE_TYPE (message) == GST_MESSAGE_ELEMENT) { const GstStructure *st; guint64 ts; gchar *type, *symbol; st = gst_message_get_structure (message); if (g_strcmp0 (gst_structure_get_name (st), "barcode") != 0) { return; } if (!gst_structure_get (st, "timestamp", G_TYPE_UINT64, &ts, "type", G_TYPE_STRING, &type, "symbol", G_TYPE_STRING, &symbol, NULL) ) { return; } std::string symbolStr (symbol); std::string typeStr (type); g_free (type); g_free (symbol); barcodeDetected (ts, typeStr, symbolStr); } }
void zbar_receive_message (GstBus *bus, GstMessage *message, gpointer zbar) { ZBarFilter *filter = (ZBarFilter *) zbar; if (GST_MESSAGE_SRC (message) == GST_OBJECT (filter->zbar) && GST_MESSAGE_TYPE (message) == GST_MESSAGE_ELEMENT) { const GstStructure *st; guint64 ts; gchar *type, *symbol; st = gst_message_get_structure (message); if (g_strcmp0 (gst_structure_get_name (st), "barcode") != 0) return; if (!gst_structure_get (st, "timestamp", G_TYPE_UINT64, &ts, "type", G_TYPE_STRING, &type, "symbol", G_TYPE_STRING, &symbol, NULL) ) return; std::string symbolStr (symbol); std::string typeStr (type); g_free (type); g_free (symbol); filter->barcodeDetected (ts, typeStr, symbolStr); } }