File: DumpToFile.c

package info (click to toggle)
ltt 0.9.5pre6-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 3,256 kB
  • ctags: 1,630
  • sloc: ansic: 17,284; sh: 8,010; makefile: 252
file content (1115 lines) | stat: -rw-r--r-- 42,913 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
/*
   DumpToFile.c : Dump to file dialog window.
   Copyright (C) 1999 Jean-Hugues Deschenes, 2000 Karim Yaghmour.
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; version 2 of the License.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

   History :
      K.Y., 22/08/2000, Added RTAI support
      JH.D., 15/09/1999, Initial typing.
*/

#include <stdlib.h>
#include <malloc.h>

#include <Tables.h>

#include "MainWindow.h"

/**********************************************************************************/
/**************************** Internal signal handlers ****************************/
/**********************************************************************************/
/******************************************************************
 * Function :
 *    ISHSetEventInMask()
 * Description :
 * Parameters :
 * Return values :
 * History :
 * Note :
 ******************************************************************/
void ISHSetEventInMask(GtkWidget* pmWidget, gpointer pmData)
{
  gint                lEventID; /* the list item's associated event type */
  trace_event_mask*   lMask;    /* The mask to use to set selection/deselection information */

  /* Retrieve the vector pointer */
  if(!(lMask = (trace_event_mask*) pmData))
    {
    g_print("Invalid Mask pointer in ISHSetEventInMask! \n");
    exit(1);
    }

  /* retireve the event type index */
  lEventID = (gint) gtk_object_get_data(GTK_OBJECT(pmWidget), EVENT_TYPE_DATA);

  /* is this a valid index? */
  if(lEventID >= 0 && lEventID <= MaxEventID)
    {
    /* Is the event type to be selected? */
    if(ltt_test_bit(lEventID, lMask))
      /* Select it */
      gtk_widget_set_state(pmWidget, GTK_STATE_SELECTED);
    /* Otherwise, the item is to be deselected */
    else
      /* Deselect it */
      gtk_widget_set_state(pmWidget, GTK_STATE_NORMAL);
    }
}

/******************************************************************
 * Function :
 *    ISHSelectEventRadioButton()
 * Description :
 * Parameters :
 * Return values :
 * History :
 * Note :
 ******************************************************************/
void ISHSelectEventRadioButton(GtkWidget* pmWidget, gpointer pmData)
{
  dumpToFileWindow* pDumpWindow; /* The dump to file window */

  if(!(pDumpWindow = (dumpToFileWindow*) pmData))
    {
    g_print("Selected event radio without passing dump to file window! \n");
    exit(1);
    }

  /* Set initial values for the event type Tracing options */
  pDumpWindow->LocalOptions->Omit = pDumpWindow->LocalOptions->Trace = FALSE;

  /* Should we specify event types omitted? */
  if(((pDumpWindow->LocalOptions->Omit = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(pDumpWindow->OmitTheseEvents)) == TRUE))
     && (pDumpWindow->OmitTheseEvents == pmWidget))
    /* Go through the event type list to set the options accordingly */
    gtk_container_foreach(GTK_CONTAINER(pDumpWindow->EventList),
			  ISHSetEventInMask,
			  (gpointer) &(pDumpWindow->LocalOptions->OmitMask));

  /* Should we specify event types included? */
  if(((pDumpWindow->LocalOptions->Trace = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(pDumpWindow->TraceTheseEvents)) == TRUE)
      && pDumpWindow->TraceTheseEvents == pmWidget))
    /* Go through the event type list to set the options accordingly */
    gtk_container_foreach(GTK_CONTAINER(pDumpWindow->EventList),
			  ISHSetEventInMask,
			  (gpointer) &(pDumpWindow->LocalOptions->TraceMask));

  /* Make the event type list sensitive if either option is selected */
  gtk_widget_set_sensitive(pDumpWindow->ScrolledEventList, 
			   pDumpWindow->LocalOptions->Omit || pDumpWindow->LocalOptions->Trace);
}

/******************************************************************
 * Function :
 *    ISHSelectProcRadioButton()
 * Description :
 * Parameters :
 * Return values :
 * History :
 * Note :
 ******************************************************************/
void ISHSelectProcRadioButton(GtkWidget* pmWidget, gpointer pmData)
{
  dumpToFileWindow* pDumpWindow; /* The dump to file window */

  if(!(pDumpWindow = (dumpToFileWindow*) pmData))
    {
    g_print("Selected process radio without passing dump to file window! \n");
    exit(1);
    }

  /* Should we trace all PIDs? */
  pDumpWindow->LocalOptions->TracePID = 
    gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(pDumpWindow->JustThisProc));

  /* Make the option menu sensitive if process specification is selected */
  gtk_widget_set_sensitive(pDumpWindow->Proclist, 
			   pDumpWindow->LocalOptions->TracePID);

}

/******************************************************************
 * Function :
 *    ISHSelectSMPRadioButton()
 * Description :
 * Parameters :
 * Return values :
 * History :
 * Note :
 ******************************************************************/
void ISHSelectSMPRadioButton(GtkWidget* pmWidget, gpointer pmData)
{
  dumpToFileWindow* pDumpWindow; /* The dump to file window */

  if(!(pDumpWindow = (dumpToFileWindow*) pmData))
    {
    g_print("Selected SMP radio without passing dump to file window! \n");
    exit(1);
    }

  /* Should we trace all CPU IDs? */
  pDumpWindow->LocalOptions->TraceCPUID = 
    gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(pDumpWindow->JustThisCPU));

  /* Make the option menu sensitive if CPU specification is selected */
  gtk_widget_set_sensitive(pDumpWindow->CPUIDEntry, 
			   pDumpWindow->LocalOptions->TraceCPUID);

}

/******************************************************************
 * Function :
 *    ISHSelectEventCheckBox()
 * Description :
 * Parameters :
 * Return values :
 * History :
 * Note :
 ******************************************************************/
void ISHSelectEventCheckBox(GtkWidget* pmWidget, gpointer pmData)
{
  dumpToFileWindow* pDumpWindow; /* The dump to file window */

  if(!(pDumpWindow = (dumpToFileWindow*) pmData))
    {
    g_print("Selected event radio without passing dump to file window! \n");
    exit(1);
    }

  /* Shoule event types be printed? */
  pDumpWindow->LocalOptions->Summarize = 
    !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(pDumpWindow->PrintEvents));

  /* Make the event type selection radio buttons unavailable */
  gtk_widget_set_sensitive(pDumpWindow->SelectEventFrame, 
			   !pDumpWindow->LocalOptions->Summarize);
}

