commands "a", "bb", "ccc", "dddd" and "eeeee" have been entered (followed by <crlf>, obviously):
Code: Select all
Breakpoint 2, shellThread (p=0x200015c4 <shellConfig>) at ../../chibios-svn/os/various/shell/shell.c:368
368 chprintf(chp, SHELL_PROMPT_STR);
(gdb) x/32c shellHistoryBuffer
0x20007fb0 <shellHistoryBuffer>: 1 '\001' 97 'a' 2 '\002' 98 'b' 98 'b' 3 '\003' 99 'c' 99 'c'
0x20007fb8 <shellHistoryBuffer+8>: 99 'c' 4 '\004' 100 'd' 100 'd' 100 'd' 100 'd' 5 '\005' 101 'e'
0x20007fc0 <shellHistoryBuffer+16>: 101 'e' 101 'e' 101 'e' 101 'e' 0 '\000' 0 '\000' 0 '\000' 0 '\000'
0x20007fc8 <shellHistoryBuffer+24>: 0 '\000' 0 '\000' 0 '\000' 0 '\000' 0 '\000' 0 '\000' 0 '\000' 0 '\000'
(gdb) p shp->sh_beg
$5 = 0
(gdb) p shp->sh_cur
$6 = 0
(gdb) p shp->sh_end
$7 = 20
now i type "e" and hit <tab> ("echo " appears) and <crlf>. history buffer is damaged:
Code: Select all
Breakpoint 2, shellThread (p=0x200015c4 <shellConfig>) at ../../chibios-svn/os/various/shell/shell.c:368
368 chprintf(chp, SHELL_PROMPT_STR);
(gdb) x/32c shellHistoryBuffer
0x20007fb0 <shellHistoryBuffer>: 0 '\000' 0 '\000' 0 '\000' 0 '\000' 98 'b' 3 '\003' 99 'c' 99 'c'
0x20007fb8 <shellHistoryBuffer+8>: 99 'c' 4 '\004' 100 'd' 100 'd' 100 'd' 100 'd' 5 '\005' 101 'e'
0x20007fc0 <shellHistoryBuffer+16>: 101 'e' 101 'e' 101 'e' 101 'e' 4 '\004' 101 'e' 99 'c' 104 'h'
0x20007fc8 <shellHistoryBuffer+24>: 111 'o' 0 '\000' 0 '\000' 0 '\000' 0 '\000' 0 '\000' 0 '\000' 0 '\000'
(gdb) p shp->sh_beg
$8 = 0
(gdb) p shp->sh_cur
$9 = 0
(gdb) p shp->sh_end
$10 = 25
next time you hit <up>, you end up in a loop at:
Code: Select all
^C
Program received signal SIGINT, Interrupt.
0x0800370a in get_history (shp=shp@entry=0x200078b4 <mShellThreadWorkingArea+4324>, line=line@entry=0x200078e4 <mShellThreadWorkingArea+4372> "echo", dir=dir@entry=0) at ../../chibios-svn/os/various/shell/shell.c:187
187 if (idx >= shp->sh_size)
(gdb) bt
#0 0x0800370a in get_history (shp=shp@entry=0x200078b4 <mShellThreadWorkingArea+4324>,
line=line@entry=0x200078e4 <mShellThreadWorkingArea+4372> "echo", dir=dir@entry=0)
at ../../chibios-svn/os/various/shell/shell.c:187
#1 0x08006584 in shellGetLine (scfg=scfg@entry=0x200015c4 <shellConfig>,
line=line@entry=0x200078e4 <mShellThreadWorkingArea+4372> "echo", size=size@entry=64,
shp=shp@entry=0x200078b4 <mShellThreadWorkingArea+4324>) at ../../chibios-svn/os/various/shell/shell.c:501
#2 0x08007bfa in shellThread (p=0x200015c4 <shellConfig>) at ../../chibios-svn/os/various/shell/shell.c:369
#3 0x08000346 in __port_thread_start () at ../../chibios-svn/os/common/ports/ARMv7-M/compilers/GCC/chcoreasm.S:203
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb) list
182
183 /* Count the number of lines saved in the buffer */
184 int idx = shp->sh_beg;
185 while (idx != shp->sh_end) {
186 idx += *(shp->sh_buffer + idx) + 1;
187 if (idx >= shp->sh_size)
188 idx -= shp->sh_size;
189 count++;
190 }
191
(gdb) p count
$11 = 82121462