2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
26 * Mach Operating System
27 * Copyright (c) 1991,1990 Carnegie Mellon University
28 * All Rights Reserved.
30 * Permission to use, copy, modify and distribute this software and its
31 * documentation is hereby granted, provided that both the copyright
32 * notice and this permission notice appear in all copies of the
33 * software, derivative works or modified versions, and any portions
34 * thereof, and that both notices appear in supporting documentation.
36 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
37 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
38 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
40 * Carnegie Mellon requests users of this software to return to
42 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
43 * School of Computer Science
44 * Carnegie Mellon University
45 * Pittsburgh PA 15213-3890
47 * any improvements or extensions that they make and grant Carnegie Mellon
48 * the rights to redistribute these changes.
53 * Author: David B. Golub, Carnegie Mellon University
57 #include <machine/db_machdep.h>
58 #include <string.h> /* For strcpy(), strcmp() */
59 #include <mach/std_types.h>
60 #include <kern/misc_protos.h> /* For printf() */
61 #include <ddb/db_sym.h>
62 #include <ddb/db_task_thread.h>
63 #include <ddb/db_command.h>
64 #include <ddb/db_output.h> /* For db_printf() */
66 #include <vm/vm_map.h> /* vm_map_t */
69 * Multiple symbol tables
71 * mach, bootstrap, name_server, default_pager, unix, 1 spare
73 #define MAXNOSYMTABS 6
75 db_symtab_t db_symtabs
[MAXNOSYMTABS
] = {{0}};
78 db_symtab_t
*db_last_symtab
;
80 unsigned long db_maxoff
= 0x4000;
82 unsigned long db_maxval
= (unsigned long)&end
;
83 natural_t db_minval
= 0x1000;
85 /* Prototypes for functions local to this file. XXX -- should be static!
87 static char *db_qualify(
89 register char *symtabname
);
96 boolean_t
db_symbol_is_ambiguous(char *name
);
98 void db_shorten_filename(char **filenamep
);
115 int (*compfun
)(char *, char *));
121 int (*compfun
)(char *, char *));
127 int (*compfun
)(char *, char *));
129 int no_print_completion(
132 int no_lookup_incomplete(
140 * Initialization routine for ddb.
150 * Add symbol table, with given name, to list of symbol tables.
160 unsigned long minsym
,
161 unsigned long maxsym
,
164 register db_symtab_t
*st
;
165 extern vm_map_t kernel_map
;
167 if (db_nsymtab
>= MAXNOSYMTABS
)
170 st
= &db_symtabs
[db_nsymtab
];
175 if (map_pointer
== (char *)kernel_map
||
176 (VM_MAX_ADDRESS
<= VM_MIN_KERNEL_ADDRESS
&&
177 VM_MIN_KERNEL_ADDRESS
<= minsym
))
180 st
->map_pointer
= map_pointer
;
181 strcpy(st
->name
, name
);
188 if (db_maxval
< maxsym
+ db_maxoff
)
189 db_maxval
= maxsym
+ db_maxoff
;
197 * db_qualify("vm_map", "ux") returns "ux::vm_map".
199 * Note: return value points to static data whose content is
200 * overwritten by each call... but in practice this seems okay.
205 register char *symtabname
)
207 static char tmp
[256];
211 while (*s
++ = *symtabname
++) {
215 while (*s
++ = *symname
++) {
227 if (!strcmp(src
, dst
))
230 return (!strcmp(src
+1,dst
));
241 sym
= db_lookup(name
);
242 if (sym
== DB_SYM_NULL
)
244 db_symbol_values(0, sym
, &name
, valuep
);
249 * Display list of possible completions for a symbol.
256 int symtab_start
= 0;
257 int symtab_end
= db_nsymtab
;
260 char *name
= (char *)0;
265 * Look for, remove, and remember any symbol table specifier.
267 for (cp
= symstr
; *cp
; cp
++) {
268 if (*cp
== ':' && cp
[1] == ':') {
270 for (i
= 0; i
< db_nsymtab
; i
++) {
271 if (! strcmp(symstr
, db_symtabs
[i
].name
)) {
285 * Look in the specified set of symbol tables.
286 * Return on first match.
288 for (i
= symtab_start
; i
< symtab_end
; i
++) {
289 if (X_db_print_completion(&db_symtabs
[i
], symstr
))
295 * Lookup a (perhaps incomplete) symbol.
296 * If the symbol has a qualifier (e.g., ux::vm_map),
297 * then only the specified symbol table will be searched;
298 * otherwise, all symbol tables will be searched.
301 db_lookup_incomplete(
306 int symtab_start
= 0;
307 int symtab_end
= db_nsymtab
;
310 char *name
= (char *)0;
315 * Look for, remove, and remember any symbol table specifier.
317 for (cp
= symstr
; *cp
; cp
++) {
318 if (*cp
== ':' && cp
[1] == ':') {
320 for (i
= 0; i
< db_nsymtab
; i
++) {
321 if (! strcmp(symstr
, db_symtabs
[i
].name
)) {
335 * Look in the specified set of symbol tables.
336 * Return on first match.
338 for (i
= symtab_start
; i
< symtab_end
; i
++) {
339 nsym
= X_db_lookup_incomplete(&db_symtabs
[i
], symstr
,
340 &name
, &len
, &toadd
);
343 len
= strlen(symstr
);
344 if (len
+ toadd
>= symlen
)
346 bcopy(&name
[len
], &symstr
[len
], toadd
);
347 symstr
[len
+ toadd
] = '\0';
357 * If the symbol has a qualifier (e.g., ux::vm_map),
358 * then only the specified symbol table will be searched;
359 * otherwise, all symbol tables will be searched.
362 db_lookup(char *symstr
)
366 int symtab_start
= 0;
367 int symtab_end
= db_nsymtab
;
371 * Look for, remove, and remember any symbol table specifier.
373 for (cp
= symstr
; *cp
; cp
++) {
374 if (*cp
== ':' && cp
[1] == ':') {
376 for (i
= 0; i
< db_nsymtab
; i
++) {
377 if (! strcmp(symstr
, db_symtabs
[i
].name
)) {
385 db_error("Invalid symbol table name\n");
391 * Look in the specified set of symbol tables.
392 * Return on first match.
394 for (i
= symtab_start
; i
< symtab_end
; i
++) {
395 if (sp
= X_db_lookup(&db_symtabs
[i
], symstr
)) {
396 db_last_symtab
= &db_symtabs
[i
];
404 * Print a symbol completion
407 db_sym_print_completion(
414 if (stab
!= db_symtabs
)
415 db_printf("%s::", stab
->name
);
422 db_printf(" [static from %s", fname
);
424 db_printf(":%d", line
);
431 * Common utility routine to parse a symbol string into a file
432 * name, a (possibly incomplete) symbol name without line number.
433 * This routine is called from aout_db_print_completion if the object
434 * dependent handler supports qualified search with a file name.
435 * It parses the symbol string, and call an object dependent routine
436 * with parsed file name and symbol name.
439 db_sym_parse_and_print_completion(
440 int (*func
)(db_symtab_t
*,
452 * disassemble the symbol into components: [file_name:]symbol
454 component
[0] = symstr
;
456 for (p
= symstr
, n
= 1; *p
; p
++) {
461 component
[n
++] = p
+1;
466 sym_name
= component
[0];
468 sym_name
= component
[1];
470 nsym
= func(symtab
, sym_name
);
474 component
[1][-1] = ':';
479 * Common utility routine to parse a symbol string into a file
480 * name, a (possibly incomplete) symbol name without line number.
481 * This routine is called from X_db_lookup_incomplete if the object
482 * dependent handler supports qualified search with a file name.
483 * It parses the symbol string, and call an object dependent routine
484 * with parsed file name and symbol name.
487 db_sym_parse_and_lookup_incomplete(
488 int (*func
)(db_symtab_t
*,
509 * disassemble the symbol into components: [file_name:]symbol
511 component
[0] = symstr
;
513 for (p
= symstr
, n
= 1; *p
; p
++) {
518 component
[n
++] = p
+1;
524 sym_name
= component
[0];
526 file_name
= component
[0];
527 sym_name
= component
[1];
529 nsym
= func(symtab
, file_name
, sym_name
, 0, (db_sym_t
*)0,
532 *toadd
= *len
- strlen(sym_name
);
535 component
[1][-1] = ':';
540 * Common utility routine to parse a symbol string into a file
541 * name, a symbol name and line number.
542 * This routine is called from aout_db_lookup if the object dependent
543 * handler supports qualified search with a file name or a line number.
544 * It parses the symbol string, and call an object dependent routine
545 * with parsed file name, symbol name and line number.
548 db_sym_parse_and_lookup(
549 int (*func
)(db_symtab_t
*, char *, char *, int,
550 db_sym_t
*, char **, int *),
561 db_sym_t found
= DB_SYM_NULL
;
564 * disassemble the symbol into components:
565 * [file_name:]symbol[:line_nubmer]
567 component
[0] = symstr
;
568 component
[1] = component
[2] = 0;
569 for (p
= symstr
, n
= 1; *p
; p
++) {
574 component
[n
++] = p
+1;
582 if (*p
>= '0' && *p
<= '9') {
585 for (line_number
= 0; *p
; p
++) {
586 if (*p
< '0' || *p
> '9')
588 line_number
= line_number
*10 + *p
- '0';
594 for (p
= component
[0]; *p
&& *p
!= '.'; p
++);
596 file_name
= component
[0];
600 sym_name
= component
[0];
603 file_name
= component
[0];
604 sym_name
= component
[1];
606 (void) func(symtab
, file_name
, sym_name
, line_number
, &found
,
607 (char **)0, (int *)0);
611 component
[n
][-1] = ':';
616 * Does this symbol name appear in more than one symbol table?
617 * Used by db_symbol_values to decide whether to qualify a symbol.
619 boolean_t db_qualify_ambiguous_names
= TRUE
;
622 db_symbol_is_ambiguous(char *name
)
626 boolean_t found_once
= FALSE
;
628 if (!db_qualify_ambiguous_names
)
631 for (i
= 0; i
< db_nsymtab
; i
++) {
632 if (X_db_lookup(&db_symtabs
[i
], name
)) {
642 * Find the closest symbol to val, and return its name
643 * and the difference between val and the symbol found.
645 unsigned int db_search_maxoff
= 0x4000;
647 db_search_task_symbol(
648 register db_addr_t val
,
649 db_strategy_t strategy
,
650 db_addr_t
*offp
, /* better be unsigned */
653 unsigned long diff
, newdiff
;
656 db_sym_t ret
= DB_SYM_NULL
, sym
;
657 vm_map_t map_for_val
;
659 if (task
== TASK_NULL
)
660 task
= db_current_task();
661 map_for_val
= (task
== TASK_NULL
)? VM_MAP_NULL
: task
->map
;
663 newdiff
= diff
= ~0UL;
665 for (sp
= &db_symtabs
[0], i
= 0;
668 if (((vm_map_t
)sp
->map_pointer
== VM_MAP_NULL
||
669 (vm_map_t
)sp
->map_pointer
== map_for_val
) &&
671 ((unsigned long) val
>= sp
->minsym
&&
672 (unsigned long) val
<= sp
->maxsym
))) {
673 sym
= X_db_search_symbol(sp
, val
, strategy
,
674 (db_expr_t
*)&newdiff
);
675 if (newdiff
< diff
) {
679 if (diff
<= db_search_maxoff
)
684 if (ret
== DB_SYM_NULL
&& map_for_val
!= VM_MAP_NULL
) {
685 map_for_val
= VM_MAP_NULL
;
693 * Find the closest symbol to val, and return its name
694 * and the difference between val and the symbol found.
695 * Also return the filename and linenumber if available.
698 db_search_task_symbol_and_line(
699 register db_addr_t val
,
700 db_strategy_t strategy
,
707 unsigned long diff
, newdiff
;
710 db_sym_t ret
= DB_SYM_NULL
, sym
;
711 vm_map_t map_for_val
;
717 if (task
== TASK_NULL
)
718 task
= db_current_task();
719 map_for_val
= (task
== TASK_NULL
)? VM_MAP_NULL
: task
->map
;
720 *filenamep
= (char *) 0;
724 filename
= (char *) 0;
726 newdiff
= diff
= ~0UL;
728 for (sp
= &db_symtabs
[0], i
= 0;
731 if (((vm_map_t
)sp
->map_pointer
== VM_MAP_NULL
||
732 (vm_map_t
)sp
->map_pointer
== map_for_val
) &&
734 ((unsigned long) val
>= sp
->minsym
&&
735 (unsigned long) val
<= sp
->maxsym
))) {
736 sym
= X_db_search_by_addr(sp
, val
, &filename
, &func
,
737 &linenum
, (db_expr_t
*)&newdiff
,
739 if (sym
&& newdiff
< diff
) {
743 *filenamep
= filename
;
746 if (diff
<= db_search_maxoff
)
751 if (ret
== DB_SYM_NULL
&& map_for_val
!= VM_MAP_NULL
) {
752 map_for_val
= VM_MAP_NULL
;
757 db_shorten_filename(filenamep
);
762 * Return name and value of a symbol
774 if (sym
== DB_SYM_NULL
) {
779 stab
= db_last_symtab
;
781 X_db_symbol_values(stab
, sym
, &name
, &value
);
783 if (db_symbol_is_ambiguous(name
)) {
784 *namep
= db_qualify(name
, db_last_symtab
->name
);
794 * Print a the closest symbol to value
796 * After matching the symbol according to the given strategy
797 * we print it in the name+offset format, provided the symbol's
798 * value is close enough (eg smaller than db_maxoff).
799 * We also attempt to print [filename:linenum] when applicable
800 * (eg for procedure names).
802 * If we could not find a reasonable name+offset representation,
803 * then we just print the value in hex. Small values might get
804 * bogus symbol associations, e.g. 3 might get some absolute
805 * value like _INCLUDE_VERSION or something, therefore we do
806 * not accept symbols whose value is zero (and use plain hex).
812 db_strategy_t strategy
,
822 if (off
>= db_maxval
|| off
< db_minval
) {
823 db_printf("%#n", off
);
826 cursym
= db_search_task_symbol(off
, strategy
, &d
, task
);
828 db_symbol_values(0, cursym
, &name
, &value
);
829 if (name
== 0 || d
>= db_maxoff
|| value
== 0) {
830 db_printf("%#n", off
);
833 db_printf("%s", name
);
835 db_printf("+0x%x", d
);
836 if (strategy
== DB_STGY_PROC
) {
837 if (db_line_at_pc(cursym
, &filename
, &linenum
, off
)) {
838 db_printf(" [%s", filename
);
840 db_printf(":%d", linenum
);
847 * Return symbol name for a given offset and
848 * change the offset to be relative to this symbol.
849 * Very usefull for xpr, when you want to log offsets
850 * in a user friendly way.
853 char null_sym
[] = "";
856 db_get_sym(db_expr_t
*off
)
863 cursym
= db_search_symbol(*off
, DB_STGY_ANY
, &d
);
864 db_symbol_values(0, cursym
, &name
, &value
);
875 db_strategy_t strategy
)
877 db_task_printsym(off
, strategy
, TASK_NULL
);
880 int db_short_filename
= 1;
883 db_shorten_filename(char **filenamep
)
889 for (cp
= cp_slash
= *filenamep
; *cp
; cp
++) {
893 if (*cp_slash
== '/')
894 *filenamep
= cp_slash
+1;
908 db_strategy_t strategy
= DB_STGY_PROC
;
910 if (off
>= db_maxval
|| off
< db_minval
) {
911 db_printf("%#n", off
);
914 cursym
= db_search_task_symbol(off
, strategy
, &d
, task
);
916 db_symbol_values(0, cursym
, &name
, &value
);
917 if (name
== 0 || d
>= db_maxoff
|| value
== 0) {
920 if (db_line_at_pc(cursym
, &filename
, &linenum
, off
))
935 if (db_last_symtab
== 0)
937 if (X_db_line_at_pc( db_last_symtab
, sym
, filename
, linenum
, pc
)) {
938 if (db_short_filename
)
939 db_shorten_filename(filename
);
953 int (*compfun
)(char *, char *))
955 if (nbelts
<= 0 || eltsize
<= 0 || compfun
== 0) {
956 printf("qsort: invalid parameters\n");
959 qsort_recur(table
, table
+ nbelts
* eltsize
, eltsize
, compfun
);
962 qsort_checker(table
, nbelts
, eltsize
, compfun
);
975 for (; size
>= sizeof (int); size
-= sizeof (int), a
++, b
++) {
982 for (; size
> 0; size
--, aa
++, bb
++) {
989 /* rotate the three elements to the left */
1001 for (; size
>= sizeof (int); size
-= sizeof (int), a
++, b
++, c
++) {
1010 for (; size
> 0; size
--, aa
++, bb
++, cc
++) {
1023 int (*compfun
)(char *, char *))
1026 char *sameleft
, *sameright
;
1029 if (left
+ eltsize
- 1 >= right
) {
1033 /* partition element (reference for "same"ness */
1034 sameleft
= left
+ (((right
- left
) / eltsize
) / 2) * eltsize
;
1035 sameright
= sameleft
;
1038 j
= right
- eltsize
;
1041 while (i
< sameleft
) {
1044 comp
= (*compfun
)(i
, sameleft
);
1047 * Move to the "same" partition.
1050 * Shift the left part of the "same" partition to
1051 * the left, so that "same" elements stay in their
1054 sameleft
-= eltsize
;
1055 qsort_swap((int *) i
, (int *) sameleft
, eltsize
);
1056 } else if (comp
< 0) {
1058 * Stay in the "left" partition.
1063 * Should be moved to the "right" partition.
1064 * Wait until the next loop finds an appropriate
1065 * place to store this element.
1071 while (j
> sameright
) {
1074 comp
= (*compfun
)(sameright
, j
);
1077 * Move to the right of the "same" partition.
1079 sameright
+= eltsize
;
1080 qsort_swap((int *) sameright
, (int *) j
, eltsize
);
1081 } else if (comp
> 0) {
1083 * Move to the "left" partition.
1085 if (i
== sameleft
) {
1087 * Unfortunately, the "left" partition
1088 * has already been fully processed, so
1089 * we have to shift the "same" partition
1090 * to the right to free a "left" element.
1091 * This is done by moving the leftest same
1092 * to the right of the "same" partition.
1094 sameright
+= eltsize
;
1095 qsort_rotate((int *) sameleft
, (int*) sameright
,
1096 (int *) j
, eltsize
);
1097 sameleft
+= eltsize
;
1101 * Swap with the "left" partition element
1102 * waiting to be moved to the "right"
1105 qsort_swap((int *) i
, (int *) j
, eltsize
);
1108 * Go back to the 1st loop.
1115 * Stay in the "right" partition.
1121 if (i
!= sameleft
) {
1123 * The second loop completed (the"right" partition is ok),
1124 * but we have to go back to the first loop, and deal with
1125 * the element waiting for a place in the "right" partition.
1126 * Let's shift the "same" zone to the left.
1128 sameleft
-= eltsize
;
1129 qsort_rotate((int *) sameright
, (int *) sameleft
, (int *) i
,
1131 sameright
-= eltsize
;
1134 * Go back to 1st loop.
1140 * The partitions are correct now. Recur on the smallest side only.
1142 if (sameleft
- left
>= right
- (sameright
+ eltsize
)) {
1143 qsort_recur(sameright
+ eltsize
, right
, eltsize
, compfun
);
1145 * The "right" partition is now completely sorted.
1146 * The "same" partition is OK, so...
1147 * Ignore them, and start the loops again on the
1153 qsort_recur(left
, sameleft
, eltsize
, compfun
);
1155 * The "left" partition is now completely sorted.
1156 * The "same" partition is OK, so ...
1157 * Ignore them, and start the loops again on the
1158 * "right" partition.
1160 left
= sameright
+ eltsize
;
1170 int (*compfun
)(char *, char *))
1172 char *curr
, *prev
, *last
;
1175 curr
= prev
+ eltsize
;
1176 last
= table
+ (nbelts
* eltsize
);
1178 while (prev
< last
) {
1179 if ((*compfun
)(prev
, curr
) > 0) {
1180 printf("**** qsort_checker: error between 0x%x and 0x%x!!!\n", prev
, curr
);
1186 printf("qsort_checker: OK\n");
1189 int qsort_search_debug
= 0;
1192 db_qsort_limit_search(
1197 int (*compfun
)(char *, char *))
1199 register char *left
, *right
;
1200 char *oleft
, *oright
, *part
;
1204 oleft
= left
= *start
;
1205 oright
= right
= *end
;
1208 while (left
< right
) {
1210 part
= left
+ (((right
- left
) / eltsize
) / 2) * eltsize
;
1211 comp
= (*compfun
)(target
, part
);
1218 if (qsort_search_debug
> 1)
1219 printf(" [ Moved left from 0x%x to 0x%x]\n",
1221 } else if (comp
< 0) {
1225 if (qsort_search_debug
> 1)
1226 printf(" [ Moved right from 0x%x to 0x%x]\n",
1229 if (qsort_search_debug
> 1)
1230 printf(" [ FOUND! left=0x%x right=0x%x]\n",
1233 left
> *start
&& (*compfun
)(left
, part
) == 0;
1235 for (right
= part
+ eltsize
;
1236 right
< *end
&& (*compfun
)(right
, part
) == 0;
1244 if (qsort_search_debug
)
1245 printf("[ Limited from %x-%x to %x-%x in %d iters ]\n",
1246 *start
, *end
, oleft
, oright
, nbiter
);
1256 int (*compfun
)(char *, char *))
1262 end
= table
+ ((nbelts
-1) * eltsize
);
1265 for (p
= table
; p
< end
; p
+= eltsize
) {
1266 if ((*compfun
)(p
, p
+ eltsize
) > 0) {
1267 qsort_swap((int *) p
, (int *) (p
+ eltsize
),
1272 } while (sorted
== FALSE
);
1275 qsort_checker(table
, nbelts
, eltsize
, compfun
);
1278 vm_offset_t vm_min_inks_addr
= VM_MAX_KERNEL_ADDRESS
;
1284 /* save addr to demarcate kernel/inks boundary (1st time only) */
1285 if (vm_min_inks_addr
== VM_MAX_KERNEL_ADDRESS
) {
1286 vm_min_inks_addr
= base
;
1287 db_qualify_ambiguous_names
= TRUE
;
1294 char *clonee
, /* which symtab to clone */
1295 char *cloner
, /* in-kernel-server name */
1296 vm_offset_t base
) /* base address of cloner */
1298 db_symtab_t
*st
, *st_src
;
1302 extern vm_offset_t
kalloc(vm_size_t
);
1303 extern void db_clone_offsetXXX(char *, long);
1305 if (db_nsymtab
>= MAXNOSYMTABS
) {
1306 db_printf("db_clone_symtab: Too Many Symbol Tables\n");
1310 db_install_inks(base
);
1312 st
= &db_symtabs
[db_nsymtab
]; /* destination symtab */
1313 if ((st_src
= db_symtab_cloneeXXX(clonee
)) == 0) {
1314 db_printf("db_clone_symtab: clonee (%s) not found\n", clonee
);
1317 /* alloc new symbols */
1318 size
= (vm_size_t
)(st_src
->end
- st_src
->private);
1319 memp
= (char *)kalloc( round_page_32(size
) );
1321 db_printf("db_clone_symtab: no memory for symtab\n");
1325 *st
= *st_src
; /* bulk copy src -> dest */
1326 strcpy(st
->name
, cloner
); /* new name */
1327 st
->private = memp
; /* copy symbols */
1328 bcopy((const char *)st_src
->private, st
->private, size
);
1329 st
->start
= memp
+ sizeof(int); /* fixup pointers to symtab */
1330 st
->end
= memp
+ *(int *)memp
;
1331 st
->map_pointer
= 0; /* no map because kernel-loaded */
1333 /* Offset symbols, leaving strings pointing into st_src */
1334 offset
= base
- st_src
->minsym
;
1335 st
->minsym
+= offset
;
1336 st
->maxsym
+= offset
;
1337 db_clone_offsetXXX(memp
, offset
);
1340 db_printf( "[ cloned symbol table for %s: range 0x%x to 0x%x %s]\n",
1341 st
->name
, st
->minsym
, st
->maxsym
,
1342 st
->sorted
? "(sorted) " : "");
1343 db_maxval
= (unsigned int)st
->maxsym
+ db_maxoff
;
1347 db_symtab_cloneeXXX(
1350 db_symtab_t
*st
, *st_src
;
1352 st
= &db_symtabs
[db_nsymtab
]; /* destination symtab */
1353 for (st_src
= &db_symtabs
[0]; st_src
< st
; ++st_src
)
1354 if (!strcmp(clonee
, st_src
->name
))
1356 return ((st_src
< st
) ? st_src
: 0);
1360 * Switch into symbol-table specific routines
1363 #if !defined(__alpha) && !defined(INTEL860)
1368 #include <ddb/db_aout.h>
1372 #include <ddb/db_coff.h>
1375 static void no_init(void)
1378 db_printf("Non-existent code for ddb init\n");
1381 static boolean_t
no_sym_init(
1387 db_printf("Non-existent code for init of symtab %s\n", name
);
1391 static db_sym_t
no_lookup(
1395 db_printf("Bogus lookup of symbol %s\n", symstr
);
1399 static db_sym_t
no_search(
1402 db_strategy_t strategy
,
1405 db_printf("Bogus search for offset %#Xn", off
);
1409 static boolean_t
no_line_at_pc(
1416 db_printf("Bogus search for pc %#X\n", pc
);
1420 static void no_symbol_values(
1425 db_printf("Bogus symbol value resolution\n");
1426 if (namep
) *namep
= NULL
;
1427 if (valuep
) *valuep
= 0;
1430 static db_sym_t
no_search_by_addr(
1439 db_printf("Bogus search for address %#X\n", off
);
1444 no_print_completion(
1448 db_printf("Bogus print completion: not supported\n");
1453 no_lookup_incomplete(
1460 db_printf("Bogus lookup incomplete: not supported\n");
1465 { no_init, no_sym_init, no_lookup, no_search, \
1466 no_line_at_pc, no_symbol_values, no_search_by_addr, \
1467 no_print_completion, no_lookup_incomplete}
1469 struct db_sym_switch x_db
[] = {
1471 /* BSD a.out format (really, sdb/dbx(1) symtabs) */
1474 #else /* DB_NO_AOUT */
1475 { aout_db_init
, aout_db_sym_init
, aout_db_lookup
, aout_db_search_symbol
,
1476 aout_db_line_at_pc
, aout_db_symbol_values
, aout_db_search_by_addr
,
1477 aout_db_print_completion
, aout_db_lookup_incomplete
},
1478 #endif /* DB_NO_AOUT */
1482 #else /* DB_NO_COFF */
1483 { coff_db_init
, coff_db_sym_init
, coff_db_lookup
, coff_db_search_symbol
,
1484 coff_db_line_at_pc
, coff_db_symbol_values
, coff_db_search_by_addr
,
1485 coff_db_print_completion
, coff_db_lookup_incomplete
},
1486 #endif /* DB_NO_COFF */
1488 /* Machdep, not inited here */