/******************************************************************
 * Function :
 *    ISHSelectEventType()
 * Description :
 * Parameters :
 * Return values :
 * History :
 * Note :
 ******************************************************************/
void ISHSelectEventType(GtkWidget* pmWidget, GtkStateType state, gpointer pmData)
{
  options* lLocalOptions; /* Local option structure */
  gint     lEventID;      /* the list item's associated event type */

  /* don't bother executing this if the widget shouldn't be sensitive */
  if(pmWidget->state == GTK_STATE_INSENSITIVE) return;

  /* Was the data passed correstly? */
  if(!(lLocalOptions = (options*) pmData))
    {
    g_print("Selected event without passing local options! \n");
    exit(1);
    }

  /* retireve the event type index */
  lEventID = (gint) gtk_object_get_data(GTK_OBJECT(pmWidget), EVENT_TYPE_DATA);

  /* is this a valid index? */
  if(lEventID >= 0 && lEventID <= MaxEventID)
    {
    /* Are we indicating which event types to omit? */
    if(lLocalOptions->Omit)
      {
      /* Set the Omit vector accordingly */
      if(pmWidget->state == GTK_STATE_SELECTED)
	ltt_set_bit(lEventID, &(lLocalOptions->OmitMask));
      else
	ltt_clear_bit(lEventID, &(lLocalOptions->OmitMask));
      }

    /* Are we indicating which event types to include? */
    if(lLocalOptions->Trace)
      {
      /* Set the Trace vector accordingly */
      if(pmWidget->state == GTK_STATE_SELECTED)
	ltt_set_bit(lEventID, &(lLocalOptions->TraceMask));
      else
	ltt_clear_bit(lEventID, &(lLocalOptions->TraceMask));
      }
    }
}

/******************************************************************
 * Function :
 *    ISHSelectProc()
 * Description :
 * Parameters :
 * Return values :
 * History :
 * Note :
 ******************************************************************/
void ISHSelectProc(GtkWidget* pmWidget, gpointer pmData)
{
  options* lLocalOptions; /* System view pointer */
  process* pProc;        /* the menu item's associated process */

  if(!(lLocalOptions = (options*) pmData))
    {
    g_print("Selected process without passing local options! \n");
    exit(1);
    }

  /* retireve the process pointer */
  if(((pProc = (process*) gtk_object_get_data(GTK_OBJECT(pmWidget), OPT_MENU_DATA)) != NULL))
    /* Set it in our temporary options structure */
    lLocalOptions->PID = pProc->PID;
  else
    /* default to tracing the kernel */
    lLocalOptions->PID = 0;
}

/******************************************************************
 * Function :
 *    ISHSelectOptionsCheckBox()
 * Description :
 * Parameters :
 * Return values :
 * History :
 * Note :
 ******************************************************************/
void ISHSelectOptionsCheckBox(GtkWidget* pmWidget, gpointer pmData)
{
  gint* ItemToSet; /* Pointer to the item to be set in LocalOptions */

  if(!(ItemToSet = (gint*) pmData))
    {
    g_print("Internal error: select options check box called without ItemToSet \n");
    exit(1);
    }

  *ItemToSet = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(pmWidget));
}

/**********************************************************************************/
/******************************* Internal functions *******************************/
/**********************************************************************************/
/******************************************************************
 * Function :
 * Description :
 * Parameters :
 * Return values :
 * History :
 * Note :
 ******************************************************************/
void DTFIAddEventTypeItem(GtkWidget* List, gchar* Label, gint EventID, options* LocalOptions)
{
  GtkWidget* NewListItem; /* the new list itme to create */

  /* Create the new list item */
  NewListItem = gtk_list_item_new_with_label(Label);

  /* Memorize the EventID */
  gtk_object_set_data(GTK_OBJECT(NewListItem), EVENT_TYPE_DATA, (gpointer) EventID);

  /* Add the item to the list */
  gtk_container_add(GTK_CONTAINER(List), NewListItem);

  /* Make the menu item visible */
  gtk_widget_show(NewListItem);
}

/******************************************************************
 * Function :
 * Description :
 * Parameters :
 * Return values :
 * History :
 * Note :
 ******************************************************************/
void DTFIAddMenuItem(GtkWidget* pmMenu, options* LocalOptions, process* pProc)
{
  GtkWidget* NewMenuItem; /* The new menu item to add */
  gchar      lString[256]; /* Temporary string to build menu */

  /* Create list item text */
  if(pProc->Command != NULL)
    sprintf(lString, "%s", pProc->Command);
  else 
    if(pProc->PID == 0)
      sprintf(lString, "Kernel");
    else
      sprintf(lString, "Unnamed child");

  sprintf(lString, "%s (%d)", lString, pProc->PID);

  /* Create the new menu item */
  NewMenuItem = gtk_menu_item_new_with_label(lString);

  /* If it should be the  default menu item */
  if(pProc->PID == LocalOptions->PID)
    /* Prepend the menu item to the menu */
    gtk_menu_prepend(GTK_MENU(pmMenu), NewMenuItem);
  else
    /* Append the menu item to the menu */
    gtk_menu_append(GTK_MENU(pmMenu), NewMenuItem);

  /* Memorize the associated process */
  gtk_object_set_data(GTK_OBJECT(NewMenuItem), OPT_MENU_DATA, pProc);

  /* Connect selection signal */
  gtk_signal_connect(GTK_OBJECT(NewMenuItem),
		     "activate",
		     GTK_SIGNAL_FUNC(ISHSelectProc),
		     LocalOptions);

  /* Make the menu item visible */
  gtk_widget_show(NewMenuItem);

}

/******************************************************************
 * Function :
 * Description :
 * Parameters :
 * Return values :
 * History :
 * Note :
 ******************************************************************/
void DTFIFileSelectDestroy(GtkWidget* pmWidget, gpointer pmData)
{
  dumpToFileWindow*  pDTFWin;  /* The window for whom this was called */

  /* Do we have anything meaningfull */
  if((pDTFWin = (dumpToFileWindow*) pmData) == NULL)
    {
    g_print("Internal error: Destroy File Select without Dump To File Window \n");
    exit(1);
    }

  /* Delete the file selection  */
  gtk_widget_destroy(pDTFWin->FileSelect);

  pDTFWin->FileSelect = NULL;
}

/******************************************************************
 * Function :
 * Description :
 * Parameters :
 * Return values :
 * History :
 * Note :
 ******************************************************************/
