diff options
author | peter <peter@FreeBSD.org> | 2001-06-13 10:58:39 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 2001-06-13 10:58:39 +0000 |
commit | f10fa038c14063eaf2da32ed734e644e5f569694 (patch) | |
tree | 88aef8097c80f09c2f725d61b6da4d433a595a61 /sys/ddb/db_command.c | |
parent | 2514663dd721b9ac234d35a4dac65dfc457ff6bc (diff) | |
download | FreeBSD-src-f10fa038c14063eaf2da32ed734e644e5f569694.zip FreeBSD-src-f10fa038c14063eaf2da32ed734e644e5f569694.tar.gz |
With this commit, I hereby pronounce gensetdefs past its use-by date.
Replace the a.out emulation of 'struct linker_set' with something
a little more flexible. <sys/linker_set.h> now provides macros for
accessing elements and completely hides the implementation.
The linker_set.h macros have been on the back burner in various
forms since 1998 and has ideas and code from Mike Smith (SET_FOREACH()),
John Polstra (ELF clue) and myself (cleaned up API and the conversion
of the rest of the kernel to use it).
The macros declare a strongly typed set. They return elements with the
type that you declare the set with, rather than a generic void *.
For ELF, we use the magic ld symbols (__start_<setname> and
__stop_<setname>). Thanks to Richard Henderson <rth@redhat.com> for the
trick about how to force ld to provide them for kld's.
For a.out, we use the old linker_set struct.
NOTE: the item lists are no longer null terminated. This is why
the code impact is high in certain areas.
The runtime linker has a new method to find the linker set
boundaries depending on which backend format is in use.
linker sets are still module/kld unfriendly and should never be used
for anything that may be modular one day.
Reviewed by: eivind
Diffstat (limited to 'sys/ddb/db_command.c')
-rw-r--r-- | sys/ddb/db_command.c | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/sys/ddb/db_command.c b/sys/ddb/db_command.c index 201d1f1..39378e9 100644 --- a/sys/ddb/db_command.c +++ b/sys/ddb/db_command.c @@ -51,13 +51,14 @@ * Exported global variables */ boolean_t db_cmd_loop_done; -extern struct linker_set db_cmd_set; db_addr_t db_dot; jmp_buf db_jmpbuf; db_addr_t db_last_addr; db_addr_t db_prev; db_addr_t db_next; -extern struct linker_set db_show_cmd_set; + +SET_DECLARE(db_cmd_set, struct command); +SET_DECLARE(db_show_cmd_set, struct command); static db_cmdfcn_t db_fncall; static db_cmdfcn_t db_gdb; @@ -94,22 +95,26 @@ db_skip_to_eol() #define CMD_HELP 4 static void db_cmd_list __P((struct command *table, - struct command **aux_tablep)); + struct command **aux_tablep, + struct command **aux_tablep_end)); static int db_cmd_search __P((char *name, struct command *table, struct command **aux_tablep, + struct command **aux_tablep_end, struct command **cmdp)); static void db_command __P((struct command **last_cmdp, struct command *cmd_table, - struct command **aux_cmd_tablep)); + struct command **aux_cmd_tablep, + struct command **aux_cmd_tablep_end)); /* * Search for command prefix. */ static int -db_cmd_search(name, table, aux_tablep, cmdp) +db_cmd_search(name, table, aux_tablep, aux_tablep_end, cmdp) char * name; struct command *table; struct command **aux_tablep; + struct command **aux_tablep_end; struct command **cmdp; /* out */ { struct command *cmd; @@ -148,7 +153,7 @@ db_cmd_search(name, table, aux_tablep, cmdp) } if (result == CMD_NONE && aux_tablep != 0) /* XXX repeat too much code. */ - for (aux_cmdp = aux_tablep; *aux_cmdp != 0; aux_cmdp++) { + for (aux_cmdp = aux_tablep; aux_cmdp < aux_tablep_end; aux_cmdp++) { register char *lp; register char *rp; register int c; @@ -188,9 +193,10 @@ db_cmd_search(name, table, aux_tablep, cmdp) } static void -db_cmd_list(table, aux_tablep) +db_cmd_list(table, aux_tablep, aux_tablep_end) struct command *table; struct command **aux_tablep; + struct command **aux_tablep_end; { register struct command *cmd; register struct command **aux_cmdp; @@ -201,17 +207,18 @@ db_cmd_list(table, aux_tablep) } if (aux_tablep == 0) return; - for (aux_cmdp = aux_tablep; *aux_cmdp != 0; aux_cmdp++) { + for (aux_cmdp = aux_tablep; aux_cmdp < aux_tablep_end; aux_cmdp++) { db_printf("%-12s", (*aux_cmdp)->name); db_end_line(); } } static void -db_command(last_cmdp, cmd_table, aux_cmd_tablep) +db_command(last_cmdp, cmd_table, aux_cmd_tablep, aux_cmd_tablep_end) struct command **last_cmdp; /* IN_OUT */ struct command *cmd_table; struct command **aux_cmd_tablep; + struct command **aux_cmd_tablep_end; { struct command *cmd; int t; @@ -246,6 +253,7 @@ db_command(last_cmdp, cmd_table, aux_cmd_tablep) result = db_cmd_search(db_tok_string, cmd_table, aux_cmd_tablep, + aux_cmd_tablep_end, &cmd); switch (result) { case CMD_NONE: @@ -257,7 +265,7 @@ db_command(last_cmdp, cmd_table, aux_cmd_tablep) db_flush_lex(); return; case CMD_HELP: - db_cmd_list(cmd_table, aux_cmd_tablep); + db_cmd_list(cmd_table, aux_cmd_tablep, aux_cmd_tablep_end); db_flush_lex(); return; default: @@ -267,12 +275,12 @@ db_command(last_cmdp, cmd_table, aux_cmd_tablep) /* XXX usually no more aux's. */ aux_cmd_tablep = 0; if (cmd_table == db_show_cmds) - aux_cmd_tablep = - (struct command **)&db_show_cmd_set.ls_items[0]; + aux_cmd_tablep = SET_BEGIN(db_show_cmd_set); + aux_cmd_tablep_end = SET_LIMIT(db_show_cmd_set); t = db_read_token(); if (t != tIDENT) { - db_cmd_list(cmd_table, aux_cmd_tablep); + db_cmd_list(cmd_table, aux_cmd_tablep, aux_cmd_tablep_end); db_flush_lex(); return; } @@ -453,7 +461,7 @@ db_command_loop() (void) db_read_line(); db_command(&db_last_command, db_command_table, - (struct command **)&db_cmd_set.ls_items[0]); + SET_BEGIN(db_cmd_set), SET_LIMIT(db_cmd_set)); } } |