forked from crash-utility/crash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
defs.h
5976 lines (5441 loc) · 182 KB
/
defs.h
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
/* defs.h - core analysis suite
*
* Copyright (C) 1999, 2000, 2001, 2002 Mission Critical Linux, Inc.
* Copyright (C) 2002-2014 David Anderson
* Copyright (C) 2002-2014 Red Hat, Inc. All rights reserved.
* Copyright (C) 2002 Silicon Graphics, Inc.
*
* 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 of the License, 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.
*/
#ifndef GDB_COMMON
#include <stdio.h>
#include <stdarg.h>
#include <stdint.h>
#include <termios.h>
#include <unistd.h>
#include <sys/mman.h>
#include <setjmp.h>
#undef basename
#if !defined(__USE_GNU)
#define __USE_GNU
#include <string.h>
#undef __USE_GNU
#else
#include <string.h>
#endif
#include <fcntl.h>
#include <stdlib.h>
#include <signal.h>
#include <assert.h>
#include <errno.h>
#include <dirent.h>
#include <time.h>
#include <zlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <sys/wait.h>
#include <sys/time.h>
#include <execinfo.h> /* backtrace() */
#include <regex.h>
#ifdef LZO
#include <lzo/lzo1x.h>
#endif
#ifdef SNAPPY
#include <snappy-c.h>
#endif
#ifndef ATTRIBUTE_UNUSED
#define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
#endif
#define BASELEVEL_REVISION "7.0.5"
#undef TRUE
#undef FALSE
#define TRUE (1)
#define FALSE (0)
#define STR(x) #x
#ifndef offsetof
# define offsetof(TYPE, MEMBER) ((ulong)&((TYPE *)0)->MEMBER)
#endif
#if !defined(X86) && !defined(X86_64) && !defined(ALPHA) && !defined(PPC) && \
!defined(IA64) && !defined(PPC64) && !defined(S390) && !defined(S390X) && \
!defined(ARM) && !defined(ARM64)
#ifdef __alpha__
#define ALPHA
#endif
#ifdef __i386__
#define X86
#endif
#ifdef __powerpc__
#define PPC
#endif
#ifdef __ia64__
#define IA64
#endif
#ifdef __s390__
#define S390
#endif
#ifdef __s390x__
#define S390X
#endif
#ifdef __powerpc64__
#define PPC64
#endif
#ifdef __x86_64__
#define X86_64
#endif
#ifdef __arm__
#define ARM
#endif
#ifdef __aarch64__
#define ARM64
#endif
#endif
#ifdef X86
#define NR_CPUS (256)
#endif
#ifdef X86_64
#define NR_CPUS (8192)
#endif
#ifdef ALPHA
#define NR_CPUS (64)
#endif
#ifdef PPC
#define NR_CPUS (32)
#endif
#ifdef IA64
#define NR_CPUS (4096)
#endif
#ifdef PPC64
#define NR_CPUS (2048)
#endif
#ifdef S390
#define NR_CPUS (512)
#endif
#ifdef S390X
#define NR_CPUS (512)
#endif
#ifdef ARM
#define NR_CPUS (4)
#endif
#ifdef ARM64
#define NR_CPUS (4096) /* TBD */
#endif
#define BUFSIZE (1500)
#define NULLCHAR ('\0')
#define MAXARGS (100) /* max number of arguments to one function */
#define MAXARGLEN (40) /* max length of argument */
#define HIST_BLKSIZE (4096)
static inline int string_exists(char *s) { return (s ? TRUE : FALSE); }
#define STREQ(A, B) (string_exists((char *)A) && string_exists((char *)B) && \
(strcmp((char *)(A), (char *)(B)) == 0))
#define STRNEQ(A, B) (string_exists((char *)A) && string_exists((char *)B) && \
(strncmp((char *)(A), (char *)(B), strlen((char *)(B))) == 0))
#define BZERO(S, N) (memset(S, NULLCHAR, N))
#define BCOPY(S, D, C) (memcpy(D, S, C))
#define BNEG(S, N) (memset(S, 0xff, N))
#define BEEP() fprintf(stderr, "%c", 0x7)
#define LASTCHAR(s) (s[strlen(s)-1])
#define FIRSTCHAR(s) (s[0])
#define QUOTED_STRING(s) ((FIRSTCHAR(s) == '"') && (LASTCHAR(s) == '"'))
#define SINGLE_QUOTED_STRING(s) ((FIRSTCHAR(s) == '\'') && (LASTCHAR(s) == '\''))
#define PATHEQ(A, B) ((A) && (B) && (pathcmp((char *)(A), (char *)(B)) == 0))
#ifdef roundup
#undef roundup
#endif
#define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
typedef uint64_t physaddr_t;
#define PADDR_NOT_AVAILABLE (0x1ULL)
typedef unsigned long long int ulonglong;
struct number_option {
ulong num;
ulonglong ll_num;
ulong retflags;
};
/*
* program_context flags
*/
#define LIVE_SYSTEM (0x1ULL)
#define TTY (0x2ULL)
#define RUNTIME (0x4ULL)
#define IN_FOREACH (0x8ULL)
#define MCLXCD (0x10ULL)
#define CMDLINE_IFILE (0x20ULL)
#define MFD_RDWR (0x40ULL)
#define KVMDUMP (0x80ULL)
#define SILENT (0x100ULL)
#define SADUMP (0x200ULL)
#define HASH (0x400ULL)
#define SCROLL (0x800ULL)
#define NO_CONSOLE (0x1000ULL)
#define RUNTIME_IFILE (0x2000ULL)
#define DROP_CORE (0x4000ULL)
#define LKCD (0x8000ULL)
#define GDB_INIT (0x10000ULL)
#define IN_GDB (0x20000ULL)
#define RCLOCAL_IFILE (0x40000ULL)
#define RCHOME_IFILE (0x80000ULL)
#define GET_TIMESTAMP (0x100000ULL)
#define READLINE (0x200000ULL)
#define _SIGINT_ (0x400000ULL)
#define IN_RESTART (0x800000ULL)
#define KERNEL_DEBUG_QUERY (0x1000000ULL)
#define DEVMEM (0x2000000ULL)
#define REM_LIVE_SYSTEM (0x4000000ULL)
#define NAMELIST_LOCAL (0x8000000ULL)
#define MEMSRC_LOCAL (0x10000000ULL)
#define NAMELIST_SAVED (0x20000000ULL)
#define DUMPFILE_SAVED (0x40000000ULL)
#define UNLINK_NAMELIST (0x80000000ULL)
#define NAMELIST_UNLINKED (0x100000000ULL)
#define REM_MCLXCD (0x200000000ULL)
#define REM_LKCD (0x400000000ULL)
#define NAMELIST_NO_GZIP (0x800000000ULL)
#define UNLINK_MODULES (0x1000000000ULL)
#define S390D (0x2000000000ULL)
#define REM_S390D (0x4000000000ULL)
#define SYSRQ (0x8000000000ULL)
#define KDUMP (0x10000000000ULL)
#define NETDUMP (0x20000000000ULL)
#define REM_NETDUMP (0x40000000000ULL)
#define SYSMAP (0x80000000000ULL)
#define SYSMAP_ARG (0x100000000000ULL)
#define MEMMOD (0x200000000000ULL)
#define MODPRELOAD (0x400000000000ULL)
#define DISKDUMP (0x800000000000ULL)
#define DATADEBUG (0x1000000000000ULL)
#define FINDKERNEL (0x2000000000000ULL)
#define VERSION_QUERY (0x4000000000000ULL)
#define READNOW (0x8000000000000ULL)
#define NOCRASHRC (0x10000000000000ULL)
#define INIT_IFILE (0x20000000000000ULL)
#define XENDUMP (0x40000000000000ULL)
#define XEN_HYPER (0x80000000000000ULL)
#define XEN_CORE (0x100000000000000ULL)
#define PLEASE_WAIT (0x200000000000000ULL)
#define IFILE_ERROR (0x400000000000000ULL)
#define KERNTYPES (0x800000000000000ULL)
#define MINIMAL_MODE (0x1000000000000000ULL)
#define CRASHBUILTIN (0x2000000000000000ULL)
#define PRELOAD_EXTENSIONS \
(0x4000000000000000ULL)
#define PROC_KCORE (0x8000000000000000ULL)
#define ACTIVE() (pc->flags & LIVE_SYSTEM)
#define DUMPFILE() (!(pc->flags & LIVE_SYSTEM))
#define LIVE() (pc->flags2 & LIVE_DUMP || pc->flags & LIVE_SYSTEM)
#define MEMORY_SOURCES (NETDUMP|KDUMP|MCLXCD|LKCD|DEVMEM|S390D|MEMMOD|DISKDUMP|XENDUMP|CRASHBUILTIN|KVMDUMP|PROC_KCORE|SADUMP)
#define DUMPFILE_TYPES (DISKDUMP|NETDUMP|KDUMP|MCLXCD|LKCD|S390D|XENDUMP|KVMDUMP|SADUMP)
#define REMOTE() (pc->flags2 & REMOTE_DAEMON)
#define REMOTE_ACTIVE() (pc->flags & REM_LIVE_SYSTEM)
#define REMOTE_DUMPFILE() \
(pc->flags & (REM_NETDUMP|REM_MCLXCD|REM_LKCD|REM_S390D))
#define REMOTE_MEMSRC() (REMOTE_ACTIVE() || REMOTE_PAUSED() || REMOTE_DUMPFILE())
#define LKCD_DUMPFILE() (pc->flags & (LKCD|REM_LKCD))
#define NETDUMP_DUMPFILE() (pc->flags & (NETDUMP|REM_NETDUMP))
#define DISKDUMP_DUMPFILE() (pc->flags & DISKDUMP)
#define KDUMP_DUMPFILE() (pc->flags & KDUMP)
#define XENDUMP_DUMPFILE() (pc->flags & XENDUMP)
#define XEN_HYPER_MODE() (pc->flags & XEN_HYPER)
#define SYSRQ_TASK(X) ((pc->flags & SYSRQ) && is_task_active(X))
#define XEN_CORE_DUMPFILE() (pc->flags & XEN_CORE)
#define LKCD_KERNTYPES() (pc->flags & KERNTYPES)
#define KVMDUMP_DUMPFILE() (pc->flags & KVMDUMP)
#define SADUMP_DUMPFILE() (pc->flags & SADUMP)
#define NETDUMP_LOCAL (0x1) /* netdump_data flags */
#define NETDUMP_REMOTE (0x2)
#define VMCORE_VALID() (nd->flags & (NETDUMP_LOCAL|NETDUMP_REMOTE|KDUMP_LOCAL))
#define NETDUMP_ELF32 (0x4)
#define NETDUMP_ELF64 (0x8)
#define PARTIAL_DUMP (0x10) /* netdump or diskdump */
#define KDUMP_ELF32 (0x20)
#define KDUMP_ELF64 (0x40)
#define KDUMP_LOCAL (0x80)
#define KCORE_LOCAL (0x100)
#define KCORE_ELF32 (0x200)
#define KCORE_ELF64 (0x400)
#define QEMU_MEM_DUMP_KDUMP_BACKUP \
(0x800)
#define KVMDUMP_LOCAL (0x1)
#define KVMDUMP_VALID() (kvm->flags & (KVMDUMP_LOCAL))
#define DUMPFILE_FORMAT(flags) ((flags) & \
(NETDUMP_ELF32|NETDUMP_ELF64|KDUMP_ELF32|KDUMP_ELF64))
#define DISKDUMP_LOCAL (0x1)
#define KDUMP_CMPRS_LOCAL (0x2)
#define ERROR_EXCLUDED (0x4)
#define ZERO_EXCLUDED (0x8)
#define DUMPFILE_SPLIT (0x10)
#define NO_ELF_NOTES (0x20)
#define LZO_SUPPORTED (0x40)
#define SNAPPY_SUPPORTED (0x80)
#define DISKDUMP_VALID() (dd->flags & DISKDUMP_LOCAL)
#define KDUMP_CMPRS_VALID() (dd->flags & KDUMP_CMPRS_LOCAL)
#define KDUMP_SPLIT() (dd->flags & DUMPFILE_SPLIT)
#define XENDUMP_LOCAL (0x1)
#define XENDUMP_VALID() (xd->flags & XENDUMP_LOCAL)
#define SADUMP_LOCAL (0x1)
#define SADUMP_DISKSET (0x2)
#define SADUMP_MEDIA (0x4)
#define SADUMP_ZERO_EXCLUDED (0x8)
#define SADUMP_KDUMP_BACKUP (0x10)
#define SADUMP_VALID() (sd->flags & SADUMP_LOCAL)
#define CRASHDEBUG(x) (pc->debug >= (x))
#define CRASHDEBUG_SUSPEND(X) { pc->debug_save = pc->debug; pc->debug = X; }
#define CRASHDEBUG_RESTORE() { pc->debug = pc->debug_save; }
#define VERBOSE (0x1)
#define ADDRESS_SPECIFIED (0x2)
#define FAULT_ON_ERROR (0x1)
#define RETURN_ON_ERROR (0x2)
#define QUIET (0x4)
#define HEX_BIAS (0x8)
#define LONG_LONG (0x10)
#define RETURN_PARTIAL (0x20)
#define SEEK_ERROR (-1)
#define READ_ERROR (-2)
#define WRITE_ERROR (-3)
#define PAGE_EXCLUDED (-4)
#define RESTART() (longjmp(pc->main_loop_env, 1))
#define RESUME_FOREACH() (longjmp(pc->foreach_loop_env, 1))
#define INFO (1)
#define FATAL (2)
#define FATAL_RESTART (3)
#define WARNING (4)
#define NOTE (5)
#define CONT (6)
#define FATAL_ERROR(x) (((x) == FATAL) || ((x) == FATAL_RESTART))
#define CONSOLE_OFF(x) ((x) = console_off())
#define CONSOLE_ON(x) (console_on(x))
#define RADIX(X) (X)
#define NUM_HEX (0x1)
#define NUM_DEC (0x2)
#define NUM_EXPR (0x4)
#define NUM_ANY (NUM_HEX|NUM_DEC|NUM_EXPR)
/*
* program context redirect flags
*/
#define FROM_COMMAND_LINE (0x1)
#define FROM_INPUT_FILE (0x2)
#define REDIRECT_NOT_DONE (0x4)
#define REDIRECT_TO_PIPE (0x8)
#define REDIRECT_TO_STDPIPE (0x10)
#define REDIRECT_TO_FILE (0x20)
#define REDIRECT_FAILURE (0x40)
#define REDIRECT_SHELL_ESCAPE (0x80)
#define REDIRECT_SHELL_COMMAND (0x100)
#define REDIRECT_PID_KNOWN (0x200)
#define REDIRECT_MULTI_PIPE (0x400)
#define PIPE_OPTIONS (FROM_COMMAND_LINE | FROM_INPUT_FILE | REDIRECT_TO_PIPE | \
REDIRECT_TO_STDPIPE | REDIRECT_TO_FILE)
#define DEFAULT_REDHAT_DEBUG_LOCATION "/usr/lib/debug/lib/modules"
#define MEMORY_DRIVER_MODULE "crash"
#define MEMORY_DRIVER_DEVICE "/dev/crash"
#define MEMORY_DRIVER_DEVICE_MODE (S_IFCHR|S_IRUSR)
/*
* structure definitions
*/
struct program_context {
char *program_name; /* this program's name */
char *program_path; /* unadulterated argv[0] */
char *program_version; /* this program's version */
char *gdb_version; /* embedded gdb version */
char *prompt; /* this program's prompt */
unsigned long long flags; /* flags from above */
char *namelist; /* linux namelist */
char *dumpfile; /* dumpfile or /dev/kmem */
char *live_memsrc; /* live memory driver */
char *system_map; /* get symbol values from System.map */
char *namelist_debug; /* namelist containing debug data */
char *debuginfo_file; /* separate debuginfo file */
char *memory_module; /* alternative to mem.c driver */
char *memory_device; /* alternative to /dev/[k]mem device */
char *machine_type; /* machine's processor type */
char *editing_mode; /* readline vi or emacs */
char *server; /* network daemon */
char *server_memsrc; /* memory source on server */
char *server_namelist; /* kernel namelist on server */
int nfd; /* linux namelist fd */
int mfd; /* /dev/mem fd */
int kfd; /* /dev/kmem fd */
int dfd; /* dumpfile fd */
int confd; /* console fd */
int sockfd; /* network daemon socket */
ushort port; /* network daemon port */
int rmfd; /* remote server memory source fd */
int rkfd; /* remote server /dev/kmem fd */
ulong program_pid; /* program pid */
ulong server_pid; /* server pid */
ulong rcvbufsize; /* client-side receive buffer size */
char *home; /* user's home directory */
char command_line[BUFSIZE]; /* possibly parsed input command line */
char orig_line[BUFSIZE]; /* original input line */
char *readline; /* pointer to last readline() return */
char my_tty[10]; /* real tty name (shown by ps -ef) */
ulong debug; /* level of debug */
ulong debug_save; /* saved level for debug-suspend */
char *console; /* current debug console device */
char *redhat_debug_loc; /* location of matching debug objects */
int pipefd[2]; /* output pipe file descriptors */
FILE *nullfp; /* bitbucket */
FILE *stdpipe; /* standard pipe for output */
FILE *pipe; /* command line specified pipe */
FILE *ofile; /* command line specified output file */
FILE *ifile; /* command line specified input file */
FILE *ifile_pipe; /* output pipe specified from file */
FILE *ifile_ofile; /* output file specified from file */
FILE *symfile; /* symbol table data file */
FILE *symfile2; /* alternate access to above */
FILE *tmpfile; /* tmpfile for selective data output */
FILE *saved_fp; /* for printing while parsing tmpfile */
FILE *tmp_fp; /* stored tmpfile pointer */
char *input_file; /* input file specified at invocation */
FILE *tmpfile2; /* tmpfile2 does not use save_fp! */
int eoc_index; /* end of redirected command index */
int scroll_command; /* default scroll command for output */
#define SCROLL_NONE 0
#define SCROLL_LESS 1
#define SCROLL_MORE 2
#define SCROLL_CRASHPAGER 3
ulong redirect; /* per-cmd origin and output flags */
pid_t stdpipe_pid; /* per-cmd standard output pipe's pid */
pid_t pipe_pid; /* per-cmd output pipe's pid */
pid_t pipe_shell_pid; /* per-cmd output pipe's shell pid */
char pipe_command[BUFSIZE]; /* pipe command line */
struct command_table_entry *cmd_table; /* linux/xen command table */
char *curcmd; /* currently-executing command */
char *lastcmd; /* previously-executed command */
ulong cmdgencur; /* current command generation number */
ulong curcmd_flags; /* general purpose per-command flag */
#define XEN_MACHINE_ADDR (0x1)
#define REPEAT (0x2)
#define IDLE_TASK_SHOWN (0x4)
#define TASK_SPECIFIED (0x8)
#define MEMTYPE_UVADDR (0x10)
#define MEMTYPE_FILEADDR (0x20)
#define HEADER_PRINTED (0x40)
#define BAD_INSTRUCTION (0x80)
#define UD2A_INSTRUCTION (0x100)
#define IRQ_IN_USE (0x200)
#define NO_MODIFY (0x400)
#define IGNORE_ERRORS (0x800)
#define FROM_RCFILE (0x1000)
#define MEMTYPE_KVADDR (0x2000)
#define MOD_SECTIONS (0x4000)
#define MOD_READNOW (0x8000)
ulonglong curcmd_private; /* general purpose per-command info */
int cur_gdb_cmd; /* current gdb command */
int last_gdb_cmd; /* previously-executed gdb command */
int sigint_cnt; /* number of ignored SIGINTs */
struct gnu_request *cur_req; /* current gdb gnu_request */
struct sigaction sigaction; /* general usage sigaction. */
struct sigaction gdb_sigaction; /* gdb's SIGINT sigaction. */
jmp_buf main_loop_env; /* longjmp target default */
jmp_buf foreach_loop_env; /* longjmp target within foreach */
jmp_buf gdb_interface_env; /* longjmp target for gdb error catch */
struct termios termios_orig; /* non-raw settings */
struct termios termios_raw; /* while gathering command input */
int ncmds; /* number of commands in menu */
char **cmdlist; /* current list of available commands */
int cmdlistsz; /* space available in cmdlist */
unsigned output_radix; /* current gdb output_radix */
void *sbrk; /* current sbrk value */
struct extension_table *curext; /* extension being loaded */
int (*readmem)(int, void *, int, ulong, physaddr_t); /* memory access */
int (*writemem)(int, void *, int, ulong, physaddr_t);/* memory access */
ulong ifile_in_progress; /* original xxx_IFILE flags */
off_t ifile_offset; /* current offset into input file */
char *runtime_ifile_cmd; /* runtime command using input file */
char *kvmdump_mapfile; /* storage of physical to file offsets */
ulonglong flags2; /* flags overrun */
#define FLAT (0x01ULL)
#define ELF_NOTES (0x02ULL)
#define GET_OSRELEASE (0x04ULL)
#define REMOTE_DAEMON (0x08ULL)
#define ERASEINFO_DATA (0x10ULL)
#define GDB_CMD_MODE (0x20ULL)
#define LIVE_DUMP (0x40ULL)
#define FLAT_FORMAT() (pc->flags2 & FLAT)
#define ELF_NOTES_VALID() (pc->flags2 & ELF_NOTES)
#define RADIX_OVERRIDE (0x80ULL)
#define QEMU_MEM_DUMP (0x100ULL)
#define GET_LOG (0x200ULL)
#define VMCOREINFO (0x400ULL)
#define ALLOW_FP (0x800ULL)
#define REM_PAUSED_F (0x1000ULL)
#define REMOTE_PAUSED() (pc->flags2 & REM_PAUSED_F)
char *cleanup;
char *namelist_orig;
char *namelist_debug_orig;
FILE *args_ifile; /* per-command args input file */
void (*cmd_cleanup)(void *); /* per-command cleanup function */
void *cmd_cleanup_arg; /* optional cleanup function argument */
ulong scope; /* optional text context address */
};
#define READMEM pc->readmem
typedef void (*cmd_func_t)(void);
struct command_table_entry { /* one for each command in menu */
char *name;
cmd_func_t func;
char **help_data;
ulong flags;
};
struct args_input_file {
int index;
int args_used;
int is_gdb_cmd;
int in_expression;
int start;
int resume;
char *fileptr;
};
#define REFRESH_TASK_TABLE (0x1) /* command_table_entry flags */
#define HIDDEN_COMMAND (0x2)
#define CLEANUP (0x4) /* for extensions only */
#define MINIMAL (0x8)
/*
* A linked list of extension table structures keeps track of the current
* set of shared library extensions.
*/
struct extension_table {
void *handle; /* handle from dlopen() */
char *filename; /* name of shared library */
struct command_table_entry *command_table; /* list of commands */
ulong flags; /* registration flags */
struct extension_table *next, *prev; /* bookkeeping */
};
#define REGISTERED (0x1) /* extension_table flags */
#define DUPLICATE_COMMAND_NAME (0x2)
#define NO_MINIMAL_COMMANDS (0x4)
struct new_utsname {
char sysname[65];
char nodename[65];
char release[65];
char version[65];
char machine[65];
char domainname[65];
};
#define NO_MODULE_ACCESS (0x1)
#define TVEC_BASES_V1 (0x2)
#define GCC_3_2 (0x4)
#define GCC_3_2_3 (0x8)
#define GCC_2_96 (0x10)
#define RA_SEEK (0x20)
#define NO_RA_SEEK (0x40)
#define KALLSYMS_V1 (0x80)
#define NO_KALLSYMS (0x100)
#define PER_CPU_OFF (0x200)
#define SMP (0x400)
#define GCC_3_3_2 (0x800)
#define KMOD_V1 (0x1000)
#define KMOD_V2 (0x2000)
#define KALLSYMS_V2 (0x2000)
#define TVEC_BASES_V2 (0x4000)
#define GCC_3_3_3 (0x8000)
#define USE_OLD_BT (0x10000)
#define ARCH_XEN (0x20000)
#define NO_IKCONFIG (0x40000)
#define DWARF_UNWIND (0x80000)
#define NO_DWARF_UNWIND (0x100000)
#define DWARF_UNWIND_MEMORY (0x200000)
#define DWARF_UNWIND_EH_FRAME (0x400000)
#define DWARF_UNWIND_CAPABLE (DWARF_UNWIND_MEMORY|DWARF_UNWIND_EH_FRAME)
#define DWARF_UNWIND_MODULES (0x800000)
#define BUGVERBOSE_OFF (0x1000000)
#define RELOC_SET (0x2000000)
#define RELOC_FORCE (0x4000000)
#define ARCH_OPENVZ (0x8000000)
#define ARCH_PVOPS (0x10000000)
#define PRE_KERNEL_INIT (0x20000000)
#define ARCH_PVOPS_XEN (0x40000000)
#define IRQ_DESC_TREE (0x80000000)
#define GCC_VERSION_DEPRECATED (GCC_3_2|GCC_3_2_3|GCC_2_96|GCC_3_3_2|GCC_3_3_3)
/* flags2 */
#define RELOC_AUTO (0x1ULL)
#define KASLR (0x2ULL)
#define XEN() (kt->flags & ARCH_XEN)
#define OPENVZ() (kt->flags & ARCH_OPENVZ)
#define PVOPS() (kt->flags & ARCH_PVOPS)
#define PVOPS_XEN() (kt->flags & ARCH_PVOPS_XEN)
#define XEN_MACHINE_TO_MFN(m) ((ulonglong)(m) >> PAGESHIFT())
#define XEN_PFN_TO_PSEUDO(p) ((ulonglong)(p) << PAGESHIFT())
#define XEN_MFN_NOT_FOUND (~0UL)
#define XEN_PFNS_PER_PAGE (PAGESIZE()/sizeof(ulong))
#define XEN_FOREIGN_FRAME (1UL << (BITS()-1))
#define XEN_MACHADDR_NOT_FOUND (~0ULL)
#define XEN_P2M_PER_PAGE (PAGESIZE() / sizeof(unsigned long))
#define XEN_P2M_MID_PER_PAGE (PAGESIZE() / sizeof(unsigned long *))
#define XEN_P2M_TOP_PER_PAGE (PAGESIZE() / sizeof(unsigned long **))
struct kernel_table { /* kernel data */
ulong flags;
ulong stext;
ulong etext;
ulong stext_init;
ulong etext_init;
ulong init_begin;
ulong init_end;
ulong end;
int cpus;
char *cpus_override;
void (*display_bh)(void);
ulong module_list;
ulong kernel_module;
int mods_installed;
struct timespec date;
char proc_version[BUFSIZE];
struct new_utsname utsname;
uint kernel_version[3];
uint gcc_version[3];
int runq_siblings;
int kernel_NR_CPUS;
long __per_cpu_offset[NR_CPUS];
long *__rq_idx;
long *__cpu_idx;
ulong *cpu_flags;
#define POSSIBLE (0x1)
#define PRESENT (0x2)
#define ONLINE (0x4)
#define NMI (0x8)
int BUG_bytes;
ulong xen_flags;
#define WRITABLE_PAGE_TABLES (0x1)
#define SHADOW_PAGE_TABLES (0x2)
#define CANONICAL_PAGE_TABLES (0x4)
#define XEN_SUSPEND (0x8)
char *m2p_page;
ulong phys_to_machine_mapping;
ulong p2m_table_size;
#define P2M_MAPPING_CACHE (512)
struct p2m_mapping_cache {
ulong mapping;
ulong pfn;
ulong start;
ulong end;
} p2m_mapping_cache[P2M_MAPPING_CACHE];
#define P2M_MAPPING_PAGE_PFN(c) \
(PVOPS_XEN() ? kt->p2m_mapping_cache[c].pfn : \
(((kt->p2m_mapping_cache[c].mapping - kt->phys_to_machine_mapping)/PAGESIZE()) \
* XEN_PFNS_PER_PAGE))
ulong last_mapping_read;
ulong p2m_cache_index;
ulong p2m_pages_searched;
ulong p2m_mfn_cache_hits;
ulong p2m_page_cache_hits;
ulong relocate;
char *module_tree;
struct pvops_xen_info {
int p2m_top_entries;
ulong p2m_top;
ulong p2m_mid_missing;
ulong p2m_missing;
} pvops_xen;
int highest_irq;
#define IKCONFIG_AVAIL 0x1 /* kernel contains ikconfig data */
#define IKCONFIG_LOADED 0x2 /* ikconfig data is currently loaded */
int ikconfig_flags;
int ikconfig_ents;
char *hypervisor;
struct vmcoreinfo_data {
ulong log_buf_SYMBOL;
ulong log_end_SYMBOL;
ulong log_buf_len_SYMBOL;
ulong logged_chars_SYMBOL;
ulong log_first_idx_SYMBOL;
ulong log_next_idx_SYMBOL;
long log_SIZE;
long log_ts_nsec_OFFSET;
long log_len_OFFSET;
long log_text_len_OFFSET;
long log_dict_len_OFFSET;
ulong phys_base_SYMBOL;
ulong _stext_SYMBOL;
} vmcoreinfo;
ulonglong flags2;
};
/*
* Aid for the two versions of the kernel's module list linkage.
*/
#define NEXT_MODULE(next_module, modbuf) \
{ \
switch (kt->flags & (KMOD_V1|KMOD_V2)) \
{ \
case KMOD_V1: \
next_module = ULONG(modbuf + OFFSET(module_next)); \
break; \
case KMOD_V2: \
next_module = ULONG(modbuf + OFFSET(module_list)); \
if (next_module != kt->kernel_module) \
next_module -= OFFSET(module_list); \
break; \
} \
}
#define THIS_KERNEL_VERSION ((kt->kernel_version[0] << 16) + \
(kt->kernel_version[1] << 8) + \
(kt->kernel_version[2]))
#define LINUX(x,y,z) (((uint)(x) << 16) + ((uint)(y) << 8) + (uint)(z))
#define THIS_GCC_VERSION ((kt->gcc_version[0] << 16) + \
(kt->gcc_version[1] << 8) + \
(kt->gcc_version[2]))
#define GCC(x,y,z) (((uint)(x) << 16) + ((uint)(y) << 8) + (uint)(z))
#define IS_KERNEL_STATIC_TEXT(x) (((ulong)(x) >= kt->stext) && \
((ulong)(x) < kt->etext))
#define TASK_COMM_LEN 16 /* task command name length including NULL */
struct task_context { /* context stored for each task */
ulong task;
ulong thread_info;
ulong pid;
char comm[TASK_COMM_LEN+1];
int processor;
ulong ptask;
ulong mm_struct;
struct task_context *tc_next;
};
struct task_table { /* kernel/local task table data */
struct task_context *current;
struct task_context *context_array;
void (*refresh_task_table)(void);
ulong flags;
ulong task_start;
ulong task_end;
void *task_local;
int max_tasks;
int nr_threads;
ulong running_tasks;
ulong retries;
ulong panicmsg;
int panic_processor;
ulong *idle_threads;
ulong *panic_threads;
ulong *active_set;
ulong *panic_ksp;
ulong *hardirq_ctx;
ulong *hardirq_tasks;
ulong *softirq_ctx;
ulong *softirq_tasks;
ulong panic_task;
ulong this_task;
int pidhash_len;
ulong pidhash_addr;
ulong last_task_read;
ulong last_thread_info_read;
ulong last_mm_read;
char *task_struct;
char *thread_info;
char *mm_struct;
ulong init_pid_ns;
};
#define TASK_INIT_DONE (0x1)
#define TASK_ARRAY_EXISTS (0x2)
#define PANIC_TASK_NOT_FOUND (0x4)
#define TASK_REFRESH (0x8)
#define TASK_REFRESH_OFF (0x10)
#define PANIC_KSP (0x20)
#define ACTIVE_SET (0x40)
#define POPULATE_PANIC (0x80)
#define PIDHASH (0x100)
#define PID_HASH (0x200)
#define THREAD_INFO (0x400)
#define IRQSTACKS (0x800)
#define TIMESPEC (0x1000)
#define NO_TIMESPEC (0x2000)
#define ACTIVE_ONLY (0x4000)
#define TASK_SLUSH (20)
#define NO_PROC_ID 0xFF /* No processor magic marker (from kernel) */
/*
* Global "tt" points to task_table
*/
#define CURRENT_CONTEXT() (tt->current)
#define CURRENT_TASK() (tt->current->task)
#define CURRENT_PID() (tt->current->pid)
#define CURRENT_COMM() (tt->current->comm)
#define RUNNING_TASKS() (tt->running_tasks)
#define FIRST_CONTEXT() (tt->context_array)
#define NO_PID ((ulong)-1)
#define NO_TASK (0)
#define IS_TASK_ADDR(X) (machdep->is_task_addr(X))
#define GET_STACKBASE(X) (machdep->get_stackbase(X))
#define GET_STACKTOP(X) (machdep->get_stacktop(X))
#define STACKSIZE() (machdep->stacksize)
#define LONGS_PER_STACK (machdep->stacksize/sizeof(ulong))
#define INSTACK(X,BT) \
(((ulong)(X) >= (BT)->stackbase) && ((ulong)(X) < (BT)->stacktop))
#define ALIGNED_STACK_OFFSET(task) ((ulong)(task) & (STACKSIZE()-1))
#define BITS() (machdep->bits)
#define BITS32() (machdep->bits == 32)
#define BITS64() (machdep->bits == 64)
#define IS_KVADDR(X) (machdep->is_kvaddr(X))
#define IS_UVADDR(X,C) (machdep->is_uvaddr(X,C))
#define PID_ALIVE(x) (kill(x, 0) == 0)
struct kernel_list_head {
struct kernel_list_head *next, *prev;
};
struct stack_hook {
ulong esp;
ulong eip;
};
struct bt_info {
ulong task;
ulonglong flags;
ulong instptr;
ulong stkptr;
ulong bptr;
ulong stackbase;
ulong stacktop;
char *stackbuf;
struct task_context *tc;
struct stack_hook *hp;
struct stack_hook *textlist;
struct reference *ref;
ulong frameptr;
char *call_target;
void *machdep;
ulong debug;
ulong eframe_ip;
ulong radix;
};
#define STACK_OFFSET_TYPE(OFF) \
(((ulong)(OFF) > STACKSIZE()) ? \
(ulong)((ulong)(OFF) - (ulong)(bt->stackbase)) : (ulong)(OFF))
#define GET_STACK_ULONG(OFF) \
*((ulong *)((char *)(&bt->stackbuf[(ulong)(STACK_OFFSET_TYPE(OFF))])))
#define GET_STACK_DATA(OFF, LOC, SZ) memcpy((void *)(LOC), \
(void *)(&bt->stackbuf[(ulong)STACK_OFFSET_TYPE(OFF)]), (size_t)(SZ))
struct machine_specific; /* uniquely defined below each machine's area */
struct xendump_data;
struct xen_kdump_data;
struct vaddr_range {
ulong start;
ulong end;
ulong type;
#define KVADDR_UNITY_MAP (1)
#define KVADDR_VMALLOC (2)
#define KVADDR_VMEMMAP (3)
#define KVADDR_START_MAP (4)
#define KVADDR_MODULES (5)
#define MAX_KVADDR_RANGES KVADDR_MODULES
};
#define MAX_MACHDEP_ARGS 5 /* for --machdep/-m machine-specific args */
struct machdep_table {
ulong flags;
ulong kvbase;
ulong identity_map_base;
uint pagesize;
uint pageshift;
ulonglong pagemask;
ulong pageoffset;
ulong stacksize;
uint hz;
ulong mhz;
int bits;
int nr_irqs;
uint64_t memsize;
int (*eframe_search)(struct bt_info *);
void (*back_trace)(struct bt_info *);
ulong (*processor_speed)(void);
int (*uvtop)(struct task_context *, ulong, physaddr_t *, int);
int (*kvtop)(struct task_context *, ulong, physaddr_t *, int);
ulong (*get_task_pgd)(ulong);
void (*dump_irq)(int);
void (*get_stack_frame)(struct bt_info *, ulong *, ulong *);
ulong (*get_stackbase)(ulong);
ulong (*get_stacktop)(ulong);
int (*translate_pte)(ulong, void *, ulonglong);
uint64_t (*memory_size)(void);
ulong (*vmalloc_start)(void);
int (*is_task_addr)(ulong);
int (*verify_symbol)(const char *, ulong, char);
int (*dis_filter)(ulong, char *, unsigned int);
int (*get_smp_cpus)(void);
int (*is_kvaddr)(ulong);
int (*is_uvaddr)(ulong, struct task_context *);
int (*verify_paddr)(uint64_t);
void (*cmd_mach)(void);
void (*init_kernel_pgd)(void);
struct syment *(*value_to_symbol)(ulong, ulong *);
struct line_number_hook {
char *func;
char **file;
} *line_number_hooks;
ulong last_pgd_read;
ulong last_pud_read;
ulong last_pmd_read;
ulong last_ptbl_read;
char *pgd;
char *pud;
char *pmd;
char *ptbl;
int ptrs_per_pgd;
char *cmdline_args[MAX_MACHDEP_ARGS];
struct machine_specific *machspec;
ulong section_size_bits;
ulong max_physmem_bits;
ulong sections_per_root;
int (*xendump_p2m_create)(struct xendump_data *);
ulong (*xendump_panic_task)(struct xendump_data *);
void (*get_xendump_regs)(struct xendump_data *, struct bt_info *, ulong *, ulong *);
void (*clear_machdep_cache)(void);
int (*xen_kdump_p2m_create)(struct xen_kdump_data *);
int (*in_alternate_stack)(int, ulong);
void (*dumpfile_init)(int, void *);
void (*process_elf_notes)(void *, unsigned long);
int (*get_kvaddr_ranges)(struct vaddr_range *);
int (*verify_line_number)(ulong, ulong, ulong);
void (*get_irq_affinity)(int);
void (*show_interrupts)(int, ulong *);
};
/*
* Processor-common flags; processor-specific flags use the lower bits
* as defined in their processor-specific files below. (see KSYMS_START defs).
*/
#define HWRESET (0x80000000)
#define OMIT_FRAME_PTR (0x40000000)
#define FRAMESIZE_DEBUG (0x20000000)
#define MACHDEP_BT_TEXT (0x10000000)
#define DEVMEMRD (0x8000000)
#define INIT (0x4000000)
#define VM_4_LEVEL (0x2000000)
#define MCA (0x1000000)
#define PAE (0x800000)
#define VMEMMAP (0x400000)
extern struct machdep_table *machdep;
#ifndef HZ
#define HZ sysconf(_SC_CLK_TCK)
#endif
#define IS_LAST_PGD_READ(pgd) ((ulong)(pgd) == machdep->last_pgd_read)
#define IS_LAST_PMD_READ(pmd) ((ulong)(pmd) == machdep->last_pmd_read)
#define IS_LAST_PTBL_READ(ptbl) ((ulong)(ptbl) == machdep->last_ptbl_read)
#define IS_LAST_PUD_READ(pud) ((ulong)(pud) == machdep->last_pud_read)
#define FILL_PGD(PGD, TYPE, SIZE) \
if (!IS_LAST_PGD_READ(PGD)) { \