Wed Jul 29 23:29:42 2020 UTC ()
db_get_line - raw access to the DDB command line.

Provide a way for DDB commands to access the remainder of the command
line as-is.


(uwe)
diff -r1.25 -r1.26 src/sys/ddb/db_lex.c
diff -r1.15 -r1.16 src/sys/ddb/db_lex.h

cvs diff -r1.25 -r1.26 src/sys/ddb/db_lex.c (expand / switch to unified diff)

--- src/sys/ddb/db_lex.c 2019/11/22 23:01:49 1.25
+++ src/sys/ddb/db_lex.c 2020/07/29 23:29:42 1.26
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: db_lex.c,v 1.25 2019/11/22 23:01:49 ad Exp $ */ 1/* $NetBSD: db_lex.c,v 1.26 2020/07/29 23:29:42 uwe Exp $ */
2 2
3/* 3/*
4 * Mach Operating System 4 * Mach Operating System
5 * Copyright (c) 1991,1990 Carnegie Mellon University 5 * Copyright (c) 1991,1990 Carnegie Mellon University
6 * All Rights Reserved. 6 * All Rights Reserved.
7 * 7 *
8 * Permission to use, copy, modify and distribute this software and its 8 * Permission to use, copy, modify and distribute this software and its
9 * documentation is hereby granted, provided that both the copyright 9 * documentation is hereby granted, provided that both the copyright
10 * notice and this permission notice appear in all copies of the 10 * notice and this permission notice appear in all copies of the
11 * software, derivative works or modified versions, and any portions 11 * software, derivative works or modified versions, and any portions
12 * thereof, and that both notices appear in supporting documentation. 12 * thereof, and that both notices appear in supporting documentation.
13 * 13 *
14 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 14 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
@@ -24,27 +24,27 @@ @@ -24,27 +24,27 @@
24 * 24 *
25 * any improvements or extensions that they make and grant Carnegie the 25 * any improvements or extensions that they make and grant Carnegie the
26 * rights to redistribute these changes. 26 * rights to redistribute these changes.
27 * 27 *
28 * Author: David B. Golub, Carnegie Mellon University 28 * Author: David B. Golub, Carnegie Mellon University
29 * Date: 7/90 29 * Date: 7/90
30 */ 30 */
31 31
32/* 32/*
33 * Lexical analyzer. 33 * Lexical analyzer.
34 */ 34 */
35 35
36#include <sys/cdefs.h> 36#include <sys/cdefs.h>
37__KERNEL_RCSID(0, "$NetBSD: db_lex.c,v 1.25 2019/11/22 23:01:49 ad Exp $"); 37__KERNEL_RCSID(0, "$NetBSD: db_lex.c,v 1.26 2020/07/29 23:29:42 uwe Exp $");
38 38
39#include <sys/param.h> 39#include <sys/param.h>
40#include <sys/systm.h> 40#include <sys/systm.h>
41#include <sys/cpu.h> 41#include <sys/cpu.h>
42 42
43#include <ddb/ddb.h> 43#include <ddb/ddb.h>
44 44
45db_expr_t db_tok_number; 45db_expr_t db_tok_number;
46char db_tok_string[TOK_STRING_SIZE]; 46char db_tok_string[TOK_STRING_SIZE];
47 47
48static char db_line[DB_LINE_MAXLEN]; 48static char db_line[DB_LINE_MAXLEN];
49static const char *db_lp; 49static const char *db_lp;
50static const char *db_endlp; 50static const char *db_endlp;
@@ -79,26 +79,36 @@ db_read_line(void) @@ -79,26 +79,36 @@ db_read_line(void)
79 return (0); /* EOI */ 79 return (0); /* EOI */
80 db_set_line(db_line, db_line + i); 80 db_set_line(db_line, db_line + i);
81 return (i); 81 return (i);
82} 82}
83 83
84void 84void
85db_set_line(const char *sp, const char *ep) 85db_set_line(const char *sp, const char *ep)
86{ 86{
87 87
88 db_lp = sp; 88 db_lp = sp;
89 db_endlp = ep; 89 db_endlp = ep;
90} 90}
91 91
 92void
 93db_get_line(const char **psp, const char **pep)
 94{
 95
 96 if (psp != NULL)
 97 *psp = db_lp;
 98 if (pep != NULL)
 99 *pep = db_endlp;
 100}
 101
