Jon Burgess [Sun, 14 Oct 2018 18:10:16 +0000 (19:10 +0100)]
Fix memory leak in decoder test code
==187724== 917 bytes in 1 blocks are definitely lost in loss record 3,046 of 3,207
==187724== at 0x4C2EBAB: malloc (vg_replace_malloc.c:299)
==187724== by 0x563C435: g_malloc (in /usr/lib64/libglib-2.0.so.0.5600.3)
==187724== by 0x5655D82: g_strdup (in /usr/lib64/libglib-2.0.so.0.5600.3)
==187724== by 0x4E43937: py_str_as_str (util.c:371)
==187724== by 0x4E415E1: srd_decoder_doc_get (decoder.c:892)
==187724== by 0x40281D: test_doc_get (decoder.c:395)
==187724== by 0x53E51D5: srunner_run_tagged (in /usr/lib64/libcheck.so.0.0.0)
==187724== by 0x401237: main (main.c:51)
Jon Burgess [Sun, 14 Oct 2018 17:55:47 +0000 (18:55 +0100)]
Fix memory leak in print_searchpaths()
==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)
Jon Burgess [Sun, 14 Oct 2018 17:49:52 +0000 (18:49 +0100)]
Fix bad memory accesses during srd_exit()
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)
Gerhard Sittig [Sun, 14 Oct 2018 18:17:35 +0000 (20:17 +0200)]
uart: add support for break condition detection
There are the "traffic inspecting" wait() conditions, which check an
edge to find the start of START, then wait for sample points to grab the
bit values. Bit times are sampled in their respective center, potential
glitches around sample points get ignored.
Add another independent set of wait() conditions which check _all_ edges
regardless of any data communication. This results in the most reliable
and maintainable detection of break conditions, regardless of how they
align to data frames. Break is defined as a period of low input signal
which spans at least one frame's length. Run the edge inspection after
data inspection, which results in the most appropriate annotation output
like leading data bits (of incomplete frames), frame errors (violated
STOP bit expectations), then break conditions. This approach is most
robust in the presence of incomplete input streams.
usb_power_delivery: better PD 3.0 support and other changes
- better PD 3.0 support
- display PD revision in output
- different flags for source and sink PDO's and RDO's
[Note: This commit is the remaining set of manually merged changes of the
recent commits from Peetz0r <redacted> and the
improvements from davidanger <redacted> over at
https://github.com/davidanger/libsigrokdecode]
Uwe Hermann [Thu, 30 Aug 2018 18:46:43 +0000 (20:46 +0200)]
srd_exit(): Fix a -Wcast-function-type compiler warning.
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);
^
Uwe Hermann [Thu, 30 Aug 2018 18:42:05 +0000 (20:42 +0200)]
srd_decoder_unload_all(): Fix a -Wcast-function-type compiler warning.
decoder.c: In function ‘srd_decoder_unload_all’:
decoder.c:1080:27: warning: cast between incompatible function types from ‘int (*)(struct srd_decoder *)’ to ‘void (*)(void *, void *)’ [-Wcast-function-type]
g_slist_foreach(pd_list, (GFunc)srd_decoder_unload, NULL);
^
Gerhard Sittig [Wed, 15 Aug 2018 21:09:11 +0000 (23:09 +0200)]
log: add a public srd_log_callback_get() API routine
Allow applications to query the currently registered log callback. So
they can either restore the previously registered routine, or register
another routine _and_ log to the previously registered routine as well.
Josef Gajdusek [Fri, 17 Aug 2018 14:35:50 +0000 (16:35 +0200)]
spi: Create the out_bitrate annotation unconditionally
The start() method is called before the metadata() method, which results in the
the out_bitrate instance variable never getting created and ending up as an
AttributeError when decoding.
(observed with sigrok-cli and VCD file as the input)
Stefan Brüns [Sat, 25 Aug 2018 18:19:21 +0000 (20:19 +0200)]
edid: Add support for extension blocks, cleanups
Extension blocks are widely used by e.g. HDMI to signal support for
audio, colorspaces and much more.
Cleanups:
- support short forms for annotations
- join overlapping annotations, these were unreadable in PV, and the
positions were inaccurate (aligned to bytes instead of bits, no
notion of used bits in split fields).
Gerhard Sittig [Sat, 25 Aug 2018 13:20:10 +0000 (15:20 +0200)]
install: unbreak installation with Python 3.7 (os.errno)
The os.errno module has not been an official feature. Python 3.7
removed the corresponding import. This broke the installation of
decoders. Prefer 'errno' over 'os.errno'.
Gerhard Sittig [Wed, 1 Aug 2018 16:35:57 +0000 (18:35 +0200)]
mdio: accept MDIO READ without previous ADDRESS command
Fix a Python string formatting issue, where the format string disagreed
with the argument list. A READ command could unexpectedly terminate the
decoder instance when there was no previous ADDRESS command.
Gerhard Sittig [Sun, 1 Jul 2018 13:30:30 +0000 (15:30 +0200)]
uart: rephrase data bits to data value conversion
Use the already available .databits[] information which holds sample data
and bit time edge positions, and the common bitpack() routine. This shall
increase readability of the bits to value conversion.
[ best viewed with more context, like 'git diff -U5' ]
Gerhard Sittig [Sun, 27 May 2018 07:56:49 +0000 (09:56 +0200)]
counter: emit wider annotations for data and word counts
Track the start of a data or word cycle. Avoid narrow ss=es annotations
which may be tedious to inspect by users in GUI applications. This
resolves the issue initially reported in bug #1210.
Gerhard Sittig [Sun, 27 May 2018 07:46:01 +0000 (09:46 +0200)]
counter: prepare for variable width annotations
Explicitly pass a start sample number to the .putc() method, to prepare
annotations where ss differs from es. This is motivated by bug #1210.
Stick with the narrow ss=es annotations for backwards compatibility.
Gerhard Sittig [Sun, 27 May 2018 07:35:25 +0000 (09:35 +0200)]
counter: use local variables instead of instance variables
Since values get accessed within the .decode() method exclusively, we need
not store data in instance variables of the decoder object. Use another
variable for the "reset edge" option as well for consistency.
Gerhard Sittig [Sun, 27 May 2018 07:27:08 +0000 (09:27 +0200)]
counter: move some init code to the start of decode()
Since PD API v3 the .decode() method is called exactly once, and
contains a main loop itself. Move initialization code that sets up
.decode() related logic to the start of the .decode() routine.
Gerhard Sittig [Sun, 27 May 2018 07:06:48 +0000 (09:06 +0200)]
counter: explicit option text to .wait() edge mapping
The previous implementation used the fact that libsigrok's internal API
happens to use the first letter of the user visible English option text.
Two locations mapped edge choices to API literals in different ways.
Unify them, introduce an explicit option text to literal value mapping.
(Many if not all decoder implementations do that. More adjustment to use
common code could be beneficial.)