KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
Server : Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 DAV/2 PHP/5.2.17
System : Linux localhost 2.6.18-419.el5 #1 SMP Fri Feb 24 22:47:42 UTC 2017 x86_64
User : nobody ( 99)
PHP Version : 5.2.17
Disable Function : NONE
Directory :  /proc/21573/root/usr/share/systemtap/tapset/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/21573/root/usr/share/systemtap/tapset/conversions.stp
// conversions tapset
// Copyright (C) 2005-2010 Red Hat Inc.
// Copyright (C) 2007 Intel Corporation.
//
// This file is part of systemtap, and is free software.  You can
// redistribute it and/or modify it under the terms of the GNU General
// Public License (GPL); either version 2, or (at your option) any
// later version.

/**
 * sfunction kernel_string - Retrieves string from kernel memory
 * @addr: The kernel address to retrieve the string from
 *
 * Description: This function returns the null terminated C string
 * from a given kernel memory address. Reports an error on string
 * copy fault.
 */
function kernel_string:string (addr:long) %{ /* pure */
  char *destination = STAP_RETVALUE;
  kderef_string (destination, STAP_ARG_addr, MAXSTRINGLEN);
  if (0) {
deref_fault: /* branched to from deref_string() */
    snprintf (CONTEXT->error_buffer, sizeof(CONTEXT->error_buffer),
        "kernel string copy fault at 0x%p", (void *) (uintptr_t) STAP_ARG_addr);
    CONTEXT->last_error = CONTEXT->error_buffer;
  }
%}

/**
 * sfunction kernel_string2 - Retrieves string from kernel memory with alternative error string
 * @addr: The kernel address to retrieve the string from
 * @err_msg: The error message to return when data isn't available
 *
 * Description: This function returns the null terminated C string
 * from a given kernel memory address. Reports the given error message
 * on string copy fault.
 */
function kernel_string2:string (addr:long, err_msg:string) {
  try { return kernel_string(addr) } catch { return err_msg }
}

/**
 * sfunction kernel_string_n - Retrieves string of given length from kernel memory
 * @addr: The kernel address to retrieve the string from
 * @n: The maximum length of the string (if not null terminated)
 *
 * Description: Returns the C string of a maximum given length from a
 * given kernel memory address. Reports an error on string copy fault.
 */
function kernel_string_n:string (addr:long, n:long) %{ /* pure */
  char *destination = STAP_RETVALUE;
  int64_t len = clamp_t(int64_t, STAP_ARG_n + 1, 1, MAXSTRINGLEN);
  kderef_string (destination, STAP_ARG_addr, len);
  if (0) {
deref_fault: /* branched to from deref_string() */
    snprintf (CONTEXT->error_buffer, sizeof(CONTEXT->error_buffer),
        "kernel string copy fault at 0x%p", (void *) (uintptr_t) STAP_ARG_addr);
    CONTEXT->last_error = CONTEXT->error_buffer;
  }
%}

/**
 * sfunction kernel_long - Retrieves a long value stored in kernel memory
 * @addr: The kernel address to retrieve the long from
 *
 * Description: Returns the long value from a given kernel memory address.
 * Reports an error when reading from the given address fails.
 */
function kernel_long:long (addr:long) %{ /* pure */
  STAP_RETVALUE = kread((long *) (intptr_t) STAP_ARG_addr);
  if (0) {
deref_fault: /* branched to from kread() */
    snprintf (CONTEXT->error_buffer, sizeof(CONTEXT->error_buffer),
        "kernel long copy fault at 0x%p", (void *) (uintptr_t) STAP_ARG_addr);
    CONTEXT->last_error = CONTEXT->error_buffer;
  }
%}

/**
 * sfunction kernel_int - Retrieves an int value stored in kernel memory
 * @addr: The kernel address to retrieve the int from
 *
 * Description: Returns the int value from a given kernel memory address.
 * Reports an error when reading from the given address fails.
 */
function kernel_int:long (addr:long) %{ /* pure */
  STAP_RETVALUE = kread((int *) (intptr_t) STAP_ARG_addr);
  if (0) {
deref_fault: /* branched to from kread() */
    snprintf (CONTEXT->error_buffer, sizeof(CONTEXT->error_buffer),
        "kernel int copy fault at 0x%p", (void *) (uintptr_t) STAP_ARG_addr);
    CONTEXT->last_error = CONTEXT->error_buffer;
  }
%}

/**
 * sfunction kernel_short - Retrieves a short value stored in kernel memory
 * @addr: The kernel address to retrieve the short from
 *
 * Description: Returns the short value from a given kernel memory address.
 * Reports an error when reading from the given address fails.
 */
function kernel_short:long (addr:long) %{ /* pure */
  STAP_RETVALUE = kread((short *) (intptr_t) STAP_ARG_addr);
  if (0) {
deref_fault: /* branched to from kread() */
    snprintf (CONTEXT->error_buffer, sizeof(CONTEXT->error_buffer),
        "kernel short copy fault at 0x%p", (void *) (uintptr_t) STAP_ARG_addr);
    CONTEXT->last_error = CONTEXT->error_buffer;
  }
%}

/**
 * sfunction kernel_char - Retrieves a char value stored in kernel memory
 * @addr: The kernel address to retrieve the char from
 *
 * Description: Returns the char value from a given kernel memory address.
 * Reports an error when reading from the given address fails.
 */
function kernel_char:long (addr:long) %{ /* pure */
  STAP_RETVALUE = kread((char *) (intptr_t) STAP_ARG_addr);
  if (0) {
deref_fault: /* branched to from kread() */
    snprintf (CONTEXT->error_buffer, sizeof(CONTEXT->error_buffer),
        "kernel char copy fault at 0x%p", (void *) (uintptr_t) STAP_ARG_addr);
    CONTEXT->last_error = CONTEXT->error_buffer;
  }
%}

/**
 * sfunction kernel_pointer - Retrieves a pointer value stored in kernel memory
 * @addr: The kernel address to retrieve the pointer from
 *
 * Description: Returns the pointer value from a given kernel memory
 * address. Reports an error when reading from the given address
 * fails.
 */
function kernel_pointer:long (addr:long) %{ /* pure */
  STAP_RETVALUE = (uintptr_t) kread((void **) (uintptr_t) STAP_ARG_addr);
  if (0) {
deref_fault: /* branched to from kread() */
    snprintf (CONTEXT->error_buffer, sizeof(CONTEXT->error_buffer),
        "kernel pointer copy fault at 0x%p", (void *) (uintptr_t) STAP_ARG_addr);
    CONTEXT->last_error = CONTEXT->error_buffer;
  }
%}

Anon7 - 2021