이 콘텐츠는 선택한 언어로 제공되지 않습니다.

9.8. Formatting functions


The following functions help you format output.

9.8.1. ctime

General syntax:
ctime:string(epochsecs:long)
This function accepts an argument of seconds since the epoch as returned by gettimeofday_s(). It returns a date string in UTC of the form:
"Wed Jun 30 21:49:008 2006"
This function does not adjust for timezones. The returned time is always in GMT. Your script must manually adjust epochsecs before passing it to ctime() if you want to print local time.

9.8.2. errno_str

General syntax:
errno_str:string (err:long)
This function returns the symbolic string associated with the given error code, such as ENOENT for the number 2, or E#3333 for an out-of-range value such as 3333.

9.8.3. returnstr

General syntax:
returnstr:string (returnp:long)
This function is used by the syscall tapset, and returns a string. Set returnp equal to 1 for decimal, or 2 for hex.

9.8.4. thread_indent

General syntax:
thread_indent:string (delta:long)
This function returns a string with appropriate indentation for a thread. Call it with a small positive or matching negative delta. If this is the outermost, initial level of indentation, then the function resets the relative timestamp base to zero.
The following example uses thread_indent() to trace the functions called in the drivers/usb/core kernel source. It prints a relative timestamp and the name and ID of the current process, followed by the appropriate indent and the function name. Note that "swapper(0)" indicates the kernel is running in interrupt context and there is no valid current process.
probe kernel.function("*@drivers/usb/core/*") {
printf ("%s -> %s\n", thread_indent(1), probefunc())
}
probe kernel.function("*@drivers/usb/core/*").return {
printf ("%s <- %s\n", thread_indent(-1), probefunc())
}
This prints:
0 swapper(0): -> usb_hcd_irq
8 swapper(0): <- usb_hcd_irq
0 swapper(0): -> usb_hcd_irq
10 swapper(0):  -> usb_hcd_giveback_urb
16 swapper(0):   -> urb_unlink
22 swapper(0):   <- urb_unlink
29 swapper(0):   -> usb_free_urb
35 swapper(0):   <- usb_free_urb
39 swapper(0):  <- usb_hcd_giveback_urb
45 swapper(0): <- usb_hcd_irq
0 usb-storage(1338): -> usb_submit_urb
6 usb-storage(1338):  -> usb_hcd_submit_urb
12 usb-storage(1338):   -> usb_get_urb
18 usb-storage(1338):   <- usb_get_urb
25 usb-storage(1338):  <- usb_hcd_submit_urb
29 usb-storage(1338): <- usb_submit_urb
0 swapper(0): -> usb_hcd_irq
7 swapper(0): <- usb_hcd_irq

9.8.5. thread_timestamp

General syntax:
thread_timestamp:long ()
This function returns an absolute timestamp value for use by the indentation function. The default function uses gettimeofday_us.
Red Hat logoGithubRedditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

© 2024 Red Hat, Inc.