Commit 30942b18b66f35f2ceedab39af10e9eccaa943cc
1 parent
b58d8b48e2
Exists in
master
and in
54 other branches
new command for displaying strings at specified memory locations
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Showing 2 changed files with 50 additions and 0 deletions Side-by-side Diff
common/Makefile
... | ... | @@ -87,6 +87,7 @@ |
87 | 87 | COBJS-y += cmd_sata.o |
88 | 88 | COBJS-$(CONFIG_CMD_SCSI) += cmd_scsi.o |
89 | 89 | COBJS-$(CONFIG_CMD_SPI) += cmd_spi.o |
90 | +COBJS-$(CONFIG_CMD_STRINGS) += cmd_strings.o | |
90 | 91 | COBJS-$(CONFIG_CMD_TERMINAL) += cmd_terminal.o |
91 | 92 | COBJS-$(CONFIG_CMD_UNIVERSE) += cmd_universe.o |
92 | 93 | COBJS-$(CONFIG_CMD_USB) += cmd_usb.o |
common/cmd_strings.c
1 | +/* | |
2 | + * cmd_strings.c - just like `strings` command | |
3 | + * | |
4 | + * Copyright (c) 2008 Analog Devices Inc. | |
5 | + * | |
6 | + * Licensed under the GPL-2 or later. | |
7 | + */ | |
8 | + | |
9 | +#include <config.h> | |
10 | +#include <common.h> | |
11 | +#include <command.h> | |
12 | + | |
13 | +#ifdef CONFIG_CFG_STRINGS | |
14 | + | |
15 | +static char *start_addr, *last_addr; | |
16 | + | |
17 | +int do_strings(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) | |
18 | +{ | |
19 | + if (argc == 1) { | |
20 | + printf("Usage:\n%s\n", cmdtp->usage); | |
21 | + return 1; | |
22 | + } | |
23 | + | |
24 | + if ((flag & CMD_FLAG_REPEAT) == 0) { | |
25 | + start_addr = (char *)simple_strtoul(argv[1], NULL, 16); | |
26 | + if (argc > 2) | |
27 | + last_addr = (char *)simple_strtoul(argv[2], NULL, 16); | |
28 | + else | |
29 | + last_addr = (char *)-1; | |
30 | + } | |
31 | + | |
32 | + char *addr = start_addr; | |
33 | + do { | |
34 | + printf("%s\n", addr); | |
35 | + addr += strlen(addr) + 1; | |
36 | + } while (addr[0] && addr < last_addr); | |
37 | + | |
38 | + last_addr = addr + (last_addr - start_addr); | |
39 | + start_addr = addr; | |
40 | + | |
41 | + return 0; | |
42 | +} | |
43 | + | |
44 | +U_BOOT_CMD(strings, 3, 1, do_strings, | |
45 | + "strings - display strings\n", | |
46 | + "<addr> [byte count]\n" | |
47 | + " - display strings at <addr> for at least [byte count] or first double NUL\n"); | |
48 | + | |
49 | +#endif |