~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to kernel/kallsyms.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
64
64
        if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
65
65
            arch_is_kernel_text(addr))
66
66
                return 1;
67
 
        return in_gate_area_no_task(addr);
 
67
        return in_gate_area_no_mm(addr);
68
68
}
69
69
 
70
70
static inline int is_kernel(unsigned long addr)
71
71
{
72
72
        if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
73
73
                return 1;
74
 
        return in_gate_area_no_task(addr);
 
74
        return in_gate_area_no_mm(addr);
75
75
}
76
76
 
77
77
static int is_ksym_addr(unsigned long addr)
342
342
}
343
343
 
344
344
/* Look up a kernel symbol and return it in a text buffer. */
345
 
int sprint_symbol(char *buffer, unsigned long address)
 
345
static int __sprint_symbol(char *buffer, unsigned long address,
 
346
                           int symbol_offset)
346
347
{
347
348
        char *modname;
348
349
        const char *name;
349
350
        unsigned long offset, size;
350
351
        int len;
351
352
 
 
353
        address += symbol_offset;
352
354
        name = kallsyms_lookup(address, &size, &offset, &modname, buffer);
353
355
        if (!name)
354
356
                return sprintf(buffer, "0x%lx", address);
357
359
                strcpy(buffer, name);
358
360
        len = strlen(buffer);
359
361
        buffer += len;
 
362
        offset -= symbol_offset;
360
363
 
361
364
        if (modname)
362
 
                len += sprintf(buffer, "+%#lx/%#lx [%s]",
363
 
                                                offset, size, modname);
 
365
                len += sprintf(buffer, "+%#lx/%#lx [%s]", offset, size, modname);
364
366
        else
365
367
                len += sprintf(buffer, "+%#lx/%#lx", offset, size);
366
368
 
367
369
        return len;
368
370
}
 
371
 
 
372
/**
 
373
 * sprint_symbol - Look up a kernel symbol and return it in a text buffer
 
374
 * @buffer: buffer to be stored
 
375
 * @address: address to lookup
 
376
 *
 
377
 * This function looks up a kernel symbol with @address and stores its name,
 
378
 * offset, size and module name to @buffer if possible. If no symbol was found,
 
379
 * just saves its @address as is.
 
380
 *
 
381
 * This function returns the number of bytes stored in @buffer.
 
382
 */
 
383
int sprint_symbol(char *buffer, unsigned long address)
 
384
{
 
385
        return __sprint_symbol(buffer, address, 0);
 
386
}
 
387
 
369
388
EXPORT_SYMBOL_GPL(sprint_symbol);
370
389
 
 
390
/**
 
391
 * sprint_backtrace - Look up a backtrace symbol and return it in a text buffer
 
392
 * @buffer: buffer to be stored
 
393
 * @address: address to lookup
 
394
 *
 
395
 * This function is for stack backtrace and does the same thing as
 
396
 * sprint_symbol() but with modified/decreased @address. If there is a
 
397
 * tail-call to the function marked "noreturn", gcc optimized out code after
 
398
 * the call so that the stack-saved return address could point outside of the
 
399
 * caller. This function ensures that kallsyms will find the original caller
 
400
 * by decreasing @address.
 
401
 *
 
402
 * This function returns the number of bytes stored in @buffer.
 
403
 */
 
404
int sprint_backtrace(char *buffer, unsigned long address)
 
405
{
 
406
        return __sprint_symbol(buffer, address, -1);
 
407
}
 
408
 
371
409
/* Look up a kernel symbol and print it to the kernel messages. */
372
410
void __print_symbol(const char *fmt, unsigned long address)
373
411
{