OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [gdb/] [ui-out.c] - Blame information for rev 1775

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 104 markom
/* Output generating routines for GDB.
2
   Copyright 1999, 2000 Free Software Foundation, Inc.
3
   Contributed by Cygnus Solutions.
4
   Written by Fernando Nasser for Cygnus.
5
 
6
   This file is part of GDB.
7
 
8
   This program is free software; you can redistribute it and/or modify
9
   it under the terms of the GNU General Public License as published by
10
   the Free Software Foundation; either version 2 of the License, or
11
   (at your option) any later version.
12
 
13
   This program is distributed in the hope that it will be useful,
14
   but WITHOUT ANY WARRANTY; without even the implied warranty of
15
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
   GNU General Public License for more details.
17
 
18
   You should have received a copy of the GNU General Public License
19
   along with this program; if not, write to the Free Software
20
   Foundation, Inc., 59 Temple Place - Suite 330,
21
   Boston, MA 02111-1307, USA.  */
22
 
23
#include "defs.h"
24
#include "gdb_string.h"
25
#include "expression.h"         /* For language.h */
26
#include "language.h"
27
#include "ui-out.h"
28
 
29
/* Convenience macro for allocting typesafe memory. */
30
 
31
#undef XMALLOC
32
#define XMALLOC(TYPE) (TYPE*) xmalloc (sizeof (TYPE))
33
 
34
/* table header structures */
35
 
36
struct ui_out_hdr
37
  {
38
    int colno;
39
    int width;
40
    int alignment;
41
    char *colhdr;
42
    struct ui_out_hdr *next;
43
  };
44
 
45
/* The ui_out structure */
46
/* Any change here requires a corresponding one in the initialization
47
   of the default uiout, which is statically initialized */
48
 
49
struct ui_out
50
  {
51
    int flags;
52
    /* specific implementation of ui-out */
53
    struct ui_out_impl *impl;
54
    struct ui_out_data *data;
55
 
56
    /* if on, a table is being generated */
57
    int table_flag;
58
 
59
    /* if on, the body of a table is being generated */
60
    int body_flag;
61
 
62
    /* number of table columns (as specified in the table_begin call) */
63
    int table_columns;
64
 
65
    /* strinf identifying the table (as specified in the table_begin call) */
66
    char *table_id;
67
 
68
    /* if on, a list is being generated.  The value is the level of nesting */
69
    int list_flag;
70
 
71
    /* we count each field; the first element is for non-list fields */
72
    int field_count[5];
73
 
74
    /* points to the first header (if any) */
75
    struct ui_out_hdr *headerfirst;
76
 
77
    /* points to the last header (if any) */
78
    struct ui_out_hdr *headerlast;
79
 
80
    /* points to header of next column to format */
81
    struct ui_out_hdr *headercurr;
82
 
83
  };
84
 
85
/* These are the default implementation functions */
86
 
87
static void default_table_begin (struct ui_out *uiout, int nbrofcols,
88
                                 char *tblid);
89
static void default_table_body (struct ui_out *uiout);
90
static void default_table_end (struct ui_out *uiout);
91
static void default_table_header (struct ui_out *uiout, int width,
92
                                  enum ui_align alig, char *colhdr);
93
static void default_list_begin (struct ui_out *uiout, int list_flag,
94
                                char *lstid);
95
static void default_list_end (struct ui_out *uiout, int list_flag);
96
static void default_field_int (struct ui_out *uiout, int fldno, int width,
97
                               enum ui_align alig, char *fldname, int value);
98
static void default_field_skip (struct ui_out *uiout, int fldno, int width,
99
                                enum ui_align alig, char *fldname);
100
static void default_field_string (struct ui_out *uiout, int fldno, int width,
101
                                  enum ui_align align, char *fldname,
102
                                  const char *string);
103
static void default_field_fmt (struct ui_out *uiout, int fldno,
104
                               int width, enum ui_align align,
105
                               char *fldname, char *format, va_list args);
106
static void default_spaces (struct ui_out *uiout, int numspaces);
107
static void default_text (struct ui_out *uiout, char *string);
108
static void default_message (struct ui_out *uiout, int verbosity, char *format,
109
                             va_list args);
110
static void default_wrap_hint (struct ui_out *uiout, char *identstring);
111
static void default_flush (struct ui_out *uiout);
112
 
113
/* This is the default ui-out implementation functions vector */
114
 
