On Monday 09 April 2007 11:04, Levend Sayar wrote:
> Hi, all
> My current problem with busybox is getting a really interactive shell. Since
> my shell does not respond to any command.
> I posted my log coming from my embedded board console. Below you will see
> lines starting with "LS:". They are belong to printk's inserted into kernel
> code by me. And also I added a driver KLOG into the kernel (Not module). It
> simply printk whatever written to it from user-space. It is a gateway from
> user-space to kernel ring buffer. So I changed ash.c to use my device, not
> trace into "./trace" file. My motive was to see what's going on when ash
> shell started to run,since it has built-in trace code when you define DEBUG
> as 2.
Nice.
> 10MB LOWMEM available.
> Memory: 4824k/10240k available (511k kernel code, 5028k reserved, 101k data,
> 40k
> init, 0k highmem)
This is irrelevant to the problem, but... why so much of memory
is reserved by kernel?
> KLOG: Tracing started.
>
>
> BusyBox v1.4.2 (2007-04-09 10:09:53 EEST) Built-in shell (ash)
> Enter 'help' for a list of built-in commands.
>
> KLOG: LS:interactive(1)
> LS:sys_open(/etc/profile)
> LS:sys_open(/etc/profile)->4
> LS:sys_close(4)
> KLOG: cmdloop(0) called
> KLOG: token newline
...
> KLOG: evalcommand arg: export
> KLOG: evalcommand arg: PATH
> KLOG: token newline
> KLOG: evaltree(NULL) called
> KLOG: token end of file
> LS:sys_close(10)
So, you have /etc/profile and it was executed.
> LS:sys_open(.profile)
> LS:sys_open(.profile)->-2
You dont have .profile.
> KLOG: cmdloop(1) called
> #
Now it tries to read command from stdin.
Let's see... in ash.c:
cmdloop(int top)
{
TRACE(("cmdloop(%d) called\n", top));
for (;;) {
int skip;
setstackmark(&smark);
#if JOBS
if (jobctl)
showjobs(stderr, SHOW_CHANGED);
#endif
inter = 0;
if (iflag && top) {
inter++;
#if ENABLE_ASH_MAIL
chkmail();
#endif
}
n = parsecmd(inter);
Thus we call parsecmd(1):
parsecmd(int interact)
{
tokpushback = 0;
doprompt = interact;
if (doprompt)
setprompt(doprompt);
needprompt = 0;
t = readtoken();
...
readtoken(void)
{
#if DEBUG
int alreadyseen = tokpushback;
#endif
#if ENABLE_ASH_ALIAS
top:
#endif
t = xxreadtoken();
...
xxreadtoken(void)
{
if (tokpushback) {
tokpushback = 0;
return lasttoken;
}
if (needprompt) {
setprompt(2);
}
startlinno = plinno;
for (;;) { /* until token or start of word found */
c = pgetc_macro();
...
pgetc_macro calls preadbuffer() thru this maze:
#define pgetc_as_macro() (--parsenleft >= 0? signed_char2int(*parsenextc++) :
preadbuffer())
static int
pgetc(void)
{
return pgetc_as_macro();
}
#if ENABLE_ASH_OPTIMIZE_FOR_SIZE
#define pgetc_macro() pgetc()
#else
#define pgetc_macro() pgetc_as_macro()
#endif
preadbuffer(void)
{
while (parsefile->strpush) {
...
}
if (parsenleft == EOF_NLEFT || parsefile->buf == NULL)
return PEOF;
flush_stdout_stderr();
more = parselleft;
if (more <= 0) {
again:
more = preadfd();
...
preadfd(void)
{
int nr;
char *buf = parsefile->buf;
parsenextc = buf;
retry:
#if ENABLE_FEATURE_EDITING
if (!iflag || parsefile->fd)
nr = safe_read(parsefile->fd, buf, BUFSIZ - 1);
else {
#if ENABLE_FEATURE_TAB_COMPLETION
line_input_state->path_lookup = pathval();
#endif
nr = read_line_input(cmdedit_prompt, buf, BUFSIZ,
line_input_state);
It has to reach safe_read() or read_line_input(), but does it?
You can add debug prints along this callchain and track
what's going on.
simple write(2, "I am here\n", 10) style debugging will work.
--
vda
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox