Linux Debug: Systemtap

Source: Internet
Author: User
Tags locale systemtap

Installation and Configuration

In Ubuntu under the direct use of Apt-get install can not be used normally, indicating the lack of debugging information or compile probe code when there is a problem.

1. Using official web-based solutions

2. You can recompile the kernel yourself once and then compile the systemtap manually once. This will allow you to use it normally.

Systemtap's compilation instructions, in addition to not saying too much stuff. Select a version and choose the latest 2.7.

Unzip after download, execute

./configure

Generally, you are prompted for missing components. Systemtap should be the first to be developed by Redhat, so the package name Ubuntu cannot be used directly apt-get

List several dependencies that you have encountered:

Configure:error:missing gnu/usr/bin/msgfmt

Apt-get Install GetText

Configure:error:missing elfutils Development headers/libraries (install elfutils-devel, Libebl-dev, Libdw-dev and/or Libebl-devel)

Can be solved by Apt-get install Libdw-dev

 in '/root/systemtap-2.7':"/lib/cpp" fails sanity Check

Installing Apt-get Install g++

Basic use

See Systemtap official tutorial. Take a note here.

Hello World

The Systemtap script transformation is compiled into a kernel module and then a predefined action is performed, and the defined action is triggered by a series of events. The user can specify which events are triggered on which of the specified actions. The following is a Systemtap HelloWorld, which is executed once before the script is run in the module mount

[Email protected]:~# stap hello-world.stp Hello world[email protected]:cat hello-WORLD.STP probe begin{    Print ("Hello world\n")    exit ()}

If you turn on the-v option, you can see the detailed steps for execution:

[Email protected]:~# stap-v hello-WORLD.STP Pass1: Parsed user script and106Library script (s) using 66544virt/37432res/4324shr/33908data KB,inch120usr/10sys/127real Ms. Pass2: Analyzed script:1Probe (s),1 function(s),0Embed (s),0Global (s) using 67204virt/38136res/4512shr/34568data KB,inch0usr/0sys/4real Ms. Pass3: Translated to C into"/TMP/STAPYZXHXI/STAP_847497C1DE7927412685A2282F37C57D_881_SRC.C"Using 67204virt/39028res/5232shr/34568data KB,inch0usr/0sys/0real Ms. Pass4: Compiled C into"Stap_847497c1de7927412685a2282f37c57d_881.ko" inch1000usr/590sys/1582real Ms. Pass5: Starting Run.helloworldpass5: Run completedinch10usr/20sys/472real Ms.

It is much quicker to run the same script multiple times because SYSTEMTAP directly uses the compiled cache module file.

You can also run a certain time on a regular basis:

[Email protected]:~# Stap strace-OPEN.STPCat(24307) Open ("/etc/ld.so.cache", o_rdonly|o_cloexec)Cat(24307) Open ("/lib/x86_64-linux-gnu/libc.so.6", o_rdonly|o_cloexec)Cat(24307) Open ("/usr/lib/locale/locale-archive", o_rdonly|o_cloexec)Cat(24307) Open ("iw.c", O_rdonly) [Email protected]:~#Catstrace-OPEN.STP probe Syscall.open {printf ("%s (%d) open (%s) \ n", Execname (), PID (), argstr);} Probe timer.ms (4000) # After4seconds{exit ()}

The results of a cat command were executed during the Systemtap run, and the script recorded the process information that executed the system call to open.

Linux Debug: Systemtap

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.