void DTFIFileSelectOK(GtkWidget* pmWidget, gpointer pmData)
{
  dumpToFileWindow*  pDTFWin;  /* The window for whom this was called */

  /* Do we have anything meaningfull */
  if((pDTFWin = (dumpToFileWindow*) pmData) == NULL)
    {
    g_print("Internal error: OK File Select without Open Trace Window \n");
    exit(1);
    }

  /* Display the filename in the prof file text entry */
  gtk_entry_set_text(GTK_ENTRY(pDTFWin->FileTextEntry),
		     gtk_file_selection_get_filename(GTK_FILE_SELECTION(pDTFWin->FileSelect)));
}

/******************************************************************
 * Function :
 * Description :
 * Parameters :
 * Return values :
 * History :
 * Note :
 ******************************************************************/
void DTFIFileBrowse(dumpToFileWindow* pmDTFWin)
{
  GtkWidget*   pFileSelect;    /* The file select window */

  /* Don't open more than one file selection window */
  if(pmDTFWin->FileSelect != NULL)
    {
    gtk_widget_hide(pmDTFWin->FileSelect);
    gtk_widget_show(pmDTFWin->FileSelect);
    return;
    }

  /* Create a new file selection dialog */
  pFileSelect = pmDTFWin->FileSelect = gtk_file_selection_new("Dump to file...");

  /* Connect the correct signals */
  gtk_signal_connect(GTK_OBJECT(pFileSelect),
		     "destroy",
		     GTK_SIGNAL_FUNC(DTFIFileSelectDestroy),
		     pmDTFWin);
  gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(pFileSelect)->ok_button),
		     "clicked",
		     GTK_SIGNAL_FUNC(DTFIFileSelectOK),
		     pmDTFWin);
  gtk_signal_connect_object(GTK_OBJECT(GTK_FILE_SELECTION(pFileSelect)->ok_button),
			    "clicked",
			    GTK_SIGNAL_FUNC(gtk_widget_destroy),
			    GTK_OBJECT(pFileSelect));
  gtk_signal_connect_object(GTK_OBJECT(GTK_FILE_SELECTION(pFileSelect)->cancel_button),
			    "clicked",
			    GTK_SIGNAL_FUNC(gtk_widget_destroy),
			    GTK_OBJECT(pFileSelect));

  /* Display file selection window in middle of screen */
  gtk_window_set_position(GTK_WINDOW(pFileSelect), GTK_WIN_POS_CENTER);

  /* Keep file selection on the foreground */
  gtk_window_set_transient_for(GTK_WINDOW(pFileSelect), 
			       GTK_WINDOW(pmDTFWin->Window));

  /* Show the file selection window */
  gtk_widget_show(pFileSelect);
}

/******************************************************************
 * Function :
 * Description :
 * Parameters :
 * Return values :
 * History :
 * Note :
 ******************************************************************/
