forked from cpiger/vimgdb-for-vim7.3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvim73.patch
11570 lines (11494 loc) · 311 KB
/
vim73.patch
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
diff -uNr vim73old/src/auto/configure vim73/src/auto/configure
--- vim73old/src/auto/configure 2010-08-13 22:17:15.000000000 +0800
+++ vim73/src/auto/configure 2011-04-25 09:08:36.000000000 +0800
@@ -603,6 +603,8 @@
HANGULIN_SRC
GUI_X_LIBS
GUITYPE
+GDB_SRC
+GDB_OBJ
GUI_LIB_LOC
GUI_INC_LOC
NARROW_PROTO
@@ -770,6 +772,7 @@
enable_cscope
enable_workshop
enable_netbeans
+enable_gdb
enable_sniff
enable_multibyte
enable_hangulinput
@@ -1430,6 +1433,7 @@
--enable-rubyinterp Include Ruby interpreter.
--enable-cscope Include cscope interface.
--enable-workshop Include Sun Visual Workshop support.
+ --enable-gdb Include GDB support.
--disable-netbeans Disable NetBeans integration support.
--enable-sniff Include Sniff interface.
--enable-multibyte Include multibyte editing support.
@@ -6241,6 +6245,18 @@
fi
+echo "$as_me:$LINENO: checking --enable-gdb argument" >&5
+echo $ECHO_N "checking --enable-gdb argument... $ECHO_C" >&6
+# Check whether --enable-gdb or --disable-gdb was given.
+if test "${enable_gdb+set}" = set; then
+ enableval="$enable_gdb"
+
+else
+ enable_gdb="no"
+fi;
+echo "$as_me:$LINENO: result: $enable_gdb" >&5
+echo "${ECHO_T}$enable_gdb" >&6
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking --enable-workshop argument" >&5
$as_echo_n "checking --enable-workshop argument... " >&6; }
# Check whether --enable-workshop was given.
@@ -8600,6 +8616,22 @@
+if test "$enable_gdb" = "yes"; then
+ cat >>confdefs.h <<\_ACEOF
+#define FEAT_GDB 1
+_ACEOF
+
+ if test "x$GUITYPE" = "xNONE"; then
+ GDB_SRC="gdb.c clewn/gdb_lvl2.c clewn/gdb_lvl3.c clewn/misc.c clewn/obstack.c pty.c"
+ GDB_OBJ="objects/gdb.o objects/gdb_lvl2.o objects/gdb_lvl3.o objects/misc.o objects/obstack.o objects/pty.o"
+ else
+ GDB_SRC="gdb.c clewn/gdb_lvl2.c clewn/gdb_lvl3.c clewn/misc.c clewn/obstack.c"
+ GDB_OBJ="objects/gdb.o objects/gdb_lvl2.o objects/gdb_lvl3.o objects/misc.o objects/obstack.o"
+ fi
+
+
+fi
+
if test "$enable_workshop" = "yes" -a -n "$SKIP_MOTIF"; then
as_fn_error "cannot use workshop without Motif" "$LINENO" 5
diff -uNr vim73old/src/buffer.c vim73/src/buffer.c
--- vim73old/src/buffer.c 2010-08-13 17:14:35.000000000 +0800
+++ vim73/src/buffer.c 2011-04-25 09:08:36.000000000 +0800
@@ -624,6 +624,9 @@
#ifdef FEAT_AUTOCMD
aubuflocal_remove(buf);
#endif
+#ifdef FEAT_GDB
+ gdb_buffer_free(gdb, buf);
+#endif
vim_free(buf);
}
@@ -5173,7 +5176,7 @@
newsign->lnum = lnum;
newsign->typenr = typenr;
newsign->next = next;
-#ifdef FEAT_NETBEANS_INTG
+#if defined(FEAT_NETBEANS_INTG) || defined(FEAT_GDB)
newsign->prev = prev;
if (next != NULL)
next->prev = newsign;
@@ -5219,12 +5222,12 @@
return;
}
else if (
-#ifndef FEAT_NETBEANS_INTG /* keep signs sorted by lnum */
+#if !defined(FEAT_NETBEANS_INTG) && !defined(FEAT_GDB) /* keep signs sorted by lnum */
id < 0 &&
#endif
lnum < sign->lnum)
{
-#ifdef FEAT_NETBEANS_INTG /* insert new sign at head of list for this lnum */
+#if defined(FEAT_NETBEANS_INTG) || defined(FEAT_GDB) /* insert new sign at head of list for this lnum */
/* XXX - GRP: Is this because of sign slide problem? Or is it
* really needed? Or is it because we allow multiple signs per
* line? If so, should I add that feature to FEAT_SIGNS?
@@ -5241,7 +5244,7 @@
}
prev = sign;
}
-#ifdef FEAT_NETBEANS_INTG /* insert new sign at head of list for this lnum */
+#if defined(FEAT_NETBEANS_INTG) || defined(FEAT_GDB) /* insert new sign at head of list for this lnum */
/* XXX - GRP: See previous comment */
while (prev != NULL && prev->lnum == lnum)
prev = prev->prev;
@@ -5317,7 +5320,7 @@
if (sign->id == id)
{
*lastp = next;
-#ifdef FEAT_NETBEANS_INTG
+#if defined(FEAT_NETBEANS_INTG) || defined(FEAT_GDB)
if (next != NULL)
next->prev = sign->prev;
#endif
@@ -5497,6 +5500,35 @@
long amount_after;
{
signlist_T *sign; /* a sign in a b_signlist */
+# ifdef FEAT_GDB
+ int lnum;
+
+ for (sign = curbuf->b_signlist; sign != NULL; sign = sign->next)
+ {
+ lnum = sign->lnum;
+
+ if (sign->lnum >= line1 && sign->lnum <= line2)
+ {
+ if (amount == MAXLNUM)
+ lnum = line1;
+ else
+ lnum += amount;
+ }
+ else if (sign->lnum > line2)
+ lnum += amount_after;
+
+ /* Keep sign->lnum unchanged, but mark as changed the sign line and
+ * the new line position if we had moved the line
+ * (otherwise their highlighting may be scrolled along) */
+ if (gdb_isrunning(gdb) && lnum != sign->lnum)
+ {
+ changed_lines(sign->lnum, 0, sign->lnum + 1, 0);
+ changed_lines(lnum, 0, lnum + 1, 0);
+ }
+ else
+ sign->lnum = lnum;
+ }
+# else
for (sign = curbuf->b_signlist; sign != NULL; sign = sign->next)
{
@@ -5510,6 +5542,7 @@
else if (sign->lnum > line2)
sign->lnum += amount_after;
}
+# endif
}
#endif /* FEAT_SIGNS */
diff -uNr vim73old/src/clewn/gdb.h vim73/src/clewn/gdb.h
--- vim73old/src/clewn/gdb.h 1970-01-01 08:00:00.000000000 +0800
+++ vim73/src/clewn/gdb.h 2011-04-25 09:08:38.000000000 +0800
@@ -0,0 +1,685 @@
+/* vi:set ts=8 sts=4 sw=4:
+ *
+ * Copyright (C) 2004 Xavier de Gaye.
+ *
+ * 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; either version 2, or (at your option)
+ * any later version.
+ *
+ * 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 (see the file COPYING); if not, write to the
+ * Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * $Id: gdb.h 148 2007-07-21 16:35:40Z xavier $
+ */
+
+#ifndef GDB_H
+# define GDB_H
+
+#define obstack_chunk_alloc malloc
+#define obstack_chunk_free free
+#define obstack_strsave(o,s) (char_u *)obstack_copy0((o), (s), STRLEN((s)))
+#define obstack_strcat(o,s) \
+( (s) ? obstack_grow((o), (s), STRLEN((s))) : 0)
+#define obstack_strcat0(o,s) \
+( (s) \
+ ? obstack_grow0((o), (s), STRLEN((s))) \
+ : obstack_grow0((o), "", 0))
+
+#define GDB_LVL2_SUPPORT
+#define GDB_LVL3_SUPPORT
+/*#define GDB_MI_SUPPORT */
+
+/* |+gdb| modes */
+#define GDB_MODE_LVL2 1 /* CLI with annotations level 2 */
+#define GDB_MODE_LVL3 2 /* CLI with annotations level 3 and GDB/MI */
+#define GDB_MODE_MI 3 /* GDB/MI */
+
+#if defined(GDB_LVL2_SUPPORT) || defined(GDB_LVL3_SUPPORT)
+/*
+ * GDB does not send ANO_BP_INVALID annotation when hitting a breakpoint
+ * that has been 'enable once'.
+ * Undefine BP_INVALID_ANO_MISSING after GDB fixes this
+ */
+# define BP_INVALID_ANO_MISSING
+#endif
+
+#define KEY_INTERUPT Ctrl_Z /* interrupt */
+#define MAX_BUFFSIZE 1024
+
+/* The breakpoint info record structure */
+typedef struct bpinfo_struct bpinfo_T;
+
+struct bpinfo_struct
+{
+ int id; /* breakpoint number */
+ int typenr; /* sign type number, for Clewn: sequence sign type number in this buffer */
+#ifdef BP_INVALID_ANO_MISSING
+ int disposition; /* TRUE when keep, FALSE when disabled */
+#endif
+ int enabled; /* TRUE when enabled */
+ int cont; /* TRUE when 'commands' includes continue */
+#ifdef FEAT_GDB
+ buf_T *buf; /* breakpoint buffer */
+#else
+ int buf; /* Clewn buffer number */
+ int typenr_en; /* enabled breakpoint sequence number */
+ int typenr_dis; /* disabled breakpoint sequence number */
+#endif
+ linenr_T lnum; /* breakpoint line number */
+ bpinfo_T *next;
+};
+
+#if defined(GDB_LVL2_SUPPORT) || defined(GDB_LVL3_SUPPORT)
+/* Annotation types */
+# define ANO_NONE 0
+# define ANO_ANY 1 /* some unrecognized annotation */
+
+/* level 2 and level 3 annotations */
+# define ANO_PREPROMPT 101
+# define ANO_PROMPT 102
+# define ANO_POSTPROMPT 103
+# define ANO_PRECMDS 104
+# define ANO_CMDS 105
+# define ANO_PREOVERLOAD 106
+# define ANO_OVERLOAD 107
+# define ANO_PREQUERY 108
+# define ANO_QUERY 109
+# define ANO_PREPMT_FORMORE 110
+# define ANO_PMT_FORMORE 111
+# define ANO_POSTPMT_FORMORE 112
+# define ANO_QUIT 113
+# define ANO_ERROR_BEG 114
+# define ANO_FRAME_INVALID 115
+# define ANO_BP_INVALID 116
+# define ANO_STARTING 117
+# define ANO_STOPPED 118
+# define ANO_EXITED 119
+# define ANO_SIGNALLED 120
+# define ANO_BREAKPOINT 121
+# define ANO_SOURCE 122
+
+# define KEY_KILL Ctrl_U /* readline 'unix-line-discard' */
+# define LPP_LINES 500 /* large output interruption interval */
+
+/* Command completion states */
+# define CS_START 0
+# define CS_PENDING 1
+# define CS_CHOICE 2
+# define CS_DONE 3
+# define CS_QUERY 4
+
+/* The gdb CLI cmd */
+typedef struct
+{
+ int state; /* cmd completion state */
+ int cnt; /* lines output by gdb since last cmd */
+ char_u *gdb; /* partial cmd sent to gdb */
+ char_u *readline; /* gdb readline content */
+ char_u *echoed; /* echoed cmd */
+} cli_cmd_T;
+
+/* breakpoint states */
+# define BPS_INVALID 0x0100 /* got "breakpoints-invalid" annotation */
+# define BPS_BP_HIT 0x0200 /* got "breakpoint" annotation */
+# define BPS_FR_INVALID 0x0400 /* got "frames-invalid" annotation */
+# define BPS_BP_SET 0x0800 /* a break type GDB cmd is being processed */
+# define BPS_RECORD 0x1000 /* parsing a record in the breakpoint table */
+# define BPS_START 0x2000 /* start of a record */
+#endif /* defined(GDB_LVL2_SUPPORT) || defined(GDB_LVL3_SUPPORT) */
+
+#ifdef GDB_LVL2_SUPPORT
+/* level 2 annotations */
+# define ANO_FRAME_BEGIN 201
+# define ANO_FRAME_END 202
+# define ANO_BP_HEADER 203
+# define ANO_BP_TABLE 204
+# define ANO_BP_RECORD 205
+# define ANO_BP_FIELD0 206 /* Number */
+# define ANO_BP_FIELD1 207 /* Type */
+# define ANO_BP_FIELD2 208 /* Disposition */
+# define ANO_BP_FIELD3 209 /* Enable */
+# define ANO_BP_FIELD4 210 /* Address */
+# define ANO_BP_FIELD5 211 /* What */
+# define ANO_BP_FIELD6 212 /* Frame */
+# define ANO_BP_FIELD7 213 /* Condition */
+# define ANO_BP_FIELD8 214 /* Ignore-count */
+# define ANO_BP_FIELD9 215 /* Commands */
+# define ANO_BP_END 216
+# define ANO_DISP_BEG 217
+# define ANO_DISP_NUMEND 218
+# define ANO_DISP_FMT 219
+# define ANO_DISP_EXP 220
+# define ANO_DISP_EXPEND 221
+# define ANO_DISP_VALUE 222 /* not output by GDB */
+# define ANO_DISP_END 223
+# define ANO_FIELD_BEG 224
+# define ANO_FIELD_NAMEND 225
+# define ANO_FIELD_VALUE 226
+# define ANO_FIELD_END 227
+# define ANO_ARRAY_BEG 228
+# define ANO_ARRAY_ELT 229
+# define ANO_ARRAY_ELTREP 230
+# define ANO_ARRAY_ELTEND 231
+# define ANO_ARRAY_END 232
+
+/* breakpoints */
+# define IS_RECORD(s) ((s) & BPS_RECORD)
+# define RECORD_INDEX(s) ((s) & 0xff)
+# define SET_RECORD_IDX(s, i) (((s) & ~0xff) | (i))
+
+/* breakpoint annotation fields indexes */
+# define BI_NUM 0
+# define BI_TYPE 1
+# define BI_DISPO 2
+# define BI_ENABLE 3
+# define BI_ADDRESS 4
+# define BI_WHAT 5
+# define BI_FRAME 6
+# define BI_COND 7
+# define BI_COUNT 8
+# define BI_CMMDS 9 /* commands */
+# define BI_FIELDS 10 /* number of bp info annotation fields */
+
+/* The display object structure */
+typedef struct gdbdisp_struct gdbdisp_T;
+
+struct gdbdisp_struct
+{
+ int num; /* display number */
+ int state; /* highlighted or/and changed */
+ gdbdisp_T * next;
+};
+
+/* display states */
+# define DSP_INIT 0
+# define DSP_STOPPED 1
+
+/* The display list structure */
+typedef struct
+{
+ int state;
+ gdbdisp_T * list;
+} displist_T;
+
+/* The display entry structure used to store a GDB display output */
+typedef struct
+{
+ char_u * num; /* display item number */
+ char_u * expression;/* display item format and expression */
+ char_u * value; /* display item value */
+} doutput_T;
+
+/* The lvl2 mode structure: lvl2 specific data */
+typedef struct
+{
+ /* breakpoints */
+ char_u *info[BI_FIELDS]; /* breakpoint info record contents */
+
+ /* variables (display) window */
+ displist_T varlist; /* list of display items */
+ doutput_T dentry; /* current GDB display output entry */
+ int doing_value; /* when TRUE: currently handling a display value */
+ char_u *dispinfostr;/* current line output after "info display" */
+ char_u *dispinfo; /* all item numbers result of a "info display" */
+} lvl2_T;
+#endif /* GDB_LVL2_SUPPORT */
+
+#ifdef GDB_LVL3_SUPPORT
+/* The variable object structure */
+typedef struct varobj_struct varobj_T;
+
+/* varobj states */
+#define VS_INIT 0x01 /* object creation */
+#define VS_ERROR 0x02 /* a command on this object produced an error */
+
+struct varobj_struct
+{
+ int state;
+ char_u *name; /* variable name ("NNN" in "varNNN") */
+ int children; /* TRUE when has children */
+ char_u *format; /* print format is "/[tdxo]"*/
+ char_u *expression; /* variable expression */
+ varobj_T * next;
+};
+
+/* GDB/MI var commands */
+# define VCMD_INIT 0
+# define VCMD_CREATE 1
+# define VCMD_DELETE 2
+# define VCMD_CHILDREN 3
+# define VCMD_UPDATE 4
+# define VCMD_PRINT 5
+# define VCMD_EVALUATE 6
+# define VCMD_FORMAT 7
+
+/* The lvl3 mode structure: lvl3 specific data */
+typedef struct
+{
+ char_u *result; /* result of a GDB/MI command */
+
+ int get_source_list;
+ char_u *source_cur; /* result of -file-list-exec-source-file */
+ char_u *source_list;/* result of -file-list-exec-source-files */
+
+ /* variables window */
+ varobj_T *varlist; /* list of variable objects */
+ varobj_T *varitem; /* current object in varlist */
+ int varcmd; /* GDB/MI var cmd being processed */
+ int varnext_cmd; /* GDB/MI var next cmd to process */
+} lvl3_T;
+#endif /* GDB_LVL3_SUPPORT */
+
+/* Command types */
+#define CMD_ANY 0
+#ifdef FEAT_GDB
+# define CMD_DIR 1
+#endif
+#define CMD_DETACH 2
+#define CMD_SHELL 3
+#define CMD_STEPI 4 /* instruction stepping cmds */
+#define CMD_EXECF 5 /* invalidating asm buffers cmds */
+#define CMD_BREAK 6
+#define CMD_DISPLAY 7
+#define CMD_CREATEVAR 8
+#define CMD_UP 9
+#define CMD_DOWN 10
+#define CMD_FRAME 11
+#define CMD_DISABLE 12
+#define CMD_DELETE 13
+#define CMD_UP_SILENT 14
+#define CMD_DOWN_SILENT 15
+#define CMD_SLECT_FRAME 16
+#define CMD_SYMF 17
+#define CMD_RESTART 18
+#define CMD_QUIT 19
+
+#define ASM_MAX_BUFF 64 /* asm buffers pool size */
+#define ASM_BUF_NAME "gdb-asm-" /* asm buffer name prefix */
+#define ASM_OLD (char_u)(~0U) /* asm buffer max age */
+
+/* The assembly buffer pool */
+typedef struct
+{
+#ifdef FEAT_GDB
+ int max; /* buffers in use */
+ int idx; /* current buffer */
+ buf_T * buf[ASM_MAX_BUFF]; /* asm buffers */
+ char_u age[ASM_MAX_BUFF]; /* buffer's age */
+ int last; /* used for generating unique asm names */
+#else
+ int buf; /* number of the asm buffer being disassembled */
+ FILE *fd; /* stream descriptor of asm file being written to */
+ char_u *name; /* file name of the function being disassembled */
+ long line_offset; /* offset of start of last line in file */
+#endif
+ linenr_T lnum; /* highlited line number */
+ int hilite; /* TRUE when $pc in asm is highlited */
+} asm_T;
+
+/* The gdb structure */
+typedef struct gdb_struct gdb_T;
+
+/* Out of band states */
+#define OS_CMD 0x01 /* a cmd is being processed */
+#define OS_INTR 0x02 /* interrupt sent to gdb */
+#define OS_QUIT 0x04 /* 'quit' annotation received */
+
+/* Out of Band */
+#define OOB_CMD 0
+#define OOB_COLLECT 1
+#define OOB_COMPLETE 2
+#define IS_OOBACTIVE(t) (((t)->oob.idx) >= 0)
+
+/* The out of band process */
+typedef struct
+{
+ int state; /* oob state */
+ int idx; /* current function index */
+ int cnt; /* asm output lines count */
+} oob_T;
+
+/*
+ * oobfunc_T function:
+ *
+ * When an oobfunc_T[] array is processed by gdb_oob_send() and
+ * gdb_oob_receive(), each oob function in the array is called with
+ * successive state values of:
+ *
+ * OOB_CMD: called at each 'prompt'; should return the GDB cmd
+ * to send to GDB or NULL when no command must be sent;
+ * in this case the next oob function in the oobfunc_T[]
+ * array is processed next with OOB_CMD
+ *
+ * OOB_COLLECT: oob may process chunk, a (possibly partial) line from GDB
+ * result of GDB command; may be invoked more than once, or not at all
+ *
+ * OOB_COMPLETE:indicates end of GDB output; oob may do any final processing;
+ * if oob returns a non NULL value, the same oob function is
+ * called once again with OOB_CMD and the same cycle starts again;
+ * if oob returns a NULL value, the next oob function in the
+ * oobfunc_T[] array is processed with OOB_CMD
+ *
+ * Return: NULL, except when state is OOB_CMD or OOB_COMPLETE
+ */
+
+typedef struct {
+ char * (*oob)(gdb_T *, int state, char_u *chunk, struct obstack *);
+} oobfunc_T;
+
+/* gdb states */
+#define GDB_STATE(i,s) (((i) != NULL) ? ((((gdb_T *)(i))->state) & (s)):FALSE)
+#define GS_INIT 0 /* initial state */
+#define GS_CLOSING 0x001 /* gdb process closing */
+#define GS_UP 0x002 /* gdb up and running */
+#define GS_STARTED 0x004 /* gdb just started */
+#define GS_ALLOWED 0x008 /* select on pty is allowed */
+#define GS_EVENT 0x010 /* got SIGCHLD or gdb output some data */
+#define GS_SIGCHLD 0x020 /* got SIGCHLD from gdb */
+#define GS_STOPPED 0x040 /* debuggee is stopped */
+#define GS_ANO 0x080 /* parsing an annotation table or list */
+#define GS_QUITTING 0x100 /* quitting clewn */
+
+/* parser states */
+#define PS_ANY 0
+#define PS_PREPROMPT 1 /* before the prompt, after any output from GDB */
+#define PS_PROMPT 2 /* after prompt, but before user input */
+
+/* project file sourced states */
+#define PROJ_INIT 0
+#define PROJ_SOURCEIT 1
+#define PROJ_DONE 2
+
+/* The gdb structure */
+struct gdb_struct
+{
+ /* process */
+ int instance; /* gdb instance number */
+ int fd; /* pty file descriptor */
+ pid_t pid; /* process id */
+#if defined(GDB_LVL2_SUPPORT) || defined(GDB_LVL3_SUPPORT)
+ int height; /* pseudo tty height, non zero when ioctl set */
+ int intr_sent; /* hack: an interrupt has been sent by the user */
+#endif
+ int state; /* gdb state */
+ char_u *status; /* gdb status */
+ int recurse; /* disable GS_ALLOWED when calling safe_vgetc */
+
+ /* cmds */
+ int cmd_type; /* cmd type */
+#if defined(GDB_LVL2_SUPPORT) || defined(GDB_LVL3_SUPPORT)
+ cli_cmd_T cli_cmd; /* current CLI cmd (common to lvl2 and lvl3) */
+#endif
+ char_u *firstcmd; /* first cmd in new GDB session */
+ int parser; /* parser states */
+ int syntax; /* when TRUE, enable syntax highlighting */
+ char_u *line; /* last incomplete line */
+ char_u *winput_cmd; /* cmd inserted in input-line window */
+ char_u *directories;/* gdb search path for source files */
+#ifndef FEAT_GDB
+ char_u *prompt; /* the current GDB prompt */
+ char * version; /* clewn version */
+ char_u * pwd; /* current working directory */
+ char_u * args; /* debugge command line arguments */
+#endif
+ char_u *sfile; /* symbol file name */
+
+#if defined(GDB_LVL2_SUPPORT) || defined(GDB_LVL3_SUPPORT)
+ /* annotations */
+ int note; /* annotation type */
+ int annoted; /* TRUE when parsing an annotation */
+ int newline; /* pending NL, possibly an annotation first char */
+ int valid_note; /* last non prompt-for-more annotation type */
+ int prev_note; /* previous annotation type */
+ char_u *annotation; /* last incomplete annotation */
+#endif
+
+ /* disassembly */
+ asm_T pool; /* asm buffers pool */
+ char_u *pc; /* program counter where debuggee is stopped */
+ char_u *frame_pc; /* current frame program counter */
+ char_u *oob_result; /* result of oob gdb_get_frame */
+ char_u *asm_add; /* address whose function must be disassembled */
+ char_u *asm_func; /* asm function name */
+
+ /* breakpoints */
+#if defined(GDB_LVL2_SUPPORT) || defined(GDB_LVL3_SUPPORT)
+ int bp_state; /* breakpoint annotation state (and index) */
+ bpinfo_T *tmplist; /* tmp new bp list when reading "info beakpoints" */
+#endif
+ bpinfo_T *record; /* current record */
+ int bufIsChanged; /* TRUE when curbuf is changed after edit failed */
+ int cont; /* TRUE when pgm is continuing at this bp */
+ bpinfo_T *bpinfo; /* breakpoints info table */
+ int frame_curlvl; /* current frame level */
+ linenr_T frame_lnum;/* current frame line number */
+ char_u * frame_fname;/* current frame file name */
+
+#ifdef FEAT_GDB
+ buf_T *buf; /* gdb buffer */
+ buf_T *fr_buf; /* frame sign buffer */
+ buf_T *var_buf; /* variables window buffer */
+#else /* Clewn implementation */
+ linenr_T lastline; /* lastline being disassembled */
+ int fr_buf; /* frame sign buffer number */
+ linenr_T lnum; /* frame sign line number */
+ int var_buf; /* variables buffer number */
+ char_u *var_name; /* variables file name */
+ char_u *balloon_txt;/* text over which is pointed the mouse */
+ char * project_file;/* project file name */
+ int project_state; /* project file sourced state */
+#endif
+ oob_T oob; /* out of band data */
+
+ /* |+gdb| modes */
+ int mode; /* current |+gdb| mode */
+#ifdef GDB_LVL2_SUPPORT
+ lvl2_T lvl2; /* annotations level 2 */
+#endif
+#ifdef GDB_LVL3_SUPPORT
+ lvl3_T lvl3; /* annotations level 3 and GDB/MI */
+#endif
+
+ /* pointers to mode specific functions */
+ oobfunc_T *oobfunc; /* the current oob functions array */
+ oobfunc_T *std_oobfunc; /* the standard oob functions array */
+ int (*parse_output)(gdb_T *); /* parser function */
+ void (*gdb_docmd)(gdb_T *, char_u *);/* GDB command input function */
+ void (*var_delete)(gdb_T *); /* delete all variables function */
+ void (*clear_gdb_T)(gdb_T *); /* clear mode specific stuff */
+};
+
+/* Regexp patterns */
+#define PAT_DIR 1
+#define PAT_CHG_ANNO 2
+#define PAT_ADD 3
+#define PAT_PID 4
+
+#if defined(GDB_LVL2_SUPPORT) || defined(GDB_LVL3_SUPPORT)
+# define PAT_SOURCE 101
+# define PAT_QUERY 102
+# define PAT_YES 103
+# define PAT_SFILE 104
+# define PAT_BP_CONT 105
+# define PAT_ASM_FUNC 106
+# define PAT_ASM_FUNC_P 107
+# define PAT_FRAME 108
+# define PAT_HEIGHT 109
+#endif
+
+#ifdef GDB_LVL2_SUPPORT
+# define PAT_BP_ASM 201
+# define PAT_BP_SOURCE 202
+# define PAT_DISPLAY 203
+# define PAT_DISPINFO 204
+# define PAT_CREATEVAR 205
+#endif
+
+# ifdef GDB_LVL3_SUPPORT
+# define PAT_CRVAR_FMT 301
+# define PAT_INFO_FRAME 302
+#endif
+
+/* User interface */
+#if defined(GDB_LVL2_SUPPORT) || defined(GDB_LVL3_SUPPORT)
+void gdb_docmd_cli __ARGS((gdb_T *, char_u *));
+void gdb_send_cmd __ARGS((gdb_T *, char_u *));
+#endif
+
+/* Vim low level hook */
+#if defined(GDB_LVL2_SUPPORT) || defined(GDB_LVL3_SUPPORT)
+int gdb_parse_output_cli __ARGS((gdb_T *));
+#endif
+
+/* Gdb process mgmt */
+void gdb_close __ARGS((gdb_T *));
+#if defined(GDB_LVL2_SUPPORT) || defined(GDB_LVL3_SUPPORT)
+int gdb_setup_cli __ARGS((gdb_T *));
+#endif
+
+/* Gdb mode initialization */
+#ifdef GDB_LVL2_SUPPORT
+void gdb_lvl2_init __ARGS((gdb_T *));
+#endif
+#ifdef GDB_LVL3_SUPPORT
+void gdb_lvl3_init __ARGS((gdb_T *));
+#endif
+
+/* Sign highliting */
+#define FRAME_SIGN 1
+#ifdef FEAT_GDB
+# define PHANTOM_SIGN 2
+# define BP_SIGN_ID(n) ((n)+2) /* reserved sign ids: 1 frame, 2 phantom */
+void gdb_fr_lite __ARGS((gdb_T *, buf_T *, linenr_T, struct obstack *));
+int gdb_define_sign __ARGS((int, int));
+void gdb_undefine_sign __ARGS((int));
+buf_T * gdb_unlite __ARGS((int));
+#else
+# define BP_SIGN_ID(n) ((n)+1) /* reserved sign id: 1 frame */
+void gdb_fr_lite __ARGS((gdb_T *, int, linenr_T, struct obstack *));
+int gdb_define_bpsign __ARGS((bpinfo_T *, struct obstack *));
+void gdb_unlite __ARGS((int));
+#endif
+int gdb_as_frset __ARGS((gdb_T *, struct obstack *));
+int gdb_fr_set __ARGS((gdb_T *, char_u *, linenr_T *, struct obstack *));
+void gdb_fr_unlite __ARGS((gdb_T *));
+
+/* Window and buffer mgmt */
+#ifdef FEAT_GDB
+win_T *gdb_btowin __ARGS((buf_T *));
+void gdb_as_setname __ARGS((char_u *));
+void gdb_clear_asmbuf __ARGS((gdb_T *, buf_T *));
+win_T * gdb_edit_file __ARGS((gdb_T *, buf_T *, char_u *, linenr_T, struct obstack *));
+void gdb_set_cursor __ARGS((win_T *, linenr_T));
+void gdb_popup_console __ARGS((gdb_T *));
+void gdb_redraw __ARGS((buf_T *));
+#else
+int gdb_edit_file __ARGS((int, char_u *, linenr_T, int, struct obstack *));
+#endif
+void gdb_msg_busy __ARGS((char_u *));
+void gdb_showBalloon __ARGS((char_u *, struct obstack *));
+void gdb_status __ARGS((gdb_T *, char_u *, struct obstack *));
+void gdb_write_buf __ARGS((gdb_T *, char_u *, int));
+
+/* Out Of Band */
+void gdb_oob_send __ARGS((gdb_T *, struct obstack *));
+void gdb_oob_receive __ARGS((gdb_T *, char_u *, struct obstack *));
+#if defined(GDB_LVL2_SUPPORT) || defined(GDB_LVL3_SUPPORT)
+char * gdb_print_value __ARGS((gdb_T *, int, char_u *, struct obstack *));
+char * gdb_get_pc __ARGS((gdb_T *, int, char_u *, struct obstack *));
+char * gdb_get_frame __ARGS((gdb_T *, int, char_u *, struct obstack *));
+char * gdb_info_frame __ARGS((gdb_T *, int, char_u *, struct obstack *));
+char * gdb_stack_frame __ARGS((gdb_T *, int, char_u *, struct obstack *));
+char * gdb_get_sfile __ARGS((gdb_T *, int, char_u *, struct obstack *));
+#ifndef FEAT_GDB
+char * gdb_source_project __ARGS((gdb_T *, int, char_u *, struct obstack *));
+char * gdb_get_pwd __ARGS((gdb_T *, int, char_u *, struct obstack *));
+char * gdb_get_args __ARGS((gdb_T *, int, char_u *, struct obstack *));
+#endif
+char * gdb_source_cur __ARGS((gdb_T *, int, char_u *, struct obstack *));
+char * gdb_source_list __ARGS((gdb_T *, int, char_u *, struct obstack *));
+char * gdb_get_sourcedir __ARGS((gdb_T *, int, char_u *, struct obstack *));
+char * gdb_get_asmfunc __ARGS((gdb_T *, int, char_u *, struct obstack *));
+char * gdb_get_asmfunc_hack __ARGS((gdb_T *, int, char_u *, struct obstack *));
+char * gdb_get_asm __ARGS((gdb_T *, int, char_u *, struct obstack *));
+void gdb_process_record __ARGS((gdb_T *, char_u *, char_u *, char_u *, char_u *, struct obstack *));
+#endif
+
+/* Variables window management */
+#ifdef GDB_LVL2_SUPPORT
+void gdb_process_display __ARGS((gdb_T *, char_u *, struct obstack *));
+#endif
+
+/* Utilities */
+#ifndef MIN
+#define MIN(a,b) (((a)<(b))?(a):(b))
+#endif
+#ifndef ABS
+#define ABS(x) (((x)<0)?(-(x)):(x))
+#endif
+#define STRCHR(s,c) (char_u *)strchr((char *)(s),(int)(c))
+#define STRSTR(h,n) (char_u *)strstr((char *)(h),(char *)(n))
+#define FREE(p) {xfree((p)); (p) = NULL;}
+#define IS_ANNOTATION(l) (STRSTR((l),"\032\032") == (l))
+#define BUFLASTL(b) (!(((b)->b_ml.ml_flags) & ML_EMPTY)?((b)->b_ml.ml_line_count):0)
+int gdb_read __ARGS((gdb_T *, char_u *, int, int));
+void gdb_free_bplist __ARGS((bpinfo_T **));
+void gdb_cmd_type __ARGS((gdb_T *, char_u *));
+void gdb_cat __ARGS((char_u **, char_u *));
+char_u * gdb_regexec __ARGS((char_u *, int, int, struct obstack *));
+char_u * gdb_itoa __ARGS((int));
+
+/* Gdb memory leaks mtrace */
+#if defined(GDB_MTRACE) && defined(HAVE_MTRACE)
+# include <malloc.h>
+# include <mcheck.h>
+/* storage for mtrace hooks */
+extern __ptr_t (*s_malloc) (size_t, const void *);
+extern void (*s_free) (void *, const void *);
+extern __ptr_t (*s_realloc) (void *, size_t, const void *);
+
+# define mv_hooks() do { \
+ s_malloc = __malloc_hook; \
+ s_free = __free_hook; \
+ s_realloc = __realloc_hook; \
+ __malloc_hook = NULL; \
+ __free_hook = NULL; \
+ __realloc_hook = NULL; \
+ } while (0)
+
+# define get_hooks() do { \
+ __malloc_hook = s_malloc; \
+ __free_hook = s_free; \
+ __realloc_hook = s_realloc; \
+ } while (0)
+
+/* we do call sometimes vim_free directly and allocation is not mtraced:
+ * when the called Vim function does not free all its allocated memory
+ * after it returns */
+# define xmalloc(s) ({char_u *mret; get_hooks(); mret=xmalloc((s)); mv_hooks(); mret;})
+# define xcalloc(s) ({char_u *mret; get_hooks(); mret=xcalloc((s)); mv_hooks(); mret;})
+# define xrealloc(m,s) ({char_u *mret; get_hooks(); mret=xrealloc((m),(s)); mv_hooks(); mret;})
+
+# define xfree(x) do { \
+ get_hooks(); \
+ xfree((x)); \
+ mv_hooks(); \
+ } while (0)
+
+# define clewn_strsave(s) ({char_u *mret; get_hooks(); mret=clewn_strsave((s)); mv_hooks(); mret;})
+# define clewn_strnsave(s,l) ({char_u *mret; get_hooks(); mret=clewn_strnsave((s),(l)); mv_hooks(); mret;})
+
+# define vim_strsave_escaped(s,e) ({char_u *mret; get_hooks(); mret=vim_strsave_escaped((s),(e)); mv_hooks(); mret;})
+# define vim_regcomp(s,m) ({regprog_T *mret; get_hooks(); mret=vim_regcomp((s),(m)); mv_hooks(); mret;})
+# define FullName_save(n,f) ({char_u *mret; get_hooks(); mret=FullName_save((n),(f)); mv_hooks(); mret;})
+# define get_option_value(n,u,s,o) ({int r; get_hooks(); r=get_option_value((n),(u),(s),(o)); mv_hooks(); r;})
+#endif /* GDB_MTRACE */
+#endif /* GDB_H */
+
diff -uNr vim73old/src/clewn/gdb_lvl2.c vim73/src/clewn/gdb_lvl2.c
--- vim73old/src/clewn/gdb_lvl2.c 1970-01-01 08:00:00.000000000 +0800
+++ vim73/src/clewn/gdb_lvl2.c 2011-04-25 09:08:38.000000000 +0800
@@ -0,0 +1,1085 @@
+/* vi:set ts=8 sts=4 sw=4:
+ *
+ * Copyright (C) 2004 Xavier de Gaye.
+ *
+ * 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; either version 2, or (at your option)
+ * any later version.
+ *
+ * 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 (see the file COPYING); if not, write to the
+ * Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * $Id: gdb_lvl2.c 222 2008-10-13 14:38:07Z xavier $
+ */
+
+# ifdef HAVE_CLEWN
+# include <config.h>
+# include "obstack.h"
+# include "clewn.h"
+# else
+# include "vim.h"
+# include "clewn/obstack.h"
+# endif
+
+#if defined(FEAT_GDB) || defined(HAVE_CLEWN)
+
+# include "gdb.h"
+# include "misc.h"
+
+# ifdef GDB_LVL2_SUPPORT
+
+/* display item states */
+# define DISP_CHANGED 0x01 /* item expression value has changed */
+# define DISP_HILITED 0x02 /* item expression value is hilited */
+
+/* Gdb process mgmt */
+static void clear_gdb_T __ARGS((gdb_T *));
+
+/* Out Of Band */
+static char *get_lastbp __ARGS((gdb_T *, int, char_u *, struct obstack *));
+static char *get_bp __ARGS((gdb_T *, int, char_u *, struct obstack *));
+static void process_record __ARGS((gdb_T *, struct obstack *));
+static void set_bpfield __ARGS((gdb_T *, char_u *));
+static char *get_display __ARGS((gdb_T *, int, char_u *, struct obstack *));
+static char *undisplay __ARGS((gdb_T *, int, char_u *, struct obstack *));
+
+/* Variables window management */
+static void var_delete __ARGS((gdb_T *));
+
+/* The function ordering in this array is important as some of
+ * these functions must be invoked in the right order */
+static oobfunc_T oobfunc[] = {
+ {gdb_get_pc},
+ {gdb_get_frame},
+ {gdb_get_sfile},
+ {gdb_get_sourcedir},
+ {get_lastbp}, /* after gdb_get_frame */
+ {gdb_get_asmfunc}, /* after get_lastbp */
+ {gdb_get_asmfunc_hack}, /* after gdb_get_asmfunc */
+ {gdb_get_asm}, /* after gdb_get_asmfunc */
+ {get_bp}, /* after gdb_get_asm and get_lastbp */
+ {get_display},
+ {undisplay},
+ {NULL}
+};
+
+/* Initialize the gdb_T structure lvl2 component that lvl2 is responsible for */
+ static void
+clear_gdb_T(this)
+ gdb_T *this;
+{
+ gdbdisp_T *item, *next;
+ int i;
+
+ if (this != NULL)
+ {
+ for (item = this->lvl2.varlist.list; item != NULL; item = next)
+ {
+ next = item->next;
+ xfree(item);
+ }
+ this->lvl2.varlist.list = NULL;
+
+ for (i = 0; i < BI_FIELDS; i++)
+ FREE(this->lvl2.info[i]);
+
+ this->lvl2.doing_value = FALSE;
+ FREE(this->lvl2.dentry.num);
+ FREE(this->lvl2.dentry.expression);
+ FREE(this->lvl2.dentry.value);
+ FREE(this->lvl2.dispinfostr);
+ FREE(this->lvl2.dispinfo);
+ }
+}
+
+/* Initialize lvl2 function pointers */
+ void
+gdb_lvl2_init(this)
+ gdb_T *this;
+{
+ this->mode = GDB_MODE_LVL2;
+ this->oobfunc = oobfunc;
+ this->std_oobfunc = oobfunc;
+ this->parse_output = gdb_parse_output_cli;
+ this->gdb_docmd = gdb_docmd_cli;
+ this->var_delete = var_delete;
+ this->clear_gdb_T = clear_gdb_T;
+}
+
+/*
+ * When a breakpoint is being set and asm option is on, get the
+ * instruction address of the last breakpoint, the one being set.
+ * This address is used in get_asm() to disassemble the function
+ * containing this address.
+ */
+ static char *
+get_lastbp(this, state, line, obs)
+ gdb_T *this;
+ int state;
+ char_u *line;
+ struct obstack *obs;
+{
+ int found = FALSE;
+ bpinfo_T *p;
+ int bp_num;
+ int i;
+
+ if (obs) {} /* keep compiler happy */
+
+ switch (state)
+ {