Commit Graph

1501 Commits

Author SHA1 Message Date
Soeren Apel 7f894d958e Fix #1132 by passing segment IDs, not segment instances
Passing segment instances fails because this creates a race condition.
When a long conversion is taking place, the SignalBase::samples_added
signal is called often but since it's in a separate thread, the calls
are queued and aren't executed immediately. Now if the conversion is
restarted - for example as a result of a changed conversion threshold -
then the segments holding the converted data are destroyed, rendering
the pointers submitted as parameters to samples_added invalid.

Once the signal queue is processed, those invalid pointers will be
accessed and PV segfaults.

Since the signal queue can neither be emptied nor flushed, this
leaves only two sensible choices:
1) Signal samples_added less often, thereby reducing the chance of
signals being queued
2) Supply the segment ID instead of the segment instance as that's
essentially the only thing we currently care about - in fact, the
only user of samples_added (ViewBase::on_samples_added) uses the
instance to query only this

As #1 is only a band-aid and not a waterproof solution, I chose
to go with #2.
2018-03-05 23:45:46 +01:00
Soeren Apel a66e286e02 Session: Fix trigger handling 2018-03-04 00:25:07 +01:00
Soeren Apel 4d48a00b1a GlobalSettings: Remove unneeded include/using 2018-02-24 00:18:27 +01:00
Soeren Apel feeb4a7ea1 Session: Add error messages 2018-02-24 00:13:13 +01:00
Soeren Apel 0fb98cf80d Tiny whitespace fix 2018-02-21 18:46:29 +01:00
Soeren Apel 7b7ab1f5cb Fix #1038 by catching invalid cursor ranges 2018-02-10 23:18:33 +01:00
Uwe Hermann 7671200bd7 MinGW: Fix a compile error due to a missing #include.
In file included from [...]/pv/globalsettings.cpp:20:0:
  [...]/pv/globalsettings.hpp:31:12: error: 'std::function' has not been declared
   using std::function;
              ^
  test/CMakeFiles/pulseview-test.dir/build.make:88: recipe for target 'test/CMakeFiles/pulseview-test.dir/__/pv/globalsettings.cpp.obj' failed
  make[2]: *** [test/CMakeFiles/pulseview-test.dir/__/pv/globalsettings.cpp.obj] Error 1
  make[2]: *** Waiting for unfinished jobs....
  [  5%] Building CXX object CMakeFiles/pulseview.dir/pv/globalsettings.cpp.obj
  In file included from [...]/pv/globalsettings.cpp:20:0:
  [...]/pv/globalsettings.hpp:31:12: error: 'std::function' has not been declared
   using std::function;
              ^

Add #include <functional> everywhere where std::function is used. Only
the occurence in globalsettings.hpp was causing an actual build failure
on MinGW, though.
2018-02-10 22:10:10 +01:00
Martin Errenst 57c04e781e fix PulseView compilation with ENABLE_DECODE set to OFF 2018-02-10 21:09:00 +01:00
Gerhard Sittig ca1d6d5f46 MainBar: fixup file extension filter in "Import File" dialog
The previous implementation used a "*" filter when a file of any other
format than srzip got imported. This happened to be a duplicate of
"All files", and ignored the list of filename extensions provided by
the input formats.

This change does respect the input format's file extensions, and copes
with the lack of such a list (raw binary), as well as lists that have
one (most formats), or multiple extensions (raw analog).

This fixes bug #1039.

Another byproduct of the change is that extensions and their decoration
(separators, parentheses) move outside of tr() calls. These technical
details shall not concern translators, and translations for human
languages shall not break the filter mechanism.

This implementation might be "too complex, computationally expensive".
But it works, and fixes an issue, and the code path executes seldom and
waits for user interaction anyway. Cost reduction can get applied later.
2018-02-10 20:35:32 +01:00
Soeren Apel b5d20c6d00 Fix #1089 by updating the signal labels and group labels
Group names currently don't change, so this doesn't do much
but they may change in the future, so it's useful to do anyway.
2018-02-08 16:32:19 +01:00
Cenkron 5408524db0 Ruler tick legends don't partly disappear when scrolled off the ends 2018-02-08 10:47:28 +01:00
Soeren Apel d0c0573b3e Rework the callback mechanism for the global settings
Up to now, registered callbacks could not be unregistered
because std::function does not permit comparing for equality.