void DTFISetInitialValues(dumpToFileWindow* pmDTFWin)
{
  process* Navigator;   /* Temporary pointer to navigate through process list */ 
  gchar    lstring[80]; /* Temporary building string */

  /* Populate lists */

  /* Allocate the options menu list */
  for(Navigator = ((systemView*)(pmDTFWin->SysView))->System->Processes; Navigator != NULL; Navigator = Navigator->Next)
  {
    DTFIAddMenuItem(pmDTFWin->ProcListMenu, pmDTFWin->LocalOptions, Navigator);
  }

  /* Set the process tab's option menu */
  gtk_option_menu_set_menu (GTK_OPTION_MENU(pmDTFWin->Proclist), pmDTFWin->ProcListMenu);

  /* Populate event type list */
  DTFIAddEventTypeItem(pmDTFWin->EventList, "Trace beginning",
		       TRACE_START, pmDTFWin->LocalOptions);
  DTFIAddEventTypeItem(pmDTFWin->EventList, "System call entered",
		       TRACE_SYSCALL_ENTRY, pmDTFWin->LocalOptions);
  DTFIAddEventTypeItem(pmDTFWin->EventList, "System call exited",
		       TRACE_SYSCALL_EXIT, pmDTFWin->LocalOptions);
  DTFIAddEventTypeItem(pmDTFWin->EventList, "Trap entered",
		       TRACE_TRAP_ENTRY, pmDTFWin->LocalOptions);
  DTFIAddEventTypeItem(pmDTFWin->EventList, "Trap exited",
		       TRACE_TRAP_EXIT, pmDTFWin->LocalOptions);
  DTFIAddEventTypeItem(pmDTFWin->EventList, "IRQ entered",
		       TRACE_IRQ_ENTRY, pmDTFWin->LocalOptions);
  DTFIAddEventTypeItem(pmDTFWin->EventList, "IRQ exited",
		       TRACE_IRQ_EXIT, pmDTFWin->LocalOptions);
  DTFIAddEventTypeItem(pmDTFWin->EventList, "Scheduling change",
		       TRACE_SCHEDCHANGE, pmDTFWin->LocalOptions);
  DTFIAddEventTypeItem(pmDTFWin->EventList, "Kernel timer routine called",
		       TRACE_KERNEL_TIMER, pmDTFWin->LocalOptions);
  DTFIAddEventTypeItem(pmDTFWin->EventList, "Soft IRQ management",
		       TRACE_SOFT_IRQ, pmDTFWin->LocalOptions);
  DTFIAddEventTypeItem(pmDTFWin->EventList, "Process management",
		       TRACE_PROCESS, pmDTFWin->LocalOptions);
  DTFIAddEventTypeItem(pmDTFWin->EventList, "File system",
		       TRACE_FILE_SYSTEM, pmDTFWin->LocalOptions);
  DTFIAddEventTypeItem(pmDTFWin->EventList, "Timer management",
		       TRACE_TIMER, pmDTFWin->LocalOptions);
  DTFIAddEventTypeItem(pmDTFWin->EventList, "Memory management",
		       TRACE_MEMORY, pmDTFWin->LocalOptions);
  DTFIAddEventTypeItem(pmDTFWin->EventList, "Socket communication",
		       TRACE_SOCKET, pmDTFWin->LocalOptions);
  DTFIAddEventTypeItem(pmDTFWin->EventList, "Inter-process communication",
		       TRACE_IPC, pmDTFWin->LocalOptions);
  DTFIAddEventTypeItem(pmDTFWin->EventList, "Network communication",
		       TRACE_NETWORK, pmDTFWin->LocalOptions);
  DTFIAddEventTypeItem(pmDTFWin->EventList, "Creation of custom event",
		       TRACE_NEW_EVENT, pmDTFWin->LocalOptions);
  DTFIAddEventTypeItem(pmDTFWin->EventList, "Custom event occurrence",
		       TRACE_CUSTOM, pmDTFWin->LocalOptions);
#if SUPP_RTAI
  /* Is this an RTAI trace */
  if(((systemView*)(pmDTFWin->SysView))->EventDB->SystemType == TRACE_SYS_TYPE_RTAI_LINUX)
    {
    DTFIAddEventTypeItem(pmDTFWin->EventList, "RTAI mount",
			 TRACE_RTAI_MOUNT, pmDTFWin->LocalOptions);
    DTFIAddEventTypeItem(pmDTFWin->EventList, "RTAI un-mount",
			 TRACE_RTAI_UMOUNT, pmDTFWin->LocalOptions);
    DTFIAddEventTypeItem(pmDTFWin->EventList, "RTAI global IRQ entry",
			 TRACE_RTAI_GLOBAL_IRQ_ENTRY, pmDTFWin->LocalOptions);
    DTFIAddEventTypeItem(pmDTFWin->EventList, "RTAI global IRQ exit",
			 TRACE_RTAI_GLOBAL_IRQ_EXIT, pmDTFWin->LocalOptions);
    DTFIAddEventTypeItem(pmDTFWin->EventList, "RTAI CPU-own IRQ entry",
			 TRACE_RTAI_OWN_IRQ_ENTRY, pmDTFWin->LocalOptions);
    DTFIAddEventTypeItem(pmDTFWin->EventList, "RTAI CPU-own IRQ exit",
			 TRACE_RTAI_OWN_IRQ_EXIT, pmDTFWin->LocalOptions);
    DTFIAddEventTypeItem(pmDTFWin->EventList, "RTAI trap entry",
			 TRACE_RTAI_TRAP_ENTRY, pmDTFWin->LocalOptions);
    DTFIAddEventTypeItem(pmDTFWin->EventList, "RTAI trap exit",
			 TRACE_RTAI_TRAP_EXIT, pmDTFWin->LocalOptions);
    DTFIAddEventTypeItem(pmDTFWin->EventList, "RTAI SRQ entry",
			 TRACE_RTAI_SRQ_ENTRY, pmDTFWin->LocalOptions);
    DTFIAddEventTypeItem(pmDTFWin->EventList, "RTAI SRQ exit",
			 TRACE_RTAI_SRQ_EXIT, pmDTFWin->LocalOptions);
    DTFIAddEventTypeItem(pmDTFWin->EventList, "RTAI switch to Linux",
			 TRACE_RTAI_SWITCHTO_LINUX, pmDTFWin->LocalOptions);
    DTFIAddEventTypeItem(pmDTFWin->EventList, "RTAI switch to RT",
			 TRACE_RTAI_SWITCHTO_RT, pmDTFWin->LocalOptions);
    DTFIAddEventTypeItem(pmDTFWin->EventList, "RTAI scheduling change",
			 TRACE_RTAI_SCHED_CHANGE, pmDTFWin->LocalOptions);
    DTFIAddEventTypeItem(pmDTFWin->EventList, "RTAI task management",
			 TRACE_RTAI_TASK, pmDTFWin->LocalOptions);
    DTFIAddEventTypeItem(pmDTFWin->EventList, "RTAI timer management",
			 TRACE_RTAI_TIMER, pmDTFWin->LocalOptions);
    DTFIAddEventTypeItem(pmDTFWin->EventList, "RTAI semaphore communication",
			 TRACE_RTAI_SEM, pmDTFWin->LocalOptions);
    DTFIAddEventTypeItem(pmDTFWin->EventList, "RTAI message communication",
			 TRACE_RTAI_MSG, pmDTFWin->LocalOptions);
    DTFIAddEventTypeItem(pmDTFWin->EventList, "RTAI RPC communication",
			 TRACE_RTAI_RPC, pmDTFWin->LocalOptions);
    DTFIAddEventTypeItem(pmDTFWin->EventList, "RTAI message-box communication",
			 TRACE_RTAI_MBX, pmDTFWin->LocalOptions);
    DTFIAddEventTypeItem(pmDTFWin->EventList, "RTAI FIFO communication",
			 TRACE_RTAI_FIFO, pmDTFWin->LocalOptions);
    DTFIAddEventTypeItem(pmDTFWin->EventList, "RTAI shared-memory mangement",
			 TRACE_RTAI_SHM, pmDTFWin->LocalOptions);
    DTFIAddEventTypeItem(pmDTFWin->EventList, "RTAI POSIX layer",
			 TRACE_RTAI_POSIX, pmDTFWin->LocalOptions);
    DTFIAddEventTypeItem(pmDTFWin->EventList, "RTAI LXRT layer",
			 TRACE_RTAI_LXRT, pmDTFWin->LocalOptions);
    DTFIAddEventTypeItem(pmDTFWin->EventList, "RTAI LXRT-Informed layer",
			 TRACE_RTAI_LXRTI, pmDTFWin->LocalOptions);
    }
#endif

  /* Set initial values for the widgets */

  /* Process radio buttons */
  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pmDTFWin->JustThisProc), 
			       pmDTFWin->LocalOptions->TracePID);
  ISHSelectProcRadioButton(pmDTFWin->JustThisProc, pmDTFWin);

  /* Summarize CheckBox */
  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pmDTFWin->PrintEvents),
			       !pmDTFWin->LocalOptions->Summarize);
  ISHSelectEventCheckBox(pmDTFWin->PrintEvents, pmDTFWin);

  /* Event radio buttons */
  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pmDTFWin->OmitTheseEvents), 
			       pmDTFWin->LocalOptions->Omit);
  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pmDTFWin->TraceTheseEvents), 
			       pmDTFWin->LocalOptions->Trace);
  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pmDTFWin->TraceAllEvents),
			       !(pmDTFWin->LocalOptions->Omit || pmDTFWin->LocalOptions->Trace));

  /* Depending on which toggle button is selected, simulate the proper mouse click */
  if(pmDTFWin->LocalOptions->Omit)
    ISHSelectEventRadioButton(pmDTFWin->OmitTheseEvents, pmDTFWin);

  else
    ISHSelectEventRadioButton(pmDTFWin->TraceTheseEvents, pmDTFWin);

  /* SMP radio buttons */
  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pmDTFWin->JustThisCPU), 
			       pmDTFWin->LocalOptions->TraceCPUID);
  ISHSelectSMPRadioButton(pmDTFWin->JustThisCPU, pmDTFWin);

  /* Set the CPUid entry */
  sprintf(lstring, "%d", pmDTFWin->LocalOptions->CPUID);
  gtk_entry_set_text(GTK_ENTRY(pmDTFWin->CPUIDEntry), lstring);

  /* Misc. options */
  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pmDTFWin->AccountSysCalls),
			       pmDTFWin->LocalOptions->AcctSysCall);
  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pmDTFWin->ForgetTime),
			       pmDTFWin->LocalOptions->ForgetTime);
  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pmDTFWin->ForgetString),
			       pmDTFWin->LocalOptions->ForgetString);
  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pmDTFWin->ForgetDataLen),
			       pmDTFWin->LocalOptions->ForgetDataLen);
  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pmDTFWin->ForgetPID),
			       pmDTFWin->LocalOptions->ForgetPID);
  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pmDTFWin->ForgetCPUID),
			       pmDTFWin->LocalOptions->ForgetCPUID);

}

