ftk_eventviewer_new creates and initialises new eventviewer instance. The returned GtkWidget pointer is in fact a pointer to a FtkEventViewer structure which should be considered opaque. The returned widget pointer should be cast to an FtkEventViewer pointer using the FTK_EVENTVIEWER() macro and used as the first argument to all of the following functions.
Table 1. ftk_eventviewer_resize Arguments
Argument | Description |
---|---|
eventviewer | A pointer to an opaque FtkEventViewer structure previously created using ftk_eventviewer_new. |
width | The requested width of the viewer. The actual width may be accted by the window manager. |
height | The requested height of the viewer. The actual height may be accted by the window manager. |
err | A pointer to a GError struct pointer. May be NULL if unused. |
ftk_eventviewer_resize attempts to resize the viewer instance referenced by the first argument to the width and height specified by the second and third arguments respectively. ftk_eventviewer_resize_e does the same thing but, if the fourth argument is non-null, will create a GError structure at the location specified by that argument. The GError * pointer passed to this function must be initialised to NULL; if it non-null when the function returns, an error has occurred and the GError structure must subsequently be freed using g_error_free.
Both of these functions return TRUE on success and FALSE on failure. In addition, if ftk_eventviewer_resize_e returns FALSE and has a valid non-null fourth argument, a GError structure will be created as described above.
#include <ftkeventviewer.h> |
gboolean ftk_eventviewer_set_bg_rgb
(FtkEventViewer * eventviewer, gint red, gint green, gint blue);
gboolean ftk_eventviewer_set_bg_rgb_e
(FtkEventViewer * eventviewer, gint red, gint green, gint blue, GError * err);
gboolean ftk_eventviewer_set_bg_color
(FtkEventViewer * eventviewer, GdkColor * color);
gboolean ftk_eventviewer_set_bg_color_e
(FtkEventViewer * eventviewer, GdkColor * color, GError * err);
Table 1. ftk_eventviewer_set_bg_rgb and ftk_eventviewer_set_bg_color Arguments
Argument | Description |
---|---|
eventviewer | A pointer to an opaque FtkEventViewer structure previously created using ftk_eventviewer_new. |
red | The red component of the requested color in a range of 0 to 65535. |
green | The green component of the requested color in a range of 0 to 65535. |
blue | The blue component of the requested color in a range of 0 to 65535. |
color | A pointer to a GdkColor structure containing the appropriate color components. |
err | A pointer to a GError struct pointer. May be NULL if unused. |
ftk_eventviewer_set_bg_rgb and ftk_eventviewer_set_bg_color change the bacground color of the viewer instance referenced by the first argument. ftk_eventviewer_set_bg_rgb accepts color information in the second, third and fourth arguments as red, green and blue color components respectively. All three components must be in a range of 0 to 65535 inclusive. ftk_eventviewer_set_bg_color accepts color information in its second argument as a pointer to a GdkColor struct. (N.B., a GdkColor struct may be set from a descriptive string, e.g. "lightblue," using gdk_color_parse(), q.v.)
ftk_eventviewer_set_bg_rgb_e and ftk_eventviewer_set_bg_color_e are identical to ftk_eventviewer_set_bg_rgb and ftk_eventviewer_set_bg_color respectively except that they accept an additional error-reporting argument as described above.
All of these functions return TRUE on success and FALSE on failure. The _e versions of the functions work as described above.
Table 1. ftk_eventviewer_timebase Arguments
Argument | Description |
---|---|
eventviewer | A pointer to an opaque FtkEventViewer structure previously created using ftk_eventviewer_new. |
span | The width in seconds spanned by the viewer. |
err | A pointer to a GError struct pointer. May be NULL if unused. |
ftk_eventviewer_set_timebase sets the width in seconds ofthe range of events to be displayed. That value corresponds to the interval in time between the left edge of the displayed information and the right edge, and may be modified by user interaction of other controls.
ftk_eventviewer_set_timebase_e is identical to ftk_eventviewer_set_timebase except that it accepts an additional error-reporting argument as described above.
These functions return TRUE on success and FALSE on failure. The _e version of the function works as described above.
Table 1. ftk_eventviewer_add_trace Arguments
Argument | Description |
---|---|
eventviewer | A pointer to an opaque FtkEventViewer structure previously created using ftk_eventviewer_new. |
label | A label to be associated with the trace. (May be NULL.) |
description | Optional additional information that may be associated with the trace, displayed when the pointer hovers over the label displayed in the viewer. May be NULL if unused. |
err | A pointer to a GError struct pointer. May be NULL if unused. |
ftk_eventviewer_add_trace appends a new trace to the series of traces displayed by the viewer. The label argument is used to supply a label for the trace while the description argument supplies a string that appears as additional information to the user when the pointer pauses over the displayed label. The traces are displayed, top to bottom, in the order in which they are defined.
ftk_eventviewer_add_trace_e is identical to ftk_eventviewer_add_trace except that it accepts an additional error-reporting argument as described above.
On success, these functions return an integer greater than or equal to zero identifying the trace for future use. Within a given viewer, these values are unique, but they may not be unique in separate viewer instances. On failure, a negative value is returned. The _e version of the function works as described above.
#include <ftkeventviewer.h> |
gboolean ftk_eventviewer_set_trace_rgb
(FtkEventViewer * eventviewer, gint trace, gint red, gint green, gint blue);
gboolean ftk_eventviewer_set_trace_rgb_e
(FtkEventViewer * eventviewer, gint trace, gint red, gint green, gint blue, GError * err);
gboolean ftk_eventviewer_set_trace_color
(FtkEventViewer * eventviewer, gint trace, GdkColor * color);
gboolean ftk_eventviewer_set_trace_color_e
(FtkEventViewer * eventviewer, gint trace, GdkColor * color, GError * err);
Table 1. ftk_eventviewer_set_trace_rgb and ftk_eventviewer_set_trace_color Arguments
Argument | Description |
---|---|
eventviewer | A pointer to an opaque FtkEventViewer structure previously created using ftk_eventviewer_new. |
trace | The identifier of a trace previously defined by ftk_eventviewer_add_trace. |
red | The red component of the requested color in a range of 0 to 65535. |
green | The green component of the requested color in a range of 0 to 65535. |
blue | The blue component of the requested color in a range of 0 to 65535. |
color | A pointer to a GdkColor structure containing the appropriate color components. |
err | A pointer to a GError struct pointer. May be NULL if unused. |
ftk_eventviewer_set_trace_rgb and ftk_eventviewer_set_trace_color change the color in the viewer instance referenced by the first argument of the trace identified by second argument. The second argument must be a value returned by a prior call to either ftk_eventviewer_add_trace or ftk_eventviewer_add_trace_e on the same viewer. ftk_eventviewer_set_trace_rgb accepts color information in the third, fourth and fifth arguments as red, green and blue color components respectively. All three components must be in a range of 0 to 65535 inclusive. ftk_eventviewer_set_trace_color accepts color information in its third argument as a pointer to a GdkColor struct. (N.B., a GdkColor struct may be set from a descriptive string, e.g. "lightblue," using gdk_color_parse(), q.v.)
ftk_eventviewer_set_trace_rgb_e and ftk_eventviewer_set_trace_color_e are identical to ftk_eventviewer_set_trace_rgb and ftk_eventviewer_set_trace_color respectively except that they accept an additional error-reporting argument as described above.
All of these functions return TRUE on success and FALSE on failure. The _e versions of the functions work as described above.
Table 1. ftk_eventviewer_set_trace_label Arguments
Argument | Description |
---|---|
eventviewer | A pointer to an opaque FtkEventViewer structure previously created using ftk_eventviewer_new. |
trace | The identifier of a trace previously defined by ftk_eventviewer_add_trace. |
label | A pointer to a string that, if non-NULL, will replace the existing trace label. |
description | A pointer to a string that, if non-NULL, will replace the existing trace description. NOTE: This argument is not yet implemented. |
err | A pointer to a GError struct pointer. May be NULL if unused. |
ftk_eventviewer_set_trace_label replaces the label associated with a trace identified by the second argument in the viewer identified by the first argument with the label specified by the third argument. The second argument must be a value returned by a prior call to either ftk_eventviewer_add_trace or ftk_eventviewer_add_trace_e on the same viewer.
At some point, an additional description argument will be added to similarly replace the description string.
ftk_eventviewer_set_trace_label_e is identical to ftk_eventviewer_set_trace_label except that it accepts an additional error-reporting argument as described above.
Both of these functions return TRUE on success and FALSE on failure. The _e version of the function work as described above.
Table 1. ftk_eventviewer_set_trace_linestyle Arguments
Argument | Description |
---|---|
eventviewer | A pointer to an opaque FtkEventViewer structure previously created using ftk_eventviewer_new. |
trace | The identifier of a trace previously defined by ftk_eventviewer_add_trace. |
linewidth | The width, in pixels, of the trace. |
linestyle | The length in pixels of the dashes used to create the trace. |
err | A pointer to a GError struct pointer. May be NULL if unused. |
ftk_eventviewer_set_trace_linstyle sets the line style and line width of the trace identified by the second argument in the viewer identified by the first argument. The second argument must be a value returned by a prior call to either ftk_eventviewer_add_trace or ftk_eventviewer_add_trace_e on the same viewer.
The linewidth argument may either be a positive value specifying the width in pixels of the trace, or any negative value to specify the use of the dafault width. If the linestyle argument is negative, a solid trace will be created; if positive, a dashed trace consisting of segments of the specified length alternating with gaps of the same length will be created.
ftk_eventviewer_set_trace_linestyle_e is identical to ftk_eventviewer_set_trace_linestyle except that it accepts an additional error-reporting argument as described above.
Both of these functions return TRUE on success and FALSE on failure. The _e version of the function work as described above.
Table 1. ftk_eventviewer_marker_new Arguments
Argument | Description |
---|---|
eventviewer | A pointer to an opaque FtkEventViewer structure previously created using ftk_eventviewer_new. |
glyph | An enum value of type FtkGlyph indentifying which of the available glyphs to use in displaying the marker. |
label | A label to be associated with the marker. (May be NULL.) |
description | Optional additional information that may be associated with the marker, displayed when the pointer hovers over the marker or the corresponding legend displayed in the viewer. May be NULL if unused. |
err | A pointer to a GError struct pointer. May be NULL if unused. |
Table 2. FtkGlyph Values.
Enum | Glyph | Description |
---|---|---|
FTK_GLYPH_FILLED_CIRCLE | • | A filled circle. |
FTK_GLYPH_FILLED_SQUARE | ▪ | A filled square. |
FTK_GLYPH_FILLED_UP_TRIANGLE | ▴ | A filled upwards-pointing triangle |
FTK_GLYPH_FILLED_DOWN_TRIANGLE | ▾ | A filled downwards-pointing triangle. |
FTK_GLYPH_FILLED_DIAMOND | ♢ | A filled diamond. |
FTK_GLYPH_FILLED_FOUR_STAR | ✦ | A filled four-pointed star. |
FTK_GLYPH_OPEN_FOUR_STAR | ✧ | An open four-pointed star. |
FTK_GLYPH_FILLED_FIVE_STAR | ⋆ | A filled five-pointed star. |
FTK_GLYPH_AUTOMATIC | A flag indicating that glyph selection and marker colors should be assigned automatically by the widget. The colors used are those shown in the figure below. |
ftk_eventviewer_marker_new defines a marker to be used in the viewer. The glyph argument specifies which of the available geometric shapes will be drawn in the display to mark the location of an event, and the label argument is used to supply a label for the marker. The description argument supplies a string that appears as additional information to the user when the pointer pauses over a displayed event or the legend describing the significance of the events..
If the value of the glyph argument
is FTK_GLYPH_AUTOMATIC
, glyphs will automatically be
assigned to markers in rotation. In addition, a color will
autonatically be assigned
to the marker from a pool of pre-defined color values. (The colors may
also be set explicitly—see ftk_eventviewer_set_marker_rgb or
ftk_eventviewer_set_marker_color.)
ftk_eventviewer_marker_new_e is identical to ftk_eventviewer_marker_new except that it accepts an additional error-reporting argument as described above.
On success, these functions return an integer greater than or equal to zero identifying the marker for future use. Within a given viewer, these values are unique, but they may not be unique in separate viewer instances. On failure, a negative value is returned. The _e version of the function works as described above.
#include <ftkeventviewer.h> |
gboolean ftk_eventviewer_set_marker_rgb
(FtkEventViewer * eventviewer, gint marker, gint red, gint green, gint blue);
gboolean ftk_eventviewer_set_marker_rgb_e
(FtkEventViewer * eventviewer, gint marker, gint red, gint green, gint blue, GError * err);
gboolean ftk_eventviewer_set_marker_color
(FtkEventViewer * eventviewer, gint marker, GdkColor * color);
gboolean ftk_eventviewer_set_marker_color_e
(FtkEventViewer * eventviewer, gint marker, GdkColor * color, GError * err);
Table 1. ftk_eventviewer_set_marker_rgb and ftk_eventviewer_set_marker_color Arguments
Argument | Description |
---|---|
eventviewer | A pointer to an opaque FtkEventViewer structure previously created using ftk_eventviewer_new. |
marker | The identifier of a marker previously defined by ftk_eventviewer_marker_new. |
red | The red component of the requested color in a range of 0 to 65535. |
green | The green component of the requested color in a range of 0 to 65535. |
blue | The blue component of the requested color in a range of 0 to 65535. |
color | A pointer to a GdkColor structure containing the appropriate color components. |
err | A pointer to a GError struct pointer. May be NULL if unused. |
ftk_eventviewer_set_marker_rgb and ftk_eventviewer_set_marker_color change the color in the viewer instance referenced by the first argument of the marker identified by second argument. The second argument must be a value returned by a prior call to either ftk_eventviewer_marker_new or ftk_eventviewer_marker_new_e on the same viewer. ftk_eventviewer_set_marker_rgb accepts color information in the third, fourth and fifth arguments as red, green and blue color components respectively. All three components must be in a range of 0 to 65535 inclusive. ftk_eventviewer_set_marker_color accepts color information in its third argument as a pointer to a GdkColor struct. (N.B., a GdkColor struct may be set from a descriptive string, e.g. "lightblue," using gdk_color_parse(), q.v.)
ftk_eventviewer_set_marker_rgb_e and ftk_eventviewer_set_marker_color_e are identical to ftk_eventviewer_set_marker_rgb and ftk_eventviewer_set_marker_color respectively except that they accept an additional error-reporting argument as described above.
All of these functions return TRUE on success and FALSE on failure. The _e versions of the functions work as described above.
Table 1. ftk_eventviewer_set_marker_label Arguments
Argument | Description |
---|---|
eventviewer | A pointer to an opaque FtkEventViewer structure previously created using ftk_eventviewer_new. |
marker | The identifier of a marker previously defined by ftk_eventviewer_marker_new. |
label | A pointer to a string that, if non-NULL, will replace the existing marker label. |
description | A pointer to a string that, if non-NULL, will replace the existing marker description. NOTE: This argument is not yet implemented. |
err | A pointer to a GError struct pointer. May be NULL if unused. |
ftk_eventviewer_set_marker_label replaces the label associated with a marker identified by the second argument in the viewer identified by the first argument with the label specified by the third argument. The second argument must be a value returned by a prior call to either ftk_eventviewer_marker_new or ftk_eventviewer_marker_new_e on the same viewer.
At some point, an additional description argument will be added to similarly replace the description string.
ftk_eventviewer_set_marker_label_e is identical to ftk_eventviewer_set_marker_label except that it accepts an additional error-reporting argument as described above.
Both of these functions return TRUE on success and FALSE on failure. The _e version of the function work as described above.
Table 1. ftk_tie_new Arguments
Argument | Description |
---|---|
eventviewer | A pointer to an opaque FtkEventViewer structure previously created using ftk_eventviewer_new. |
err | A pointer to a GError struct pointer. May be NULL if unused. |
ftk_eventviewer_tie_new defines a new tie in a viewer. Ties are used in ftk_eventviewer_append_simultaneous_events to visually connect simultaneous events.
ftk_eventviewer_new_tie_e is identical to ftk_eventviewer_new_tie except that it accepts an additional error-reporting argument as described above.
On success, these functions return an integer greater than or equal to zero identifying the tie for future use. Within a given viewer, these values are unique, but they may not be unique in separate viewer instances. On failure, a negative value is returned. The _e version of the function works as described above.
#include <ftkeventviewer.h> |
gboolean ftk_eventviewer_set_tie_rgb
(FtkEventViewer * eventviewer, gint tie, gint red, gint green, gint blue);
gboolean ftk_eventviewer_set_tie_rgb_e
(FtkEventViewer * eventviewer, gint tie, gint red, gint green, gint blue, GError * err);
gboolean ftk_eventviewer_set_tie_color
(FtkEventViewer * eventviewer, gint tie, GdkColor * color);
gboolean ftk_eventviewer_set_tie_color_e
(FtkEventViewer * eventviewer, gint tie, GdkColor * color, GError * err);
Table 1. ftk_eventviewer_set_tie_rgb and ftk_eventviewer_set_tie_color Arguments
Argument | Description |
---|---|
eventviewer | A pointer to an opaque FtkEventViewer structure previously created using ftk_eventviewer_new. |
tie | The identifier of a tie previously defined by ftk_eventviewer_tie_new. |
red | The red component of the requested color in a range of 0 to 65535. |
green | The green component of the requested color in a range of 0 to 65535. |
blue | The blue component of the requested color in a range of 0 to 65535. |
color | A pointer to a GdkColor structure containing the appropriate color components. |
err | A pointer to a GError struct pointer. May be NULL if unused. |
ftk_eventviewer_set_tie_rgb and ftk_eventviewer_set_tie_color change the color in the viewer instance referenced by the first argument of the tie identified by second argument. The second argument must be a value returned by a prior call to either ftk_eventviewer_tie_new or ftk_eventviewer_tie_new_e on the same viewer. ftk_eventviewer_set_tie_rgb accepts color information in the third, fourth and fifth arguments as red, green and blue color components respectively. All three components must be in a range of 0 to 65535 inclusive. ftk_eventviewer_set_tie_color accepts color information in its third argument as a pointer to a GdkColor struct. (N.B., a GdkColor struct may be set from a descriptive string, e.g. "lightblue," using gdk_color_parse(), q.v.)
ftk_eventviewer_set_tie_rgb_e and ftk_eventviewer_set_tie_color_e are identical to ftk_eventviewer_set_tie_rgb and ftk_eventviewer_set_tie_color respectively except that they accept an additional error-reporting argument as described above.
All of these functions return TRUE on success and FALSE on failure. The _e versions of the functions work as described above.
Table 1. ftk_eventviewer_set_tie_linestyle Arguments
Argument | Description |
---|---|
eventviewer | A pointer to an opaque FtkEventViewer structure previously created using ftk_eventviewer_new. |
tie | The identifier of a tie previously defined by ftk_eventviewer_tie_new. |
linewidth | The width, in pixels, of the tie. |
linestyle | The length in pixels of the dashes used to create the tie. |
err | A pointer to a GError struct pointer. May be NULL if unused. |
ftk_eventviewer_set_tie_linstyle sets the line style and line width of the tie identified by the second argument in the viewer identified by the first argument. The second argument must be a value returned by a prior call to either ftk_eventviewer_tie_new or ftk_eventviewer_tie_new_e on the same viewer.
The linewidth argument may either be a positive value specifying the width in pixels of the tie, or any negative value to specify the use of the dafault width. If the linestyle argument is negative, a solid tie will be created; if positive, a dashed tie consisting of segments of the specified length alternating with gaps of the same length will be created.
ftk_eventviewer_set_tie_linestyle_e is identical to ftk_eventviewer_set_tie_linestyle except that it accepts an additional error-reporting argument as described above.
Both of these functions return TRUE on success and FALSE on failure. The _e version of the function work as described above.
Table 1. ftk_eventviewer_append_event Arguments
Argument | Description |
---|---|
eventviewer | A pointer to an opaque FtkEventViewer structure previously created using ftk_eventviewer_new. |
trace | The identifier of a trace previously defined by ftk_eventviewer_add_trace. |
marker | The identifier of a marker previously defined by ftk_eventviewer_marker_new. |
description | Optional additional information that may be associated with the event, displayed when the pointer hovers over the event displayed in the viewer. May be NULL if unused. |
err | A pointer to a GError struct pointer. May be NULL if unused. |
ftk_eventviewer_append_event appends an event of the given marker type to the given trace, using in internally provided timestamp. The trace specification, the second argument, must be a value previously returned by ftk_eventviewer_add_trace; similarly, the marker argument must be a value returned by ftk_eventviewer_marker_new.
The internally generated timestamp has microsecond resolution.
ftk_eventviewer_append_event_e is identical to ftk_eventviewer_append_event except that it accepts an additional error-reporting argument as described above.
On success, both of these functions return a non-negative value identifying the appended event; on failure the return a negative one (-1). The _e version of the function work as described above.
Table 1. ftk_eventviewer_append_simultaneous_events Arguments
Argument | Description |
---|---|
eventviewer | A pointer to an opaque FtkEventViewer structure previously created using ftk_eventviewer_new. |
tie | The identifier of a tie previously defined by ftk_eventviewer_tie_new. |
err | A pointer to a GError struct pointer. May be NULL if unused. |
... | A variable-length list of any number of trace identifiers, marker identifiers, and description strings specifying an arbitrary number of simultaneously occurring events. |
ftk_eventviewer_append_simultaneous_events appends any number of events, all of which receive the same timestamp and thus are considered to have occurred simultaneously. The events to append are specified as a repeated list of parameters identical to those supplied to ftk_eventviewer_append_event_e: trace, marker, description. The end of the list is indicated by a trace argument of negative one (-1). The number of event-specifying parameters passed, exclusive of the terminal -1, must be a multiple of three; the results of any other condition are unpredictable. All three of these parameters are as described in the description of ftk_eventviewer_append_event_e.
ftk_eventviewer_append_simultaneous_events_e is identical to ftk_eventviewer_append_simultaneous_events except that it accepts an additional error-reporting argument as described above.
Both of these functions return TRUE on success and FALSE on failure. The _e version of the function work as described above.
Table 1. ftk_eventviewer_tie_events Arguments
Argument | Description |
---|---|
eventviewer | A pointer to an opaque FtkEventViewer structure previously created using ftk_eventviewer_new. |
tie | The identifier of a tie previously defined by ftk_eventviewer_tie_new. |
err | A pointer to a GError struct pointer. May be NULL if unused. |
... | A variable-length list of any number of event identifiers of an arbitrary number of existing events. |
ftk_eventviewer_tie_events lisuall links any number of existing events, regardless of simultaneity. The events to link are specified as a repeated list of event identifiers returned by ftk_eventviewer_append_event_e. The end of the list is indicated by an argument of negative one (-1).
ftk_eventviewer_tie_events_e is identical to ftk_eventviewer_tie_events except that it accepts an additional error-reporting argument as described above.
Both of these functions return TRUE on success and FALSE on failure. The _e version of the function work as described above.
This is an example fake application that shows how to use the eventviewer API.
Example 1. An example fake application using eventviewer.
/* chlm */ #include <stdlib.h> #define _GNU_SOURCE #include <math.h> #include <signal.h> #include <time.h> #include <sys/types.h> #include <sys/time.h> #include <unistd.h> #include <gtk/gtk.h> #include <ftkeventviewer.h> GtkWidget * eventviewer1; GtkWidget * eventviewer2; GtkWidget * frame2; gint clone_tie; gint term_tie; FtkEventViewer * thread_viewer; FtkEventViewer * event_viewer; GdkColor bg_color; GdkColor bg_color1; typedef struct { gint marker_id; gint trace_id; char * label; char * string; char * tstring; GdkColor * color; } plot_parms_s; static plot_parms_s thread_parms[] = { {0, 0, "Parent", "The parent process.", "Mama proc"}, {0, 0, "Thread 0", NULL, "Kid 0"}, {0, 0, "Thread 1", NULL, "Kid 1"}, {0, 0, "Thread 2", NULL, "Kid 2"}, }; enum { IDX_PARENT, IDX_THREAD0, IDX_THREAD1, IDX_THREAD2 }; static int threads_count = sizeof(thread_parms)/sizeof(plot_parms_s); static plot_parms_s event_parms[] = { {0, 0, "clone", "A clone event.", "Bring in the clones."}, {0, 0, "event A", NULL}, {0, 0, "event B", NULL}, {0, 0, "event C", NULL}, {0, 0, "term", "A termination event.", "Die!"}, }; enum { IDX_CLONE, IDX_EVENTA, IDX_EVENTB, IDX_EVENTC, IDX_TERM }; static int events_count = sizeof(event_parms)/sizeof(plot_parms_s); int max_event_nr; int events_added = 1; int sigs_sent = 0; #define MAX_SIGS_SENT 30 GdkColor clone_tie_color = {0, 65535, 32768, 32769}; GdkColor term_tie_color = {0, 0, 32760, 32769}; static void catch_sigalrm (int sig) { GError * err = NULL; int rt = lrint (drand48() * 32.0); int et = lrint (drand48() * 15.0); if (NULL == eventviewer1) return; #if 0 fprintf (stderr, "catch_sigalrm %d\n", sigs_sent); #endif if (sigs_sent++ >= MAX_SIGS_SENT) { if (events_added) { fprintf (stderr, "stopping\n"); struct itimerval value; struct itimerval ovalue; int clone_term_event; int parent_term_event; events_added = 0; clone_term_event = ftk_eventviewer_append_event (thread_viewer, thread_parms[IDX_THREAD0].trace_id, event_parms[IDX_TERM].marker_id, "termination of thread 0"); ftk_eventviewer_append_event (event_viewer, event_parms[IDX_TERM].trace_id, thread_parms[IDX_THREAD0].marker_id, "termination of thread 0"); usleep (125000); parent_term_event = ftk_eventviewer_append_event (thread_viewer, thread_parms[IDX_PARENT].trace_id, event_parms[IDX_TERM].marker_id, "termination of thread 0"); ftk_eventviewer_append_event (event_viewer, event_parms[IDX_TERM].trace_id, thread_parms[IDX_PARENT].marker_id, "termination of thread 0"); ftk_eventviewer_tie_events (thread_viewer, term_tie, clone_term_event, parent_term_event, -1); usleep (250000); clone_term_event = ftk_eventviewer_append_event (thread_viewer, thread_parms[IDX_THREAD1].trace_id, event_parms[IDX_TERM].marker_id, "termination of thread 1"); ftk_eventviewer_append_event (event_viewer, event_parms[IDX_TERM].trace_id, thread_parms[IDX_THREAD1].marker_id, "termination of thread 1"); usleep (125000); parent_term_event = ftk_eventviewer_append_event (thread_viewer, thread_parms[IDX_PARENT].trace_id, event_parms[IDX_TERM].marker_id, "termination of thread 1"); ftk_eventviewer_append_event (event_viewer, event_parms[IDX_TERM].trace_id, thread_parms[IDX_PARENT].marker_id, "termination of thread 1"); ftk_eventviewer_tie_events (thread_viewer, term_tie, clone_term_event, parent_term_event, -1); usleep (250000); clone_term_event = ftk_eventviewer_append_event (thread_viewer, thread_parms[IDX_THREAD2].trace_id, event_parms[IDX_TERM].marker_id, "termination of thread 2"); ftk_eventviewer_append_event (event_viewer, event_parms[IDX_TERM].trace_id, thread_parms[IDX_THREAD2].marker_id, "termination of thread 2"); usleep (125000); parent_term_event = ftk_eventviewer_append_event (thread_viewer, thread_parms[IDX_PARENT].trace_id, event_parms[IDX_TERM].marker_id, "termination of thread 2"); ftk_eventviewer_append_event (event_viewer, event_parms[IDX_TERM].trace_id, thread_parms[IDX_PARENT].marker_id, "termination of thread 2"); ftk_eventviewer_tie_events (thread_viewer, term_tie, clone_term_event, parent_term_event, -1); sleep (1); ftk_eventviewer_append_event (thread_viewer, thread_parms[IDX_PARENT].trace_id, event_parms[IDX_TERM].marker_id, "termination of parent"); ftk_eventviewer_append_event (event_viewer, event_parms[IDX_TERM].trace_id, thread_parms[IDX_PARENT].marker_id, "termination of parent"); signal (SIGALRM, catch_sigalrm); value.it_interval.tv_sec = 0; value.it_interval.tv_usec = 0; value.it_value.tv_sec = 0; value.it_value.tv_usec = 0; setitimer (ITIMER_REAL, &value, &ovalue); return; } #if 1 else { fprintf (stderr, "changing state\n"); sigs_sent = -200; events_added = 1; ftk_eventviewer_set_bg_rgb (thread_viewer, 65535, 65535, 65535); #if 0 ftk_eventviewer_set_trace_rgb (FTK_EVENTVIEWER (eventviewer1), traces[2], 65535, 28000, 0); ftk_eventviewer_set_trace_label (FTK_EVENTVIEWER (eventviewer1), traces[1], LABEL_TERM); /* width in pixels. a width <= 0 implies default width. values 1 - 8 work ok */ /* style is dash spec */ ftk_eventviewer_set_trace_linestyle (FTK_EVENTVIEWER (eventviewer1), traces[1], 3, 3); #endif max_event_nr = 5; } #endif } if (et <= max_event_nr) { int mi = 1 + (rt & 3); if (mi < 4) { int ti = (rt >> 2) & 3; ftk_eventviewer_append_event_e (FTK_EVENTVIEWER (eventviewer1), thread_parms[ti].trace_id, event_parms[mi].marker_id, NULL, &err); if (NULL != err) { fprintf (stderr, "Unable to append event: %s\n", err->message); g_error_free (err); } ftk_eventviewer_append_event_e (FTK_EVENTVIEWER (eventviewer2), event_parms[mi].trace_id, thread_parms[ti].marker_id, NULL, &err); if (NULL != err) { fprintf (stderr, "Unable to append event: %s\n", err->message); g_error_free (err); } } } signal (SIGALRM, catch_sigalrm); } static void quit_cb (GtkButton * button, gpointer user_data) { gtk_widget_destroy (frame2); eventviewer2 = NULL; } int main( int argc, char *argv[] ) { GtkWidget *window; GtkWidget *vbox; GtkWidget *frame; gboolean rc; GError * err; gtk_init (&argc, &argv); srand48 (time (0)); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_signal_connect(GTK_OBJECT(window), "destroy", GTK_SIGNAL_FUNC(gtk_main_quit), NULL); gtk_window_set_title (GTK_WINDOW (window), "Frysk Eventviewer"); #if 0 { GdkColor color; if (gdk_color_parse ("purple", &color)) { fprintf (stderr, "purple = %#08x [%d %d %d]\n", (int)color.pixel, (int)color.red, (int)color.green, (int)color.blue); } else fprintf (stderr, "purple not found\n"); } #endif gdk_color_parse ("black", &bg_color); gdk_color_parse ("lightblue", &bg_color1); g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (exit), NULL); gtk_container_set_border_width (GTK_CONTAINER (window), 10); vbox = gtk_vbox_new(FALSE, 10); gtk_container_add(GTK_CONTAINER(window), vbox); gtk_widget_show(vbox); eventviewer1 = ftk_eventviewer_new (); // ftk_eventviewer_resize (FTK_EVENTVIEWER (eventviewer1), 500, 150); gtk_widget_show (eventviewer1); eventviewer2 = ftk_eventviewer_new (); // ftk_eventviewer_resize (FTK_EVENTVIEWER (eventviewer2), 500, 175); gtk_widget_show (eventviewer2); thread_viewer = FTK_EVENTVIEWER (eventviewer1); event_viewer = FTK_EVENTVIEWER (eventviewer2); /* if not set, default is provided */ ftk_eventviewer_set_bg_color (thread_viewer, &bg_color1); ftk_eventviewer_set_bg_color (event_viewer, &bg_color); ftk_eventviewer_set_timebase (thread_viewer, 20.0); ftk_eventviewer_set_timebase (event_viewer, 20.0); { int i; for (i = 0; i < events_count; i++) { /* for every event type... */ event_parms[i].marker_id = /* create a marker in the thread view */ ftk_eventviewer_marker_new (thread_viewer, /* using auto glyph and color assgn */ FTK_GLYPH_AUTOMATIC, event_parms[i].label, event_parms[i].string); event_parms[i].color = /* retrieve the color */ ftk_eventviewer_get_marker_color (thread_viewer, event_parms[i].marker_id); event_parms[i].trace_id = /* create a trace in the event view */ ftk_eventviewer_add_trace (event_viewer, event_parms[i].label, event_parms[i].tstring); ftk_eventviewer_set_trace_color (event_viewer, event_parms[i].trace_id, event_parms[i].color); } for (i = 0; i < threads_count; i++) { /* for every thread type... */ thread_parms[i].marker_id = /* create a marker in the event view */ ftk_eventviewer_marker_new (event_viewer, FTK_GLYPH_AUTOMATIC, thread_parms[i].label, thread_parms[i].string); thread_parms[i].color = /* retrieve the color */ ftk_eventviewer_get_marker_color (event_viewer, thread_parms[i].marker_id); thread_parms[i].trace_id = /* create a trace in the thread view */ ftk_eventviewer_add_trace (thread_viewer, thread_parms[i].label, thread_parms[i].tstring); ftk_eventviewer_set_trace_color (thread_viewer, thread_parms[i].trace_id, thread_parms[i].color); } } /* just for the fun of it, change the linewidth and linestyle of some trace */ /* width in pixels. a width <= 0 implies default width. values 1 - 8 work ok */ /* style is dash spec */ ftk_eventviewer_set_trace_linestyle (thread_viewer, thread_parms[IDX_PARENT].trace_id, 5, /* width */ 5); /* style */ #ifdef USE_TIE_LABEL clone_tie = ftk_eventviewer_tie_new (thread_viewer, "clone"); #else clone_tie = ftk_eventviewer_tie_new (thread_viewer); term_tie = ftk_eventviewer_tie_new (thread_viewer); #endif ftk_eventviewer_set_tie_color (thread_viewer, clone_tie, &clone_tie_color); ftk_eventviewer_set_tie_color (thread_viewer, term_tie, &term_tie_color); ftk_eventviewer_set_tie_linestyle (thread_viewer, term_tie, 2, 2); ftk_eventviewer_append_simultaneous_events (thread_viewer, clone_tie, thread_parms[IDX_PARENT].trace_id, event_parms[IDX_CLONE].marker_id, "a simultaneous w/ thread 0 clone", thread_parms[IDX_THREAD0].trace_id, event_parms[IDX_CLONE].marker_id, "b simultaneous w/ parent clone", -1); ftk_eventviewer_append_simultaneous_events (event_viewer, -1, event_parms[IDX_CLONE].trace_id, thread_parms[IDX_PARENT].marker_id, "c simultaneous w/ thread 0 clone", event_parms[IDX_CLONE].trace_id, thread_parms[IDX_THREAD0].marker_id, "d simultaneous w/ parent clone", -1); usleep (250000); ftk_eventviewer_append_simultaneous_events (thread_viewer, clone_tie, thread_parms[IDX_PARENT].trace_id, event_parms[IDX_CLONE].marker_id, "e simultaneous w/ thread 1\nand thread 2 clones", thread_parms[IDX_THREAD2].trace_id, event_parms[IDX_CLONE].marker_id, "f simultaneous w/ parent\nand thread 1 clones", thread_parms[IDX_THREAD1].trace_id, event_parms[IDX_CLONE].marker_id, "g simultaneous w/ parent\nand thread 2 clones", -1); ftk_eventviewer_append_simultaneous_events (event_viewer, -1, event_parms[IDX_CLONE].trace_id, thread_parms[IDX_PARENT].marker_id, "h simultaneous w/ thread 1 clone", event_parms[IDX_CLONE].trace_id, thread_parms[IDX_THREAD1].marker_id, "i simultaneous w/ parent clone", -1); usleep (250000); ftk_eventviewer_append_simultaneous_events (thread_viewer, clone_tie, thread_parms[IDX_PARENT].trace_id, event_parms[IDX_CLONE].marker_id, "j simultaneous w/ thread 2 clone", thread_parms[IDX_THREAD2].trace_id, event_parms[IDX_CLONE].marker_id, "k simultaneous w/ parent clone", -1); ftk_eventviewer_append_simultaneous_events (event_viewer, -1, event_parms[IDX_CLONE].trace_id, thread_parms[IDX_PARENT].marker_id, "l simultaneous w/ thread 2 clone", event_parms[IDX_CLONE].trace_id, thread_parms[IDX_THREAD2].marker_id, "m simultaneous w/ parent clone", -1); usleep (250000); #if 0 ftk_eventviewer_resize (thread_viewer, 600, 100); #endif max_event_nr = 4; /* _e suffixed versions of the fcns tell you if something screwed up */ err = NULL; if (NULL != err) { fprintf (stderr, "Unable to set update: %s\n", err->message); g_error_free (err); exit (1); } if (FALSE == rc) exit (2); frame = gtk_frame_new ("Events by thread"); gtk_container_add (GTK_CONTAINER(frame), eventviewer1); gtk_widget_show (frame); gtk_box_pack_start_defaults (GTK_BOX (vbox), frame); frame2 = gtk_frame_new ("Threads by event"); gtk_container_add (GTK_CONTAINER(frame2), eventviewer2); gtk_widget_show (frame2); gtk_box_pack_start_defaults (GTK_BOX (vbox), frame2); { GtkWidget * hbutton_box = gtk_hbutton_box_new(); GtkWidget * quit_button = gtk_button_new_with_mnemonic ("_Quit"); g_signal_connect (GTK_OBJECT(quit_button),"clicked", (GtkSignalFunc) quit_cb, NULL); gtk_container_add (GTK_CONTAINER (hbutton_box), quit_button); gtk_widget_show_all (hbutton_box); gtk_box_pack_start (GTK_BOX (vbox), hbutton_box, FALSE, FALSE, 0); } gtk_widget_show (window); { struct itimerval value; struct itimerval ovalue; signal (SIGALRM, catch_sigalrm); value.it_interval.tv_sec = 0; value.it_interval.tv_usec = 500000; value.it_value.tv_sec = 0; value.it_value.tv_usec = 500000; setitimer (ITIMER_REAL, &value, &ovalue); } gtk_main (); return 0; } |