115
struct ui_out_impl default_ui_out_impl =
116
{
117
  default_table_begin,
118
  default_table_body,
119
  default_table_end,
120
  default_table_header,
121
  default_list_begin,
122
  default_list_end,
123
  default_field_int,
124
  default_field_skip,
125
  default_field_string,
126
  default_field_fmt,
127
  default_spaces,
128
  default_text,
129
  default_message,
130
  default_wrap_hint,
131
  default_flush
132
};
133
 
134
/* The default ui_out */
135
 
136
struct ui_out def_uiout =
137
{
138
  0,                             /* flags */
139
  &default_ui_out_impl,         /* impl */
140
};
141
 
142
/* Pointer to current ui_out */
143
/* FIXME: This should not be a global, but something passed down from main.c
144
   or top.c */
145
 
146
struct ui_out *uiout = &def_uiout;
147
 
148
/* These are the interfaces to implementation functions */
149
 
150
static void uo_table_begin (struct ui_out *uiout, int nbrofcols, char *tblid);
151
static void uo_table_body (struct ui_out *uiout);
152
static void uo_table_end (struct ui_out *uiout);
153
static void uo_table_header (struct ui_out *uiout, int width,
154
                             enum ui_align align, char *colhdr);
155
static void uo_list_begin (struct ui_out *uiout, int list_flag, char *lstid);
156
static void uo_list_end (struct ui_out *uiout, int list_flag);
157
static void uo_field_int (struct ui_out *uiout, int fldno, int width,
158
                          enum ui_align align, char *fldname, int value);
159
static void uo_field_skip (struct ui_out *uiout, int fldno, int width,
160
                           enum ui_align align, char *fldname);
161
static void uo_field_string (struct ui_out *uiout, int fldno, int width,
162
                          enum ui_align align, char *fldname, const char *string);
163
static void uo_field_fmt (struct ui_out *uiout, int fldno, int width,
164
                          enum ui_align align, char *fldname,
165
                          char *format, va_list args);
166
static void uo_spaces (struct ui_out *uiout, int numspaces);
167
static void uo_text (struct ui_out *uiout, char *string);
168
static void uo_message (struct ui_out *uiout, int verbosity,
169
                        char *format, va_list args);
170
static void uo_wrap_hint (struct ui_out *uiout, char *identstring);
171
static void uo_flush (struct ui_out *uiout);
172
 
173
/* Prototypes for local functions */
174
 
175
extern void _initialize_ui_out (void);
176
static void append_header_to_list (struct ui_out *uiout, int width, int alignment, char *colhdr);
177
static int get_curr_header (struct ui_out *uiout, int *colno, int *width,
178
                            int *alignment, char **colhdr);
179
static void clear_header_list (struct ui_out *uiout);
180
static void verify_field_proper_position (struct ui_out *uiout);
181
static void verify_field_alignment (struct ui_out *uiout, int fldno, int *width, int *alignment);
182
 
183
static void init_ui_out_state (struct ui_out *uiout);
184
 
185
/* exported functions (ui_out API) */
186
 
187
/* Mark beginning of a table */
188
 
189
void
190
ui_out_table_begin (uiout, nbrofcols, tblid)
191
     struct ui_out *uiout;
192
     int nbrofcols;
193
     char *tblid;