/**********************************************************************************/
/**************************** Signal handling functions ***************************/
/**********************************************************************************/
/******************************************************************
 * Function :
 * Description :
 * Parameters :
 * Return values :
 * History :
 * Note :
 ******************************************************************/
gint DTFSHDeleteEvent(GtkWidget* pmWidget, GdkEvent* pmEvent, gpointer pmData)
{
  /* Close it */
  return(FALSE);
}

/******************************************************************
 * Function :
 * Description :
 * Parameters :
 * Return values :
 * History :
 * Note :
 ******************************************************************/
void DTFSHDestroy(GtkWidget* pmWidget, gpointer pmData)
{
  dumpToFileWindow*  pDTFWin;  /* The window for whom this was called */

  /* Do we have anything meaningfull */
  if((pDTFWin = (dumpToFileWindow*) pmData) == NULL)
    {
    g_print("Internal error: Callback without Open Trace Window \n");
    exit(1);
    }

  /* Call on the cancel callback */
  pDTFWin->CBCancel(pDTFWin->SysView);
}

/******************************************************************
 * Function :
 * Description :
 * Parameters :
 * Return values :
 * History :
 * Note :
 ******************************************************************/
void DTFSHFileBrowse(GtkWidget* pmWidget, gpointer pmData)
{
  DTFIFileBrowse(((dumpToFileWindow*) pmData));
}

/******************************************************************
 * Function :
 * Description :
 * Parameters :
 * Return values :
 * History :
 * Note :
 ******************************************************************/
void DTFSHInternalOK(GtkWidget* pmWidget, gpointer pmData)
{
  dumpToFileWindow*  pDTFWin;  /* The window for whom this was called */
  gchar*             FileName; /* pointer to retrieve entry contents */

  /* Do we have anything meaningfull */
  if((pDTFWin = (dumpToFileWindow*) pmData) == NULL)
    {
    g_print("Internal error: Callback without Open Trace Window \n");
    exit(1);
    }

  /* free previously allocated string if there was one */
  free(pDTFWin->LocalOptions->OutputFileName);

  /* Set the new CPU id value */
  pDTFWin->LocalOptions->CPUID = atoi(gtk_entry_get_text(GTK_ENTRY(pDTFWin->CPUIDEntry)));

  /* Set the output filename in the options structure */
  FileName = gtk_entry_get_text(GTK_ENTRY(pDTFWin->FileTextEntry));
  pDTFWin->LocalOptions->OutputFileName = (char*) malloc(strlen(FileName) + 1);
  strcpy(pDTFWin->LocalOptions->OutputFileName, FileName);

  /* Copy the temporary options to the permanent options */
  ((systemView*)(pDTFWin->SysView))->Options = 
    memcpy(((systemView*)(pDTFWin->SysView))->Options, pDTFWin->LocalOptions, sizeof(options));

  /* Call the OK Callback */
  pDTFWin->CBOK(pDTFWin->SysView);
}

/**********************************************************************************/
/******************************* Windowing functions ******************************/
/**********************************************************************************/
/******************************************************************
 * Function :
 * Description :
 * Parameters :
 * Return values :
 * History :
 * Note :
 ******************************************************************/
void DTFConnectSignals(dumpToFileWindow* pmDTFWin)
{
  GList* Navigator; /* Pointer to navigate through list items */

  /* Connect the generic signals */
  gtk_signal_connect(GTK_OBJECT(pmDTFWin->Window),
		     "delete_event",
		     GTK_SIGNAL_FUNC(DTFSHDeleteEvent),
		     pmDTFWin);
  gtk_signal_connect(GTK_OBJECT(pmDTFWin->Window),
		     "destroy",
		     GTK_SIGNAL_FUNC(DTFSHDestroy),
		     pmDTFWin);

  /* connect the event check box */
  gtk_signal_connect(GTK_OBJECT(pmDTFWin->PrintEvents),
		     "toggled",
		     GTK_SIGNAL_FUNC(ISHSelectEventCheckBox),
		     pmDTFWin);

  /* Connect the event radio buttons */
  gtk_signal_connect(GTK_OBJECT(pmDTFWin->TraceAllEvents),
		     "toggled",
		     GTK_SIGNAL_FUNC(ISHSelectEventRadioButton),
		     pmDTFWin);
  gtk_signal_connect(GTK_OBJECT(pmDTFWin->TraceTheseEvents),
		     "toggled",
		     GTK_SIGNAL_FUNC(ISHSelectEventRadioButton),
		     pmDTFWin);
  gtk_signal_connect(GTK_OBJECT(pmDTFWin->OmitTheseEvents),
		     "toggled",
		     GTK_SIGNAL_FUNC(ISHSelectEventRadioButton),
		     pmDTFWin);

  /* Navigate through event type list */
  for(Navigator = GTK_LIST(pmDTFWin->EventList)->children; Navigator; Navigator = Navigator->next)
    /* Connect selection signal */
    gtk_signal_connect(GTK_OBJECT(Navigator->data),
		       "state-changed",
		       GTK_SIGNAL_FUNC(ISHSelectEventType),
		       pmDTFWin->LocalOptions);

  /* Connect the Process radio buttons */
  gtk_signal_connect(GTK_OBJECT(pmDTFWin->TraceAllProc),
		     "toggled",
		     GTK_SIGNAL_FUNC(ISHSelectProcRadioButton),
		     pmDTFWin);
  gtk_signal_connect(GTK_OBJECT(pmDTFWin->JustThisProc),
		     "toggled",
		     GTK_SIGNAL_FUNC(ISHSelectProcRadioButton),
		     pmDTFWin);

  /* Connect the SMP radio buttons */
  gtk_signal_connect(GTK_OBJECT(pmDTFWin->TraceAllCPUs),
		     "toggled",
		     GTK_SIGNAL_FUNC(ISHSelectSMPRadioButton),
		     pmDTFWin);
  gtk_signal_connect(GTK_OBJECT(pmDTFWin->JustThisCPU),
		     "toggled",
		     GTK_SIGNAL_FUNC(ISHSelectSMPRadioButton),
		     pmDTFWin);

  /* Connect the option check boxes */
  gtk_signal_connect(GTK_OBJECT(pmDTFWin->AccountSysCalls),
		     "toggled",
		     GTK_SIGNAL_FUNC(ISHSelectOptionsCheckBox),
		     &pmDTFWin->LocalOptions->AcctSysCall);
  gtk_signal_connect(GTK_OBJECT(pmDTFWin->ForgetTime),
		     "toggled",
		     GTK_SIGNAL_FUNC(ISHSelectOptionsCheckBox),
		     &pmDTFWin->LocalOptions->ForgetTime);
  gtk_signal_connect(GTK_OBJECT(pmDTFWin->ForgetString),
		     "toggled",
		     GTK_SIGNAL_FUNC(ISHSelectOptionsCheckBox),
		     &pmDTFWin->LocalOptions->ForgetString);
  gtk_signal_connect(GTK_OBJECT(pmDTFWin->ForgetDataLen),
		     "toggled",
		     GTK_SIGNAL_FUNC(ISHSelectOptionsCheckBox),
		     &pmDTFWin->LocalOptions->ForgetDataLen);
  gtk_signal_connect(GTK_OBJECT(pmDTFWin->ForgetPID),
		     "toggled",
		     GTK_SIGNAL_FUNC(ISHSelectOptionsCheckBox),
		     &pmDTFWin->LocalOptions->ForgetPID);
  gtk_signal_connect(GTK_OBJECT(pmDTFWin->ForgetCPUID),
		     "toggled",
		     GTK_SIGNAL_FUNC(ISHSelectOptionsCheckBox),
		     &pmDTFWin->LocalOptions->ForgetCPUID);

  /* Connect the Browse buttons */
  gtk_signal_connect(GTK_OBJECT(pmDTFWin->FileBrowse),
		     "clicked",
		     GTK_SIGNAL_FUNC(DTFSHFileBrowse),
		     pmDTFWin);

  /* Connect the Ok and Cancel buttons */
  gtk_signal_connect(GTK_OBJECT(pmDTFWin->OKButton),
		     "clicked",
		     GTK_SIGNAL_FUNC(DTFSHInternalOK),
		     pmDTFWin);
  gtk_signal_connect_object(GTK_OBJECT(pmDTFWin->OKButton),
			    "clicked",
			    GTK_SIGNAL_FUNC(gtk_widget_destroy),
			    GTK_OBJECT(pmDTFWin->Window));
  gtk_signal_connect_object(GTK_OBJECT(pmDTFWin->CancelButton),
			    "clicked",
			    GTK_SIGNAL_FUNC(gtk_widget_destroy),
			    GTK_OBJECT(pmDTFWin->Window));
}

/******************************************************************
 * Function :
 * Description :
 * Parameters :
 * Return values :
 * History :
 * Note :
 ******************************************************************/
void DTFShowDumpToFileWindow(dumpToFileWindow* pmDTFWin)
{
  /* Make OK button default choice */
  gtk_widget_grab_default(pmDTFWin->OKButton);

  /* Show it all to the world */
  gtk_widget_show(pmDTFWin->VBox);
  gtk_widget_show(pmDTFWin->Notebook);
  gtk_widget_show(pmDTFWin->ProcessTable);
  gtk_widget_show(pmDTFWin->EventsVBox);
  gtk_widget_show(pmDTFWin->OptionsVBox);
  gtk_widget_show(pmDTFWin->SMPTable);
  gtk_widget_show(pmDTFWin->FileHBox);
  gtk_widget_show(pmDTFWin->ButtonHBox);
  gtk_widget_show(pmDTFWin->TraceAllProc);
  gtk_widget_show(pmDTFWin->JustThisProc);
  gtk_widget_show(pmDTFWin->Proclist);
  gtk_widget_show(pmDTFWin->PrintEvents);
  gtk_widget_show(pmDTFWin->SelectEventFrame);
  gtk_widget_show(pmDTFWin->SelectEventVBox);
  gtk_widget_show(pmDTFWin->TraceAllEvents);
  gtk_widget_show(pmDTFWin->TraceTheseEvents);
  gtk_widget_show(pmDTFWin->OmitTheseEvents);
  gtk_widget_show(pmDTFWin->ScrolledEventList);
  gtk_widget_show(pmDTFWin->EventList);
  gtk_widget_show(pmDTFWin->TraceAllCPUs);
  gtk_widget_show(pmDTFWin->JustThisCPU);
  gtk_widget_show(pmDTFWin->CPUIDEntry);
  gtk_widget_show(pmDTFWin->AccountSysCalls);
  gtk_widget_show(pmDTFWin->ForgetTime);
  gtk_widget_show(pmDTFWin->ForgetString);
  gtk_widget_show(pmDTFWin->ForgetDataLen);
  gtk_widget_show(pmDTFWin->ForgetPID);
  gtk_widget_show(pmDTFWin->ForgetCPUID);
  gtk_widget_show(pmDTFWin->FileLabel);
  gtk_widget_show(pmDTFWin->FileTextEntry);
  gtk_widget_show(pmDTFWin->FileBrowse);
  gtk_widget_show(pmDTFWin->OKButton);
  gtk_widget_show(pmDTFWin->CancelButton);

  /* Set title */
  gtk_window_set_title(GTK_WINDOW(pmDTFWin->Window), "Dump file options");

  /* Display in the center of screen */
  gtk_window_set_position(GTK_WINDOW(pmDTFWin->Window), GTK_WIN_POS_CENTER);

  /* Make Dump to file window always visible */
  gtk_window_set_transient_for(GTK_WINDOW(pmDTFWin->Window), 
			       GTK_WINDOW(pmDTFWin->ParentWin));

  /* Display it */
  gtk_widget_show(pmDTFWin->Window);

}

/******************************************************************
 * Function :
 * Description :
 * Parameters :
 * Return values :
 * History :
 * Note :
 ******************************************************************/