Using an interface class removes the need for std::function,
making the mechanism a little less elegant but at least fully
functional.
2018-02-07 19:41:56 +01:00
Soeren Apel 451dc5f33f View: Fully integrate the "zero trigger time" setting 2018-02-07 19:41:56 +01:00
Soeren Apel 7ea2a4ff07 Session/View: Save triggers in a list and use it 2018-02-07 19:41:56 +01:00
Soeren Apel 056f443e2a Session: Clean up header a little 2018-02-07 19:41:56 +01:00
Cenkron 4a07615736 Change the number of minor ticks to be either 4 or 5
Depends on the current tick interval size, in the sense of the 1, 2, 5
sequence. It was originally always 4.
2018-02-07 19:41:56 +01:00
Cenkron ffc00fdd59 Provide a settings checkbox for showing zero at the trigger 2018-02-07 19:41:51 +01:00
Gerhard Sittig 4349dc21e7 DecodeSignal: only pass non-zero sample rate to decoders
As reported in bug #1118 not all input sources provide a samplerate, and
decoder instances may not cope with a rate spec of 0. Only pass non-zero
sample rates to the decoder stack. This improves robustness in addition
to the specific fix for #1118 in the decoders' implementations.
2018-01-28 21:58:16 +01:00
Gerhard Sittig 1d6e35dcef main: introduce -D cmdline option, don't auto-scan for devices
Add a -D command line option which skips auto-detection of devices upon
startup. This can speedup program startup for setups with known devices,
and allows to skip the scan for troubled drivers which might break the
startup phase.

This -D option can be combined with -d specs, either presence or absence
of -d is acceptable when -D is specified. Users still can interactively
scan for and use devices after program startup.

This resolves bug #1116.
2018-01-26 17:35:31 +01:00
Gerhard Sittig c5f9553c0b DecodeSignal: Void a session pointer after destroy() call
Fixup an error path when starting a created decoder session fails.
2018-01-11 21:42:45 +01:00
Soeren Apel 89914a8657 Add segment display mode UI controls and some related changes 2018-01-10 00:40:44 +01:00
Soeren Apel 9009d9b5ca Session: Make get_segment_count() consider all segments
Also changes the type for the getters to uint32_t.
2018-01-10 00:34:39 +01:00
Soeren Apel 8c33974131 Supply the segment ID when adding samples to optimize trace painting
Use case is as follows:
- Capture 20+ segments with ~500kS each
- Afterwards, enable conversion for a channel

Without this change, the converted logic will be repainted
20++ times because we are only told that new samples were
added but not which segment.

With this change, the logic trace is only painted when we
see that samples were added to the segment we're showing.
2018-01-10 00:34:39 +01:00
Soeren Apel 85a702806a Add segment_id to all segment classes 2018-01-10 00:34:39 +01:00
Soeren Apel 4d08da71e2 LogicSegment: Don't use new/delete in get_unpacked_sample() 2018-01-10 00:34:39 +01:00
Soeren Apel 4cc0df94c1 LogicSegment: Limit end in get_subsampled_edges() if needed
This is necessary because there is a race condition between
adding samples and trace repainting.
2018-01-10 00:34:38 +01:00
Soeren Apel 2b3dda54bb SignalBase: Don't terminate conversion when there's no data
Instead of terminating, we wait instead.
We do this because SignalBase::on_samples_added() somehow doesn't
reliably see that there's no conversion thread active anymore.
conversion_thread_.joinable() returns true when the thread was
already terminated for whatever reason, resulting in on_samples_added()
trying to notify a non-existant thread.
2018-01-10 00:33:54 +01:00
Soeren Apel 558ad6ceb9 Implement Trace::ShowLastCompleteSegmentOnly display mode 2018-01-05 22:50:35 +01:00
Soeren Apel 65efd0258b DecodeSignal: Restructure metadata handling
Instead of handling the metadata separately from the mux/decode segments,
it's much neater to handle both together. Doing this also allows us to
remove the need for query_input_metadata() since we're taking the metadata
from the muxed logic segments.
2018-01-05 22:50:31 +01:00
Soeren Apel 63253d7271 SignalBase: Implement multi-segment conversion 2018-01-05 22:50:26 +01:00
Soeren Apel 8a603e135f Finalize segment decoding 2018-01-05 22:50:21 +01:00
Soeren Apel 3734c4645f View: Fixes related to multi-segment display 2018-01-05 22:49:17 +01:00
Soeren Apel ed535cd705 DecodeSignal: Mux all segments 2018-01-05 22:48:45 +01:00
Soeren Apel 72435789a0 Prepare multi-segment protocol decoding ability 2017-12-27 18:40:19 +01:00
Soeren Apel ba5f21864c DecodeSignal: Allow muxed logic data to be cached 2017-12-27 18:40:19 +01:00
Soeren Apel f2f4845f15 DecodeSignal: Rename some items 2017-12-27 18:40:19 +01:00
Soeren Apel 5ecf957f9f Begin PD multisegment support 2017-12-27 18:40:19 +01:00
Soeren Apel 2749b858a7 Move current_segment_ to Trace 2017-12-27 18:40:19 +01:00
Soeren Apel 341d9a7975 Flesh out segment display mode handling 2017-12-27 18:40:19 +01:00
Soeren Apel 7daebd054e Implement segment display mode handling and update notifications 2017-12-27 18:40:19 +01:00
Soeren Apel aa8da126bb Don't set SR_CONF_LIMIT_FRAMES to 1 2017-12-27 18:40:19 +01:00
Soeren Apel aa71890d74 DecodeSignal: Make sure bit IDs are always up-to-date
https://www.youtube.com/watch?v=mw6Bd6Hv168 shows what
happens when this isn't done.
2017-12-13 14:03:59 +01:00
Philipp Marek a00f8221dc Session: Fix mismatched delete operator.
Mismatched free() / delete / delete []
   at 0x4C2D31B: operator delete(void*) (vg_replace_malloc.c:576)
   by 0x1C76D0: operator() (unique_ptr.h:78)
   by 0x1C76D0: ~unique_ptr (unique_ptr.h:268)
   by 0x1C76D0: pv::data::AnalogSegment::append_interleaved_samples(float const*, unsigned long, unsigned long) (analogsegment.cpp:78)