92static void 102static void
93db_flush_line(void) 103db_flush_line(void)
94{ 104{
95 105
96 db_lp = db_line; 106 db_lp = db_line;
97 db_endlp = db_line; 107 db_endlp = db_line;
98} 108}
99 109
100static int 110static int
101db_read_char(void) 111db_read_char(void)
102{ 112{
103 int c; 113 int c;
104 114

cvs diff -r1.15 -r1.16 src/sys/ddb/db_lex.h (expand / switch to unified diff)

--- src/sys/ddb/db_lex.h 2005/11/27 13:05:28 1.15
+++ src/sys/ddb/db_lex.h 2020/07/29 23:29:42 1.16
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: db_lex.h,v 1.15 2005/11/27 13:05:28 yamt Exp $ */ 1/* $NetBSD: db_lex.h,v 1.16 2020/07/29 23:29:42 uwe Exp $ */
2 2
3/* 3/*
4 * Mach Operating System 4 * Mach Operating System
5 * Copyright (c) 1991,1990 Carnegie Mellon University 5 * Copyright (c) 1991,1990 Carnegie Mellon University
6 * All Rights Reserved. 6 * All Rights Reserved.
7 * 7 *
8 * Permission to use, copy, modify and distribute this software and its 8 * Permission to use, copy, modify and distribute this software and its
9 * documentation is hereby granted, provided that both the copyright 9 * documentation is hereby granted, provided that both the copyright
10 * notice and this permission notice appear in all copies of the 10 * notice and this permission notice appear in all copies of the
11 * software, derivative works or modified versions, and any portions 11 * software, derivative works or modified versions, and any portions
12 * thereof, and that both notices appear in supporting documentation. 12 * thereof, and that both notices appear in supporting documentation.
13 * 13 *
14 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 14 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
@@ -26,26 +26,27 @@ @@ -26,26 +26,27 @@
26 * rights to redistribute these changes. 26 * rights to redistribute these changes.
27 * 27 *
28 * Author: David B. Golub, Carnegie Mellon University 28 * Author: David B. Golub, Carnegie Mellon University
29 * Date: 7/90 29 * Date: 7/90
30 */ 30 */
31 31
32/* 32/*
33 * Lexical analyzer. 33 * Lexical analyzer.
34 */ 34 */
35void db_flush_lex(void); 35void db_flush_lex(void);
36char *db_num_to_str(db_expr_t); 36char *db_num_to_str(db_expr_t);
37int db_read_line(void); 37int db_read_line(void);
38void db_set_line(const char *, const char *); 38void db_set_line(const char *, const char *);
 39void db_get_line(const char **, const char **);
39int db_read_token(void); 40int db_read_token(void);
40void db_unread_token(int); 41void db_unread_token(int);
41 42
42#define DB_LINE_MAXLEN 120 43#define DB_LINE_MAXLEN 120
43 44
44extern db_expr_t db_tok_number; 45extern db_expr_t db_tok_number;
45#define TOK_STRING_SIZE DB_LINE_MAXLEN 46#define TOK_STRING_SIZE DB_LINE_MAXLEN
46extern char db_tok_string[]; 47extern char db_tok_string[];
47 48
48#define tEOF (-1) 49#define tEOF (-1)
49#define tEOL 1 50#define tEOL 1
50#define tNUMBER 2 51#define tNUMBER 2
51#define tIDENT 3 52#define tIDENT 3