dumpToFileWindow* DTFCreateDumpToFileWindow(gpointer      pmSysView,
					    GtkWidget*    pmParentWin,
					    _DTFCBOK*     pmCBOK,
					    _DTFCBCancel* pmCBCancel)
{
  dumpToFileWindow* pDTFWin;     /* Dump to file window */

  /* Create a new dump to file window */
  pDTFWin = (dumpToFileWindow*) g_malloc(sizeof(dumpToFileWindow));

  /* Initialize basic variables */
  pDTFWin->FileSelect = NULL;

  /* Put the given data in the right place */
  pDTFWin->SysView  = pmSysView;
  pDTFWin->ParentWin= pmParentWin;
  pDTFWin->CBOK     = pmCBOK;
  pDTFWin->CBCancel = pmCBCancel;

  /* Create a local copy of the options to be configured */
  pDTFWin->LocalOptions = (options*) g_malloc(sizeof(options));
  pDTFWin->LocalOptions = memcpy(pDTFWin->LocalOptions, ((systemView*)(pmSysView))->Options, sizeof(options));

  /* Build the window */
  pDTFWin->Window = gtk_window_new(GTK_WINDOW_DIALOG);
  pDTFWin->VBox   = gtk_vbox_new(FALSE, TRUE);
  gtk_container_add(GTK_CONTAINER(pDTFWin->Window), pDTFWin->VBox);

  /* Build the notebook object and pack it */
  pDTFWin->Notebook = gtk_notebook_new();
  gtk_notebook_set_tab_pos(GTK_NOTEBOOK(pDTFWin->Notebook), GTK_POS_LEFT);
  gtk_box_pack_start(GTK_BOX(pDTFWin->VBox), pDTFWin->Notebook, TRUE, TRUE, 5);

  /* Build the notebook Tabs and containers and pack them */
  pDTFWin->ProcessTable = gtk_table_new(2, 2, FALSE);
  pDTFWin->EventsVBox   = gtk_vbox_new(FALSE, 0);
  pDTFWin->SMPTable     = gtk_table_new(2, 2, FALSE);
  pDTFWin->OptionsVBox  = gtk_vbox_new(FALSE, 5);
  gtk_notebook_append_page(GTK_NOTEBOOK(pDTFWin->Notebook), 
			   pDTFWin->ProcessTable,
			   gtk_label_new("Processes"));
  gtk_notebook_append_page(GTK_NOTEBOOK(pDTFWin->Notebook),
			   pDTFWin->EventsVBox,
			   gtk_label_new("Events"));
  gtk_notebook_append_page(GTK_NOTEBOOK(pDTFWin->Notebook),
			   pDTFWin->SMPTable,
			   gtk_label_new("SMP"));
  gtk_notebook_append_page(GTK_NOTEBOOK(pDTFWin->Notebook),
			   pDTFWin->OptionsVBox, 
			   gtk_label_new("Options"));

  /* Allocate HBoxes to put the rest of the widgets and pack them */
  pDTFWin->FileHBox   = gtk_hbox_new(FALSE, 0);
  pDTFWin->ButtonHBox = gtk_hbox_new(FALSE, 0);
  gtk_box_pack_start(GTK_BOX(pDTFWin->VBox), pDTFWin->FileHBox, FALSE, TRUE, 5);
  gtk_box_pack_start(GTK_BOX(pDTFWin->VBox), pDTFWin->ButtonHBox, FALSE, TRUE, 0);

  /* Build Processes tab widgets and pack them */
  pDTFWin->ProcRadioGroup = NULL;
  pDTFWin->TraceAllProc   = gtk_radio_button_new_with_label(pDTFWin->ProcRadioGroup, "Trace all processes");
  pDTFWin->ProcRadioGroup = gtk_radio_button_group(GTK_RADIO_BUTTON(pDTFWin->TraceAllProc));
  pDTFWin->JustThisProc   = gtk_radio_button_new_with_label(pDTFWin->ProcRadioGroup, "Only trace process");
  pDTFWin->ProcRadioGroup = gtk_radio_button_group(GTK_RADIO_BUTTON(pDTFWin->JustThisProc));
  pDTFWin->Proclist       = gtk_option_menu_new();
  pDTFWin->ProcListMenu   = gtk_menu_new();
  gtk_table_attach(GTK_TABLE(pDTFWin->ProcessTable), pDTFWin->TraceAllProc, 0, 2, 0, 1,
		   GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 5);
  gtk_table_attach(GTK_TABLE(pDTFWin->ProcessTable), pDTFWin->JustThisProc, 0, 1, 1, 2,
		   GTK_FILL, GTK_FILL, 0, 5);
  gtk_table_attach(GTK_TABLE(pDTFWin->ProcessTable), pDTFWin->Proclist, 1, 2, 1, 2,
		   GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 5);

  /* Build main Events tab widgets and pack them */
  pDTFWin->PrintEvents      = gtk_check_button_new_with_label("Print trace events");
  pDTFWin->SelectEventFrame = gtk_frame_new("Events to print");
  pDTFWin->SelectEventVBox  = gtk_vbox_new(FALSE, 0);
  gtk_box_pack_start(GTK_BOX(pDTFWin->EventsVBox), pDTFWin->PrintEvents, FALSE, TRUE, 5);
  gtk_box_pack_start(GTK_BOX(pDTFWin->EventsVBox), pDTFWin->SelectEventFrame, TRUE, TRUE, 5);
  gtk_container_add(GTK_CONTAINER(pDTFWin->SelectEventFrame), pDTFWin->SelectEventVBox);

  /* Build Event selection frame widgets and pack them */
  pDTFWin->EventRadioGroup   = NULL;
  pDTFWin->TraceAllEvents    = gtk_radio_button_new_with_label(pDTFWin->EventRadioGroup, "Trace all events");
  pDTFWin->EventRadioGroup   = gtk_radio_button_group(GTK_RADIO_BUTTON(pDTFWin->TraceAllEvents));
  pDTFWin->TraceTheseEvents  = gtk_radio_button_new_with_label(pDTFWin->EventRadioGroup, "Trace these events:");
  pDTFWin->EventRadioGroup   = gtk_radio_button_group(GTK_RADIO_BUTTON(pDTFWin->TraceTheseEvents));
  pDTFWin->OmitTheseEvents   = gtk_radio_button_new_with_label(pDTFWin->EventRadioGroup, "Omit these events:");
  pDTFWin->EventRadioGroup   = gtk_radio_button_group(GTK_RADIO_BUTTON(pDTFWin->OmitTheseEvents));
  pDTFWin->ScrolledEventList = gtk_scrolled_window_new(NULL, NULL);
  pDTFWin->EventList         = gtk_list_new();
  gtk_container_set_border_width(GTK_CONTAINER(pDTFWin->ScrolledEventList), 5);
  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(pDTFWin->ScrolledEventList),
				 GTK_POLICY_AUTOMATIC,
				 GTK_POLICY_AUTOMATIC);
  gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(pDTFWin->ScrolledEventList),
					pDTFWin->EventList);
  gtk_box_pack_start(GTK_BOX(pDTFWin->SelectEventVBox), pDTFWin->TraceAllEvents, FALSE, TRUE, 0);
  gtk_box_pack_start(GTK_BOX(pDTFWin->SelectEventVBox), pDTFWin->TraceTheseEvents, FALSE, TRUE, 0);
  gtk_box_pack_start(GTK_BOX(pDTFWin->SelectEventVBox), pDTFWin->OmitTheseEvents, FALSE, TRUE, 0);
  gtk_box_pack_start(GTK_BOX(pDTFWin->SelectEventVBox), pDTFWin->ScrolledEventList, TRUE, TRUE, 0);
  gtk_list_set_selection_mode(GTK_LIST(pDTFWin->EventList), GTK_SELECTION_MULTIPLE);

  /* Build SMP tab widgets and pack them */
  pDTFWin->SMPRadioGroup = NULL;
  pDTFWin->TraceAllCPUs  = gtk_radio_button_new_with_label(pDTFWin->SMPRadioGroup, "Trace all CPUs");
  pDTFWin->SMPRadioGroup = gtk_radio_button_group(GTK_RADIO_BUTTON(pDTFWin->TraceAllCPUs));
  pDTFWin->JustThisCPU   = gtk_radio_button_new_with_label(pDTFWin->SMPRadioGroup, "Only trace CPU no.:");
  pDTFWin->SMPRadioGroup = gtk_radio_button_group(GTK_RADIO_BUTTON(pDTFWin->JustThisCPU));
  pDTFWin->CPUIDEntry    = gtk_entry_new();
  gtk_table_attach(GTK_TABLE(pDTFWin->SMPTable), pDTFWin->TraceAllCPUs, 0, 2, 0, 1,
		   GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 5);
  gtk_table_attach(GTK_TABLE(pDTFWin->SMPTable), pDTFWin->JustThisCPU, 0, 1, 1, 2,
		   GTK_FILL, GTK_FILL, 0, 5);
  gtk_table_attach(GTK_TABLE(pDTFWin->SMPTable), pDTFWin->CPUIDEntry, 1, 2, 1, 2,
		   GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 5);

  /* Build Options tab widgets and pack them */
  pDTFWin->AccountSysCalls = gtk_check_button_new_with_label("Account time spent in system calls");
  pDTFWin->ForgetTime      = gtk_check_button_new_with_label("Do not print event times");
  pDTFWin->ForgetString    = gtk_check_button_new_with_label("Do not print event description strings");
  pDTFWin->ForgetDataLen   = gtk_check_button_new_with_label("Do not print length of event data entries");
  pDTFWin->ForgetPID       = gtk_check_button_new_with_label("Do not print process identifiers");
  pDTFWin->ForgetCPUID     = gtk_check_button_new_with_label("Do not print CPU identifiers");
  gtk_box_pack_start(GTK_BOX(pDTFWin->OptionsVBox), pDTFWin->AccountSysCalls, FALSE, TRUE, 5);
  gtk_box_pack_start(GTK_BOX(pDTFWin->OptionsVBox), pDTFWin->ForgetTime,      FALSE, TRUE, 5);
  gtk_box_pack_start(GTK_BOX(pDTFWin->OptionsVBox), pDTFWin->ForgetString,    FALSE, TRUE, 5);
  gtk_box_pack_start(GTK_BOX(pDTFWin->OptionsVBox), pDTFWin->ForgetDataLen,   FALSE, TRUE, 5);
  gtk_box_pack_start(GTK_BOX(pDTFWin->OptionsVBox), pDTFWin->ForgetPID,       FALSE, TRUE, 5);
  gtk_box_pack_start(GTK_BOX(pDTFWin->OptionsVBox), pDTFWin->ForgetCPUID,     FALSE, TRUE, 5);

  /* Create the label and pack it */
  pDTFWin->FileLabel = gtk_label_new("Dump to file: ");
  gtk_widget_set_usize(pDTFWin->FileLabel, 80, 20);
  gtk_box_pack_start(GTK_BOX(pDTFWin->FileHBox), pDTFWin->FileLabel, FALSE, TRUE, 0);

  /* Create text entry and pack it */
  pDTFWin->FileTextEntry = gtk_entry_new();
  gtk_box_pack_start(GTK_BOX(pDTFWin->FileHBox), pDTFWin->FileTextEntry, TRUE, TRUE, 0);

  /* Create browse button and pack it */
  pDTFWin->FileBrowse = gtk_button_new_with_label("Browse");
  gtk_box_pack_start(GTK_BOX(pDTFWin->FileHBox), pDTFWin->FileBrowse, FALSE, TRUE, 0);

  /* Create OK and cancel buttons and pack them */
  pDTFWin->OKButton     = gtk_button_new_with_label("OK");
  pDTFWin->CancelButton = gtk_button_new_with_label("Cancel");
  GTK_WIDGET_SET_FLAGS(pDTFWin->OKButton, GTK_CAN_DEFAULT);  /* Allow OK button to be default */
  gtk_box_pack_start(GTK_BOX(pDTFWin->ButtonHBox), pDTFWin->OKButton, TRUE, TRUE, 0);
  gtk_box_pack_start(GTK_BOX(pDTFWin->ButtonHBox), pDTFWin->CancelButton, TRUE, TRUE, 0);

  /* Set initial widget values and populate lists */
  DTFISetInitialValues(pDTFWin);

  /* Give it to the caller */
  return pDTFWin;
}

/******************************************************************
 * Function :
 * Description :
 * Parameters :
 * Return values :
 * History :
 * Note :
 ******************************************************************/
void DTFDestroyDumpToFileWindow(dumpToFileWindow* pmDTFWin)
{
  /* Is the file select window open */
  if(pmDTFWin->FileSelect != NULL)
    gtk_widget_destroy(pmDTFWin->FileSelect);


  /* Do we still hold a local copy of the options to set? */
  if(pmDTFWin->LocalOptions)
    g_free(pmDTFWin->LocalOptions);

  /* Destroy the window */
  gtk_widget_destroy(pmDTFWin->Window);

  /* Free space used by structure */
  g_free(pmDTFWin);
}