Subversion Repositories HelenOS

Rev

Rev 4089 | Rev 4137 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4089 Rev 4132
Line 48... Line 48...
48
#include <arch.h>
48
#include <arch.h>
49
#include <macros.h>
49
#include <macros.h>
50
#include <debug.h>
50
#include <debug.h>
51
#include <func.h>
51
#include <func.h>
52
#include <string.h>
52
#include <string.h>
53
#include <symtab.h>
-
 
54
#include <macros.h>
53
#include <macros.h>
55
#include <sysinfo/sysinfo.h>
54
#include <sysinfo/sysinfo.h>
56
#include <ddi/device.h>
55
#include <ddi/device.h>
57
 
56
 
-
 
57
#ifdef CONFIG_SYMTAB
-
 
58
#include <symtab.h>
-
 
59
#endif
-
 
60
 
58
/** Simple kernel console.
61
/** Simple kernel console.
59
 *
62
 *
60
 * The console is realized by kernel thread kconsole.
63
 * The console is realized by kernel thread kconsole.
61
 * It doesn't understand any useful command on its own,
64
 * It doesn't understand any useful command on its own,
62
 * but makes it possible for other kernel subsystems to
65
 * but makes it possible for other kernel subsystems to
Line 256... Line 259...
256
 * @param name - string to match, changed to hint on exit
259
 * @param name - string to match, changed to hint on exit
257
 * @return number of found matches
260
 * @return number of found matches
258
 */
261
 */
259
static int cmdtab_compl(char *name)
262
static int cmdtab_compl(char *name)
260
{
263
{
261
    static char output[MAX_SYMBOL_NAME + 1];
264
    static char output[/*MAX_SYMBOL_NAME*/128 + 1];
262
    link_t *startpos = NULL;
265
    link_t *startpos = NULL;
263
    const char *foundtxt;
266
    const char *foundtxt;
264
    int found = 0;
267
    int found = 0;
265
    int i;
268
    int i;
266
 
269
 
Line 288... Line 291...
288
            hlp = list_get_instance(startpos, cmd_info_t, link);
291
            hlp = list_get_instance(startpos, cmd_info_t, link);
289
            printf("%s - %s\n", hlp->name, hlp->description);
292
            printf("%s - %s\n", hlp->name, hlp->description);
290
            startpos = startpos->next;
293
            startpos = startpos->next;
291
        }
294
        }
292
    }
295
    }
293
    strncpy(name, output, MAX_SYMBOL_NAME);
296
    strncpy(name, output, 128/*MAX_SYMBOL_NAME*/);
294
    return found;
297
    return found;
295
   
-
 
296
}
298
}
297
 
299
 
298
static char *clever_readline(const char *prompt, indev_t *input)
300
static char *clever_readline(const char *prompt, indev_t *input)
299
{
301
{
300
    static int histposition = 0;
302
    static int histposition = 0;
Line 345... Line 347...
345
            strncpy(tmp, current + i, position - i + 1);
347
            strncpy(tmp, current + i, position - i + 1);
346
 
348
 
347
            if (i == 0) { /* Command completion */
349
            if (i == 0) { /* Command completion */
348
                found = cmdtab_compl(tmp);
350
                found = cmdtab_compl(tmp);
349
            } else { /* Symtab completion */
351
            } else { /* Symtab completion */
-
 
352
#ifdef CONFIG_SYMTAB
350
                found = symtab_compl(tmp);
353
                found = symtab_compl(tmp);
-
 
354
#else
-
 
355
                found = 0;
-
 
356
#endif
351
            }
357
            }
352
 
358
 
353
            if (found == 0)
359
            if (found == 0)
354
                continue;
360
                continue;
355
            for (i = 0; tmp[i] && curlen < MAX_CMDLINE;
361
            for (i = 0; tmp[i] && curlen < MAX_CMDLINE;
Line 513... Line 519...
513
    kconsole("kconsole", "Kernel console ready (press any key to activate)\n", true);
519
    kconsole("kconsole", "Kernel console ready (press any key to activate)\n", true);
514
}
520
}
515
 
521
 
516
static int parse_int_arg(char *text, size_t len, unative_t *result)
522
static int parse_int_arg(char *text, size_t len, unative_t *result)
517
{
523
{
518
    static char symname[MAX_SYMBOL_NAME];
-
 
519
    uintptr_t symaddr;
524
    uintptr_t symaddr;
520
    bool isaddr = false;
525
    bool isaddr = false;
521
    bool isptr = false;
526
    bool isptr = false;
-
 
527
 
-
 
528
#ifdef CONFIG_SYMTAB
-
 
529
    static char symname[MAX_SYMBOL_NAME];
-
 
530
#endif
522
   
531
   
523
    /* If we get a name, try to find it in symbol table */
532
    /* If we get a name, try to find it in symbol table */
524
    if (text[0] == '&') {
533
    if (text[0] == '&') {
525
        isaddr = true;
534
        isaddr = true;
526
        text++;
535
        text++;
Line 529... Line 538...
529
        isptr = true;
538
        isptr = true;
530
        text++;
539
        text++;
531
        len--;
540
        len--;
532
    }
541
    }
533
    if (text[0] < '0' || text[0] > '9') {
542
    if (text[0] < '0' || text[0] > '9') {
-
 
543
#ifdef CONFIG_SYMTAB
534
        strncpy(symname, text, min(len + 1, MAX_SYMBOL_NAME));
544
        strncpy(symname, text, min(len + 1, MAX_SYMBOL_NAME));
535
        symaddr = get_symbol_addr(symname);
545
        symaddr = get_symbol_addr(symname);
536
        if (!symaddr) {
546
        if (!symaddr) {
537
            printf("Symbol %s not found.\n", symname);
547
            printf("Symbol %s not found.\n", symname);
538
            return -1;
548
            return -1;
Line 540... Line 550...
540
        if (symaddr == (uintptr_t) -1) {
550
        if (symaddr == (uintptr_t) -1) {
541
            printf("Duplicate symbol %s.\n", symname);
551
            printf("Duplicate symbol %s.\n", symname);
542
            symtab_print_search(symname);
552
            symtab_print_search(symname);
543
            return -1;
553
            return -1;
544
        }
554
        }
-
 
555
#else
-
 
556
        symaddr = 0;
-
 
557
#endif
545
        if (isaddr)
558
        if (isaddr)
546
            *result = (unative_t)symaddr;
559
            *result = (unative_t)symaddr;
547
        else if (isptr)
560
        else if (isptr)
548
            *result = **((unative_t **)symaddr);
561
            *result = **((unative_t **)symaddr);
549
        else
562
        else