...
Address 0x1d123f70 is 0 bytes inside a block of size 312 alloc'd
   at 0x4C2C97F: operator new[](unsigned long) (vg_replace_malloc.c:423)
   by 0x1C765E: pv::data::AnalogSegment::append_interleaved_samples(float const*, unsigned long, unsigned long) (analogsegment.cpp:78)
   by 0x1AFDD5: pv::Session::feed_in_analog(std::shared_ptr<sigrok::Analog>) (session.cpp:1142)
2017-11-18 13:53:44 +01:00
Philipp Marek f9274b6890 Session: Fix mismatched delete operator.
Valgrind reported this here:

Mismatched free() / delete / delete []
   at 0x4C2D31B: operator delete(void*) (vg_replace_malloc.c:576)
   by 0x1C76D0: operator() (unique_ptr.h:78)
   by 0x1C76D0: ~unique_ptr (unique_ptr.h:268)
   by 0x1C76D0: pv::data::AnalogSegment::append_interleaved_samples(float const*, unsigned long, unsigned long) (analogsegment.cpp:78)
   by 0x1AFDD5: pv::Session::feed_in_analog(std::shared_ptr<sigrok::Analog>) (session.cpp:1142)
   by 0x1B043C: pv::Session::data_feed_in(std::shared_ptr<sigrok::Device>, std::shared_ptr<sigrok::Packet>) (session.cpp:1187)
...
 Address 0x1cbf6b90 is 0 bytes inside a block of size 940 alloc'd
   at 0x4C2C97F: operator new[](unsigned long) (vg_replace_malloc.c:423)
   by 0x1C765E: pv::data::AnalogSegment::append_interleaved_samples(float const*, unsigned long, unsigned long) (analogsegment.cpp:78)
   by 0x1AFDD5: pv::Session::feed_in_analog(std::shared_ptr<sigrok::Analog>) (session.cpp:1142)
2017-11-17 11:55:37 +01:00
Soeren Apel 4e86ec7042 Rework new segment notification mechanism 2017-10-29 23:38:06 +01:00
Soeren Apel bc93f1ef2f Append new segments to the end, not the beginning of the list 2017-10-27 18:44:51 +02:00
Soeren Apel b5940cf0ef Session: Query the device's sample rate when needed, not sooner 2017-10-09 17:47:19 +02:00
Soeren Apel b8132c767b DecodeSignal: Remove outdated code and comment 2017-09-23 08:33:16 +02:00
Soeren Apel 8d3c0f7a0b SignalBase: Make sure PDs are restarted when conv options change 2017-09-22 21:13:48 +02:00
Soeren Apel 60c426a05d TraceView: Properly handle the header resizing events 2017-09-22 21:13:48 +02:00