summaryrefslogtreecommitdiff
path: root/srd.c
AgeCommit message (Collapse)Author
2022-08-21srd: add support for SIGROKDECODE_PATH environment variableGerhard Sittig
The optional SIGROKDECODE_DIR environment variable accepts a single directory specification. The SIGROKDECODE_PATH variable accepts a list of directories to search protocol decoders. The list separator is platform dependent (colon or semicolon). Empty items are explicitly ignored. Both variables get evaluated. Behaviour remains backwards compatible, just gets extended for improved usability.
2022-08-21srd: add TODO comment on the SIGROKDECODE_DIR env var's motivationGerhard Sittig
A comment in the srd.c implementation suggests that the environment variable SIGROKDECODE_DIR would serve debugging purposes and would override other incarnations of available decoders. I disagree with either of these interpretations. Add a TODO comment, the phrase may need an update or rework.
2021-06-16doc: update IRC reference to Libera.ChatGerhard Sittig
2018-10-21Fix memory leak in print_searchpaths()Jon Burgess
==175453== 522 bytes in 8 blocks are definitely lost in loss record 2,923 of 3,201 ==175453== at 0x4C2EBAB: malloc (vg_replace_malloc.c:299) ==175453== by 0x59E9BB5: PyObject_Malloc (in /usr/lib64/libpython3.6m.so.1.0) ==175453== by 0x5A35A76: PyBytes_FromStringAndSize (in /usr/lib64/libpython3.6m.so.1.0) ==175453== by 0x4E3FA6E: print_searchpaths (srd.c:173) ==175453== by 0x4E3FA6E: srd_init (srd.c:287) ==175453== by 0x4034BE: test_session_reset_nodata (session.c:238) ==175453== by 0x53E51D5: srunner_run_tagged (in /usr/lib64/libcheck.so.0.0.0) ==175453== by 0x401237: main (main.c:51)
2018-10-21Fix bad memory accesses during srd_exit()Jon Burgess
When the decoder and session unload functions are called they remove themselves from the list. The code walking the list must be careful to avoid accessing the next pointer which might now be invalid. The g_slist_foreach() takes care of this. Reports from Valgrind before fix: ==175436== Invalid read of size 8 -- ==175436== Address 0xe3f2598 is 8 bytes inside a block of size 16 free'd ==175436== at 0x4C2FDAC: free (vg_replace_malloc.c:530) ==175436== by 0x563C541: g_free (in /usr/lib64/libglib-2.0.so.0.5600.3) ==175436== by 0x5654783: g_slice_free1 (in /usr/lib64/libglib-2.0.so.0.5600.3) ==175436== by 0x56552A2: g_slist_remove (in /usr/lib64/libglib-2.0.so.0.5600.3) ==175436== by 0x4E3FEFF: srd_session_destroy (session.c:343) ==175436== by 0x4E3F5C7: srd_exit (srd.c:311) ==175436== by 0x40336F: test_inst_new (inst.c:40) ==175436== by 0x53E51D5: srunner_run_tagged (in /usr/lib64/libcheck.so.0.0.0) ==175436== by 0x401237: main (main.c:51) ==175436== Block was alloc'd at ==175436== at 0x4C2EBAB: malloc (vg_replace_malloc.c:299) ==175436== by 0x563C435: g_malloc (in /usr/lib64/libglib-2.0.so.0.5600.3) ==175436== by 0x5654056: g_slice_alloc (in /usr/lib64/libglib-2.0.so.0.5600.3) ==175436== by 0x5655797: g_slist_append (in /usr/lib64/libglib-2.0.so.0.5600.3) ==175436== by 0x4E3FC75: srd_session_new (session.c:71) ==175436== by 0x403345: test_inst_new (inst.c:37) ==175436== by 0x53E51D5: srunner_run_tagged (in /usr/lib64/libcheck.so.0.0.0) ==175436== by 0x401237: main (main.c:51)
2018-10-16Update a few Doxygen @since tags.Uwe Hermann
Drop @since tags for non-public functions.
2018-10-06srd.c: Fix a compiler warning with gcc 8.Uwe Hermann
srd.c: In function ‘srd_searchpaths_get’: srd.c:399:40: warning: cast between incompatible function types from ‘gchar * (*)(const gchar *)’ {aka ‘char * (*)(const char *)’} to ‘void * (*)(const void *, void *)’ [-Wcast-function-type] return g_slist_copy_deep(searchpaths, (GCopyFunc)g_strdup, NULL); ^ Upstream glib issue / documentation change: https://gitlab.gnome.org/GNOME/glib/issues/1492 https://gitlab.gnome.org/pwithnall/glib/commit/e81f4c2acea5ada6ae989426e462613f7c612cac
2018-08-30srd_exit(): Fix a -Wcast-function-type compiler warning.Uwe Hermann
srd.c: In function ‘srd_exit’: srd.c:310:28: warning: cast between incompatible function types from ‘int (*)(struct srd_session *)’ to ‘void (*)(void *, void *)’ [-Wcast-function-type] g_slist_foreach(sessions, (GFunc)srd_session_destroy, NULL); ^
2018-05-18Add srd_searchpaths_get() API docs.Uwe Hermann
2018-05-18Random whitespace/cosmetic/consistency fixes.Uwe Hermann
2018-03-18print_searchpaths(): Print decoder and system search paths.Uwe Hermann
2018-03-17Fix part of #1128 by adding a way to retrieve PD search pathsSoeren Apel
As this uses g_slist_copy_deep(), we now require glib 2.34.
2017-09-22srd_init(): Print list of decoder search paths in debug output.Uwe Hermann
2017-07-06Fix a unit test.Uwe Hermann
Only try to acquire the GIL if the Python interpreter is actually initialized, otherwise there'll be a segfault.
2017-06-30Acquire/release the Python GIL where needed to avoid threading issues.Uwe Hermann
With these additions, frontends can now call libsigrokdecode API functions from different threads without running into threading issues. The backend releases the GIL when it is performing tasks that might take a while and it doesn't need to run Python/C API calls during that time. This allows frontends to run multiple PD stacks (in multiple frontend threads) "at the same time" in a time-sharing, "interlocked" manner. Whenever one of the decoders is inside e.g. self.wait() it releases the GIL and thus allows other decoders to do some work in the mean time. The user-visible effect is that for use-cases such as running 3 different decoder stacks at the same time for an acquisition, the user will not have to wait for PD 1 to finish decoding, then wait for PD 2 to finish decoding, and only *then* being able to see annotations from PD 3. Instead, all three PDs will decode some chunks of data from time to time, thus the user is able to inspect annotations from all 3 PDs while the acquisition and decoding is still going on.
2017-05-26Show lib versions in the debug output.Uwe Hermann
2016-12-06valgrind: safely iterate listsKarl Palsson
Old versions triggered valgrind errors as the API method to remove an entry modifies the list that was being iterated. Signed-off-by: Karl Palsson <karlp@etactica.com>
2016-05-25Move common/ directory into decoders/.Uwe Hermann
This simplifies cross-platform handling of the Python/decoder paths and module installation/dist a bit and also fixes bug #804.
2016-05-04Add common directory for shared modules.Bert Vermeulen
2015-12-07init: Don't let Python override signal handlersMarcus Comstedt
This fixes bug #461.
2015-10-03init: Also look for decoders in XDG data directoriesDaniel Elstner
2015-10-03init: Simplify srd_decoder_searchpath_add()Daniel Elstner
Don't mess with colon-separated search path strings -- instead, simply prepend items to the sys.path list object. Also keep the internal decoder path list in the same order as the items added to sys.path.
2015-09-13Build: Include <config.h> first in all source filesDaniel Elstner
Since Autoconf places some important feature flags only into the configuration header, it is necessary to include it globally to guarantee a consistent build.
2015-04-01Use g_malloc*() consistently, simplify error handling.Uwe Hermann
Use g_malloc*() for small allocations and assume they always succeed. Simplify error handling in a few places accordingly. Document the rules in the README file.
2014-07-23Drop references to obsolete sigrok-commits mailing list.Uwe Hermann
2014-07-08Remove dependency on Python.h from public API headerMarcus Comstedt
This prevents Python.h from being included into client code, where it can mess things up by e.g. redefining _POSIX_C_SOURCE.
2014-05-04Mark some variables more consistently as SRD_PRIV.Uwe Hermann
2014-05-03Move srd_check_init() to decoder.c and make it static.Uwe Hermann
The function srd_check_init() is only used in decoder.c.
2014-05-03Make 'pd_list' static, it's only used in one file.Uwe Hermann
2014-05-03srd.c: Fix typo to avoid Doxygen output for srd_check_init().Uwe Hermann
2014-01-30Fix warnings exposed by -Wmissing-prototypes.Uwe Hermann
2013-12-11Load decoders from all search paths, not just the default.Bert Vermeulen
srd_decoder_load_all() was really only getting a list of decoders from the default (installation) path, so could not find uninstalled decoders, or those in a custom added search path. This broke development of new PDs when using the SIGROKDECODE_DIR environment variable, and broke many of the unit tests in the tests/ directory -- those actually tested against the already-installed decoders, not the ones about to be installed.
2013-12-11Clear decoder list after unloading, not just at exit.Bert Vermeulen
2013-11-18Check library initialization before handling decodersBert Vermeulen
2013-11-16Move initialization/shutdown into srd.cBert Vermeulen