194
{
195
  if (uiout->table_flag)
196
    internal_error ("gdb/ui_out.c: tables cannot be nested; table_begin found before \
197
previous table_end.");
198
 
199
  uiout->table_flag = 1;
200
  uiout->table_columns = nbrofcols;
201
  if (tblid != NULL)
202
    uiout->table_id = xstrdup (tblid);
203
  else
204
    uiout->table_id = NULL;
205
  clear_header_list (uiout);
206
 
207
  uo_table_begin (uiout, nbrofcols, uiout->table_id);
208
}
209
 
210
void
211
ui_out_table_body (uiout)
212
     struct ui_out *uiout;
213
{
214
  if (!uiout->table_flag)
215
    internal_error ("gdb/ui_out.c: table_body outside a table is not valid; it must be \
216
after a table_begin and before a table_end.");
217
  if (uiout->body_flag)
218
    internal_error ("gdb/ui_out.c: extra table_body call not allowed; there must be \
219
only one table_body after a table_begin and before a table_end.");
220
  if (uiout->headercurr->colno != uiout->table_columns)
221
    internal_error ("gdb/ui_out.c: number of headers differ from number of table \
222
columns.");
223
 
224
  uiout->body_flag = 1;
225
  uiout->headercurr = uiout->headerfirst;
226
 
227
  uo_table_body (uiout);
228
}
229
 
230
void
231
ui_out_table_end (uiout)
232
     struct ui_out *uiout;
233
{
234
  if (!uiout->table_flag)
235
    internal_error ("gdb/ui_out.c: misplaced table_end or missing table_begin.");
236
 
237
  uiout->body_flag = 0;
238
  uiout->table_flag = 0;
239
 
240
  uo_table_end (uiout);
241
 
242
  if (uiout->table_id)
243
    free (uiout->table_id);
244
  clear_header_list (uiout);
245
}
246
 
247
void
248
ui_out_table_header (uiout, width, alignment, colhdr)
249
     struct ui_out *uiout;
250
     int width;
251
     enum ui_align alignment;
252
     char *colhdr;
253
{
254
  if (!uiout->table_flag || uiout->body_flag)
255
    internal_error ("ui_out: table header must be specified after table_begin \
256
and before table_body.");
257
 
258
  append_header_to_list (uiout, width, alignment, colhdr);
259
 
260
  uo_table_header (uiout, width, alignment, colhdr);
261
}
262
 
263
void
264
ui_out_list_begin (uiout, lstid)
265
     struct ui_out *uiout;
266
     char *lstid;
267
{
268
  if (uiout->table_flag && !uiout->body_flag)
269
    internal_error ("ui_out: table header or table_body expected; lists must be \
270
specified after table_body.");
271
  if (uiout->list_flag >= 4)
272
    internal_error ("ui_out: list depth exceeded; only 4 levels of lists can be \
273
nested.");
274
 
275
  uiout->list_flag++;
276
  uiout->field_count[uiout->list_flag] = 0;
277
  if (uiout->table_flag && (uiout->list_flag == 1))
278
    uiout->headercurr = uiout->headerfirst;
279
 
280
  uo_list_begin (uiout, uiout->list_flag, lstid);
281
}
282
 
283
void
284
ui_out_list_end (uiout)
285
     struct ui_out *uiout;
286
{
287
  if (!uiout->list_flag)
288
    internal_error ("ui_out: misplaced list_end; there is no list to be closed.");
289
 
290
  uo_list_end (uiout, uiout->list_flag);
291
 
292
  uiout->list_flag--;
293
}
294
 
295
void
296
ui_out_field_int (uiout, fldname, value)
297
     struct ui_out *uiout;
298
     char *fldname;
299
     int value;
300
{
301
  int fldno;
302
  int width;
303
  int align;
304
 
305
  verify_field_proper_position (uiout);
306
 
307
  uiout->field_count[uiout->list_flag] += 1;
308
  fldno = uiout->field_count[uiout->list_flag];
309
 
310
  verify_field_alignment (uiout, fldno, &width, &align);
311
 
312
  uo_field_int (uiout, fldno, width, align, fldname, value);
313
}
314
 
315
void
316
ui_out_field_core_addr (uiout, fldname, address)
317
     struct ui_out *uiout;
318
     char *fldname;
319
     CORE_ADDR address;
320
{
321
  char addstr[20];
322
 
323
  /* FIXME-32x64: need a print_address_numeric with field width */
324
  /* print_address_numeric (address, 1, local_stream); */
325
  strcpy (addstr, local_hex_string_custom ((unsigned long) address, "08l"));
326
 
327
  ui_out_field_string (uiout, fldname, addstr);
328
}
329
 
330
void
331
ui_out_field_stream (uiout, fldname, buf)
332
     struct ui_out *uiout;
333
     char *fldname;
334
     struct ui_stream *buf;
335
{
336
  long length;
337
  char *buffer = ui_file_xstrdup (buf->stream, &length);
338
  struct cleanup *old_cleanup = make_cleanup (free, buffer);
339
  if (length > 0)
340
    ui_out_field_string (uiout, fldname, buffer);
341
  else
342
    ui_out_field_skip (uiout, fldname);
343
  ui_file_rewind (buf->stream);
344
  do_cleanups (old_cleanup);
345
}
346
 
347
/* used to ommit a field */
348
 
349
void
350
ui_out_field_skip (uiout, fldname)
351
     struct ui_out *uiout;
352
     char *fldname;
353
{
354
  int fldno;
355
  int width;
356
  int align;
357
 
358
  verify_field_proper_position (uiout);
359
 
360
  uiout->field_count[uiout->list_flag] += 1;
361
  fldno = uiout->field_count[uiout->list_flag];
362
 
363
  verify_field_alignment (uiout, fldno, &width, &align);
364
 
365
  uo_field_skip (uiout, fldno, width, align, fldname);
366
}
367
 
368
void
369
ui_out_field_string (struct ui_out *uiout,
370
                     char *fldname,
371
                     const char *string)
372
{
373
  int fldno;
374
  int width;
375
  int align;
376
 
377
  verify_field_proper_position (uiout);
378
 
379
  uiout->field_count[uiout->list_flag] += 1;
380
  fldno = uiout->field_count[uiout->list_flag];
381
 
382
  verify_field_alignment (uiout, fldno, &width, &align);
383
 
384
  uo_field_string (uiout, fldno, width, align, fldname, string);
385
}
386
 
387
/* VARARGS */
388
void
389
ui_out_field_fmt (struct ui_out *uiout, char *fldname, char *format,...)
390
{
391
  va_list args;
392
  int fldno;
393
  int width;
394
  int align;
395
 
396
  verify_field_proper_position (uiout);
397
 
398
  uiout->field_count[uiout->list_flag] += 1;
399
  fldno = uiout->field_count[uiout->list_flag];
400
 
401
  /* will not align, but has to call anyway */
402
  verify_field_alignment (uiout, fldno, &width, &align);
403
 
404
  va_start (args, format);
405
 
406
  uo_field_fmt (uiout, fldno, width, align, fldname, format, args);
407
 
408
  va_end (args);
409
}
410
 
411
void
412
ui_out_spaces (uiout, numspaces)
413
     struct ui_out *uiout;
414
     int numspaces;
415
{
416
  uo_spaces (uiout, numspaces);
417
}
418
 
419
void
420
ui_out_text (uiout, string)
421
     struct ui_out *uiout;
422
     char *string;
423
{
424
  uo_text (uiout, string);
425
}
426
 
427
void
428
ui_out_message (struct ui_out *uiout, int verbosity, char *format,...)
429
{
430
  va_list args;
431
 
432
  va_start (args, format);
433
 
434
  uo_message (uiout, verbosity, format, args);
435
 
436
  va_end (args);
437
}
438
 
439
struct ui_stream *
440
ui_out_stream_new (uiout)
441
     struct ui_out *uiout;
442
{
443
  struct ui_stream *tempbuf;
444
 
445
  tempbuf = XMALLOC (struct ui_stream);
446
  tempbuf->uiout = uiout;
447
  tempbuf->stream = mem_fileopen ();
448
  return tempbuf;
449
}
450
 
451
void
452
ui_out_stream_delete (buf)
453
     struct ui_stream *buf;
454
{
455
  ui_file_delete (buf->stream);
456
  free (buf);
457
}
458
 
459
static void
460
do_stream_delete (void *buf)
461
{
462
  ui_out_stream_delete (buf);
463
}
464
 
465
struct cleanup *
466
make_cleanup_ui_out_stream_delete (struct ui_stream *buf)
467
{
468
  return make_cleanup (do_stream_delete, buf);
469
}
470
 
471
 
472
void
473
ui_out_wrap_hint (uiout, identstring)
474
     struct ui_out *uiout;
475
     char *identstring;
476
{
477
  uo_wrap_hint (uiout, identstring);
478
}
479
 
480
void
481
ui_out_flush (uiout)
482
     struct ui_out *uiout;
483
{
484
  uo_flush (uiout);
485
}
486
 
487
/* set the flags specified by the mask given */
488
int
489
ui_out_set_flags (uiout, mask)
490
     struct ui_out *uiout;
491
     int mask;
492
{
493
  int oldflags = uiout->flags;
494
 
495
  uiout->flags |= mask;
496
 
497
  return oldflags;
498
}
499
 
500
/* clear the flags specified by the mask given */
501
int
502
ui_out_clear_flags (uiout, mask)
503
     struct ui_out *uiout;
504
     int mask;
505
{
506
  int oldflags = uiout->flags;
507
 
508
  uiout->flags &= ~mask;
509
 
510
  return oldflags;
511
}
512
 
513
/* test the flags against the mask given */
514
int
515
ui_out_test_flags (uiout, mask)
516
     struct ui_out *uiout;
517
     int mask;
518
{
519
  return (uiout->flags & mask);
520
}
521
 
522
/* obtain the current verbosity level (as stablished by the
523
   'set verbositylevel' command */
524
 
525
int
526
ui_out_get_verblvl (uiout)
527
     struct ui_out *uiout;
528
{
529
  /* FIXME: not implemented yet */
530
  return 0;
531
}
532
 
533
#if 0
534
void
535
ui_out_result_begin (uiout, class)
536
     struct ui_out *uiout;
537
     char *class;
538
{
539
}
540
 
541
void
542
ui_out_result_end (uiout)
543
     struct ui_out *uiout;
544
{
545
}
546
 
547
void
548
ui_out_info_begin (uiout, class)
549
     struct ui_out *uiout;
550
     char *class;
551
{
552
}
553
 
554
void
555
ui_out_info_end (uiout)
556
     struct ui_out *uiout;
557
{
558
}
559
 
560
void
561
ui_out_notify_begin (uiout, class)
562
     struct ui_out *uiout;
563
     char *class;
564
{
565
}
566
 
567
void
568
ui_out_notify_end (uiout)
569
     struct ui_out *uiout;
570
{
571
}
572
 
573
void
574
ui_out_error_begin (uiout, class)
575
     struct ui_out *uiout;
576
     char *class;
577
{
578
}
579
 
580
void
581
ui_out_error_end (uiout)
582
     struct ui_out *uiout;
583
{
584
}
585
#endif
586
 
587
#if 0
588
void
589
gdb_error (ui_out * uiout, int severity, char *format,...)
590
{
591
  va_list args;
592
}
593
 
594
void
595
gdb_query (uiout, qflags, qprompt)
596
     struct ui_out *uiout;
597
     int flags;
598
     char *qprompt;
599
{
600
}
601
#endif
602
 
603
/* default gdb-out hook functions */
604
 
605
static void
606
default_table_begin (uiout, nbrofcols, tblid)
607
     struct ui_out *uiout;
608
     int nbrofcols;
609
     char *tblid;
610
{
611
}
612
 
613
static void
614
default_table_body (uiout)
615
     struct ui_out *uiout;
616
{
617
}
618
 
619
static void
620
default_table_end (uiout)
621
     struct ui_out *uiout;
622
{
623
}
624
 
625
static void
626
default_table_header (uiout, width, alignment, colhdr)
627
     struct ui_out *uiout;
628
     int width;
629
     enum ui_align alignment;
630
     char *colhdr;
631
{
632
}
633
 
634
static void
635
default_list_begin (uiout, list_flag, lstid)
636
     struct ui_out *uiout;
637
     int list_flag;
638
     char *lstid;
639
{
640
}
641
 
642
static void
643
default_list_end (uiout, list_flag)
644
     struct ui_out *uiout;
645
     int list_flag;
646
{
647
}
648
 
649
static void
650
default_field_int (uiout, fldno, width, align, fldname, value)
651
     struct ui_out *uiout;
652
     int fldno;
653
     int width;
654
     enum ui_align align;
655
     char *fldname;
656
     int value;
657
{
658
}
659
 
660
static void
661
default_field_skip (uiout, fldno, width, align, fldname)
662
     struct ui_out *uiout;
663
     int fldno;
664
     int width;
665
     enum ui_align align;
666
     char *fldname;
667
{
668
}
669
 
670
static void
671
default_field_string (struct ui_out *uiout,
672
                      int fldno,
673
                      int width,
674
                      enum ui_align align,
675
                      char *fldname,
676
                      const char *string)
677
{
678
}
679
 
680
static void
681
default_field_fmt (uiout, fldno, width, align, fldname, format, args)
682
     struct ui_out *uiout;
683
     int fldno;
684
     int width;
685
     enum ui_align align;
686
     char *fldname;
687
     char *format;
688
     va_list args;
689
{
690
}
691
 
692
static void
693
default_spaces (uiout, numspaces)
694
     struct ui_out *uiout;
695
     int numspaces;
696
{
697
}
698
 
699
static void
700
default_text (uiout, string)
701
     struct ui_out *uiout;
702
     char *string;
703
{
704
}
705
 
706
static void
707
default_message (uiout, verbosity, format, args)
708
     struct ui_out *uiout;
709
     int verbosity;
710
     char *format;
711
     va_list args;
712
{
713
}
714
 
715
static void
716
default_wrap_hint (uiout, identstring)
717
     struct ui_out *uiout;
718
     char *identstring;
719
{
720
}
721
 
722
static void
723
default_flush (uiout)
724
     struct ui_out *uiout;
725
{
726
}
727
 
728
/* Interface to the implementation functions */
729
 
730
void
731
uo_table_begin (struct ui_out *uiout, int nbrofcols, char *tblid)
732
{
733
  if (!uiout->impl->table_begin)
734
    return;
735
  uiout->impl->table_begin (uiout, nbrofcols, tblid);
736
}
737
 
738
void
739
uo_table_body (struct ui_out *uiout)
740
{
741
  if (!uiout->impl->table_body)
742
    return;
743
  uiout->impl->table_body (uiout);
744
}
745
 
746
void
747
uo_table_end (struct ui_out *uiout)
748
{
749
  if (!uiout->impl->table_end)
750
    return;
751
  uiout->impl->table_end (uiout);
752
}
753
 
754
void
755
uo_table_header (struct ui_out *uiout, int width, enum ui_align align, char *colhdr)
756
{
757
  if (!uiout->impl->table_header)
758
    return;
759
  uiout->impl->table_header (uiout, width, align, colhdr);
760
}
761
 
762
void
763
uo_list_begin (struct ui_out *uiout, int list_flag, char *lstid)
764
{
765
  if (!uiout->impl->list_begin)
766
    return;
767
  uiout->impl->list_begin (uiout, list_flag, lstid);
768
}
769
 
770
void
771
uo_list_end (struct ui_out *uiout, int list_flag)
772
{
773
  if (!uiout->impl->list_end)
774
    return;
775
  uiout->impl->list_end (uiout, list_flag);
776
}
777
 
778
void
779
uo_field_int (struct ui_out *uiout, int fldno, int width, enum ui_align align, char *fldname, int value)
780
{
781
  if (!uiout->impl->field_int)
782
    return;
783
  uiout->impl->field_int (uiout, fldno, width, align, fldname, value);
784
}
785
 
786
void
787
uo_field_skip (struct ui_out *uiout, int fldno, int width, enum ui_align align, char *fldname)
788
{
789
  if (!uiout->impl->field_skip)
790
    return;
791
  uiout->impl->field_skip (uiout, fldno, width, align, fldname);
792
}
793
 
794
void
795
uo_field_string (struct ui_out *uiout, int fldno, int width,
796
                 enum ui_align align, char *fldname, const char *string)
797
{
798
  if (!uiout->impl->field_string)
799
    return;
800
  uiout->impl->field_string (uiout, fldno, width, align, fldname, string);
801
}
802
 
803
void
804
uo_field_fmt (struct ui_out *uiout, int fldno, int width, enum ui_align align, char *fldname, char *format, va_list args)
805
{
806
  if (!uiout->impl->field_fmt)
807
    return;
808
  uiout->impl->field_fmt (uiout, fldno, width, align, fldname, format, args);
809
}
810
 
811
void
812
uo_spaces (struct ui_out *uiout, int numspaces)
813
{
814
  if (!uiout->impl->spaces)
815
    return;
816
  uiout->impl->spaces (uiout, numspaces);
817
}
818
 
819
void
820
uo_text (struct ui_out *uiout, char *string)
821
{
822
  if (!uiout->impl->text)
823
    return;
824
  uiout->impl->text (uiout, string);
825
}
826
 
827
void
828
uo_message (struct ui_out *uiout, int verbosity, char *format, va_list args)
829
{
830
  if (!uiout->impl->message)
831
    return;
832
  uiout->impl->message (uiout, verbosity, format, args);
833
}
834
 
835
void
836
uo_wrap_hint (struct ui_out *uiout, char *identstring)
837
{
838
  if (!uiout->impl->wrap_hint)
839
    return;
840
  uiout->impl->wrap_hint (uiout, identstring);
841
}
842
 
843
void
844
uo_flush (struct ui_out *uiout)
845
{
846
  if (!uiout->impl->flush)
847
    return;
848
  uiout->impl->flush (uiout);
849
}
850
 
851
/* local functions */
852
 
853
/* list of column headers manipulation routines */
854
 
855
static void
856
clear_header_list (uiout)
857
     struct ui_out *uiout;
858
{
859
  while (uiout->headerfirst != NULL)
860
    {
861
      uiout->headercurr = uiout->headerfirst;
862
      uiout->headerfirst = uiout->headerfirst->next;
863
      if (uiout->headercurr->colhdr != NULL)
864
        free (uiout->headercurr->colhdr);
865
      free (uiout->headercurr);
866
    }
867
  uiout->headerlast = NULL;
868
  uiout->headercurr = NULL;
869
}
870
 
871
static void
872
append_header_to_list (struct ui_out *uiout,
873
                       int width,
874
                       int alignment,
875
                       char *colhdr)
876
{
877
  struct ui_out_hdr *temphdr;
878
 
879
  temphdr = XMALLOC (struct ui_out_hdr);
880
  temphdr->width = width;
881
  temphdr->alignment = alignment;
882
  /* we have to copy the column title as the original may be an automatic */
883
  if (colhdr != NULL)
884
    {
885
      temphdr->colhdr = xmalloc (strlen (colhdr) + 1);
886
      strcpy (temphdr->colhdr, colhdr);
887
    }
888
  temphdr->next = NULL;
889
  if (uiout->headerfirst == NULL)
890
    {
891
      temphdr->colno = 1;
892
      uiout->headerfirst = temphdr;
893
      uiout->headerlast = temphdr;
894
    }
895
  else
896
    {
897
      temphdr->colno = uiout->headerlast->colno + 1;
898
      uiout->headerlast->next = temphdr;
899
      uiout->headerlast = temphdr;
900
    }
901
  uiout->headercurr = uiout->headerlast;
902
}
903
 
904
/* returns 0 if there is no more headers */
905
 
906
static int
907
get_curr_header (struct ui_out *uiout,
908
                 int *colno,
909
                 int *width,
910
                 int *alignment,
911
                 char **colhdr)
912
{
913
  /* There may be no headers at all or we may have used all columns */
914
  if (uiout->headercurr == NULL)
915
    return 0;
916
  *colno = uiout->headercurr->colno;
917
  *width = uiout->headercurr->width;
918
  *alignment = uiout->headercurr->alignment;
919
  *colhdr = uiout->headercurr->colhdr;
920
  uiout->headercurr = uiout->headercurr->next;
921
  return 1;
922
}
923
 
924
/* makes sure the field_* calls were properly placed */
925
 
926
static void
927
verify_field_proper_position (struct ui_out *uiout)
928
{
929
  if (uiout->table_flag)
930
    {
931
      if (!uiout->body_flag)
932
        internal_error ("ui_out: table_body missing; table fields must be \
933
specified after table_body and inside a list.");
934
      if (!uiout->list_flag)
935
        internal_error ("ui_out: list_begin missing; table fields must be \
936
specified after table_body and inside a list.");
937
    }
938
}
939
 
940
/* determines what is the alignment policy */
941
 
942
static void
943
verify_field_alignment (struct ui_out *uiout,
944
                        int fldno,
945
                        int *width,
946
                        int *align)
947
{
948
  int colno;
949
  char *text;
950
 
951
  if (uiout->table_flag
952
      && get_curr_header (uiout, &colno, width, align, &text))
953
    {
954
      if (fldno != colno)
955
        internal_error ("gdb/ui-out.c: ui-out internal error in handling headers.");
956
    }
957
  else
958
    {
959
      *width = 0;
960
      *align = ui_noalign;
961
    }
962
}
963
 
964
/* access to ui_out format private members */
965
 
966
void
967
ui_out_get_field_separator (uiout)
968
     struct ui_out *uiout;
969
{
970
}
971
 
972
/* Access to ui-out members data */
973
 
974
struct ui_out_data *
975
ui_out_data (struct ui_out *uiout)
976
{
977
  return uiout->data;
978
}
979
 
980
/* initalize private members at startup */
981
 
982
struct ui_out *
983
ui_out_new (struct ui_out_impl *impl,
984
            struct ui_out_data *data,
985
            int flags)
986
{
987
  struct ui_out *uiout = XMALLOC (struct ui_out);
988
  uiout->data = data;
989
  uiout->impl = impl;
990
  uiout->flags = flags;
991
  uiout->table_flag = 0;
992
  uiout->body_flag = 0;
993
  uiout->list_flag = 0;
994
  uiout->field_count[0] = 0;
995
  uiout->headerfirst = NULL;
996
  uiout->headerlast = NULL;
997
  uiout->headercurr = NULL;
998
  return uiout;
999
}
1000
 
1001
/* standard gdb initialization hook */
1002
 
1003
void
1004
_initialize_ui_out ()
1005
{
1006
  /* nothing needs to be done */
1007
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.