mirror of
https://github.com/apache/nuttx.git
synced 2026-05-28 20:08:15 +08:00
board/coredump: add option to use base64 stream
Signed-off-by: Xu Xingliang <xuxingliang@xiaomi.com>
This commit is contained in:
+7
-1
@@ -4666,6 +4666,13 @@ config BOARD_COREDUMP_COMPRESSION
|
|||||||
---help---
|
---help---
|
||||||
Enable LZF compression algorithm for core dump content
|
Enable LZF compression algorithm for core dump content
|
||||||
|
|
||||||
|
config BOARD_COREDUMP_BASE64STREAM
|
||||||
|
bool "Enable base64 encoding for output stream"
|
||||||
|
default n
|
||||||
|
depends on BOARD_COREDUMP_SYSLOG
|
||||||
|
---help---
|
||||||
|
Enable based64 encoded stream instead of default hexstream.
|
||||||
|
|
||||||
config BOARD_ENTROPY_POOL
|
config BOARD_ENTROPY_POOL
|
||||||
bool "Enable Board level storing of entropy pool structure"
|
bool "Enable Board level storing of entropy pool structure"
|
||||||
default n
|
default n
|
||||||
@@ -4890,4 +4897,3 @@ config BOARD_MEMORY_RANGE
|
|||||||
end: end address of memory range
|
end: end address of memory range
|
||||||
flags: Readable 0x1, writable 0x2, executable 0x4
|
flags: Readable 0x1, writable 0x2, executable 0x4
|
||||||
example:0x1000,0x2000,0x1,0x2000,0x3000,0x3,0x3000,0x4000,0x7
|
example:0x1000,0x2000,0x1,0x2000,0x3000,0x3,0x3000,0x4000,0x7
|
||||||
|
|
||||||
|
|||||||
+16
-2
@@ -39,7 +39,11 @@ static struct lib_lzfoutstream_s g_lzfstream;
|
|||||||
|
|
||||||
#ifdef CONFIG_BOARD_COREDUMP_SYSLOG
|
#ifdef CONFIG_BOARD_COREDUMP_SYSLOG
|
||||||
static struct lib_syslogstream_s g_syslogstream;
|
static struct lib_syslogstream_s g_syslogstream;
|
||||||
|
# ifdef CONFIG_BOARD_COREDUMP_BASE64STREAM
|
||||||
|
static struct lib_base64outstream_s g_base64stream;
|
||||||
|
# else
|
||||||
static struct lib_hexdumpstream_s g_hexstream;
|
static struct lib_hexdumpstream_s g_hexstream;
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_BOARD_COREDUMP_BLKDEV
|
#ifdef CONFIG_BOARD_COREDUMP_BLKDEV
|
||||||
@@ -65,6 +69,7 @@ static const struct memory_region_s *g_regions;
|
|||||||
static void coredump_dump_syslog(pid_t pid)
|
static void coredump_dump_syslog(pid_t pid)
|
||||||
{
|
{
|
||||||
FAR void *stream;
|
FAR void *stream;
|
||||||
|
FAR const char *streamname;
|
||||||
int logmask;
|
int logmask;
|
||||||
|
|
||||||
logmask = setlogmask(LOG_ALERT);
|
logmask = setlogmask(LOG_ALERT);
|
||||||
@@ -75,8 +80,16 @@ static void coredump_dump_syslog(pid_t pid)
|
|||||||
|
|
||||||
lib_syslogstream(&g_syslogstream, LOG_EMERG);
|
lib_syslogstream(&g_syslogstream, LOG_EMERG);
|
||||||
stream = &g_syslogstream;
|
stream = &g_syslogstream;
|
||||||
|
#ifdef CONFIG_BOARD_COREDUMP_BASE64STREAM
|
||||||
|
lib_base64outstream(&g_base64stream, stream);
|
||||||
|
stream = &g_base64stream;
|
||||||
|
streamname = "base64";
|
||||||
|
#else
|
||||||
lib_hexdumpstream(&g_hexstream, stream);
|
lib_hexdumpstream(&g_hexstream, stream);
|
||||||
stream = &g_hexstream;
|
stream = &g_hexstream;
|
||||||
|
streamname = "hex";
|
||||||
|
#endif
|
||||||
|
|
||||||
# ifdef CONFIG_BOARD_COREDUMP_COMPRESSION
|
# ifdef CONFIG_BOARD_COREDUMP_COMPRESSION
|
||||||
|
|
||||||
/* Initialize LZF compression stream */
|
/* Initialize LZF compression stream */
|
||||||
@@ -90,9 +103,10 @@ static void coredump_dump_syslog(pid_t pid)
|
|||||||
core_dump(g_regions, stream, pid);
|
core_dump(g_regions, stream, pid);
|
||||||
|
|
||||||
# ifdef CONFIG_BOARD_COREDUMP_COMPRESSION
|
# ifdef CONFIG_BOARD_COREDUMP_COMPRESSION
|
||||||
_alert("Finish coredump (Compression Enabled).\n");
|
_alert("Finish coredump (Compression Enabled). %s formatted\n",
|
||||||
|
streamname);
|
||||||
# else
|
# else
|
||||||
_alert("Finish coredump.\n");
|
_alert("Finish coredump. %s formatted\n", streamname);
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
setlogmask(logmask);
|
setlogmask(logmask);
|
||||||
|
|||||||
+25
-1
@@ -22,6 +22,7 @@
|
|||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
import base64
|
||||||
import binascii
|
import binascii
|
||||||
import os
|
import os
|
||||||
import struct
|
import struct
|
||||||
@@ -69,6 +70,20 @@ def unhexlify(infile, outfile):
|
|||||||
outfile.write(binascii.unhexlify(line))
|
outfile.write(binascii.unhexlify(line))
|
||||||
|
|
||||||
|
|
||||||
|
def unbase64file(infile, outfile):
|
||||||
|
input = ""
|
||||||
|
for line in infile.readlines():
|
||||||
|
line = line.strip()
|
||||||
|
if line == "":
|
||||||
|
break
|
||||||
|
index = line.rfind(" ")
|
||||||
|
if index > 0:
|
||||||
|
line = line[index + 1 :]
|
||||||
|
|
||||||
|
input += line
|
||||||
|
outfile.write(base64.b64decode(input))
|
||||||
|
|
||||||
|
|
||||||
def parse_args():
|
def parse_args():
|
||||||
global args
|
global args
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
@@ -78,6 +93,12 @@ def parse_args():
|
|||||||
)
|
)
|
||||||
parser.add_argument("input")
|
parser.add_argument("input")
|
||||||
parser.add_argument("-o", "--output", help="Output file in hex.")
|
parser.add_argument("-o", "--output", help="Output file in hex.")
|
||||||
|
parser.add_argument(
|
||||||
|
"--base64",
|
||||||
|
action="store_true",
|
||||||
|
default=False,
|
||||||
|
help="Set when input file is base64 encoded.",
|
||||||
|
)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
@@ -94,7 +115,10 @@ def main():
|
|||||||
infile = open(args.input, "r")
|
infile = open(args.input, "r")
|
||||||
tmpfile = open(tmp, "wb+")
|
tmpfile = open(tmp, "wb+")
|
||||||
|
|
||||||
unhexlify(infile, tmpfile)
|
if args.base64:
|
||||||
|
unbase64file(infile, tmpfile)
|
||||||
|
else:
|
||||||
|
unhexlify(infile, tmpfile)
|
||||||
|
|
||||||
infile.close()
|
infile.close()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user