什么是 strace
strace是Linux环境下的一款程序调试工具,用来监察一个应用程序所使用的系统调用。
Strace是一个简单的跟踪系统调用执行的工具。在其最简单的形式中,它可以从开始到结束跟踪二进制的执行,并在进程的生命周期中输出一行具有系统调用名称,每个系统调用的参数和返回值的文本行。
strace有两种运行模式
一:通过它启动要跟踪的进程,在原本的命令前加上strace即可:strace ls -lh /var/log/cron
二:跟踪已经在运行的进程,在不中断进程执行的情况下,查看它在干嘛。 给strace传递个-p pid 选项即可:strace -p 28397
starce 常用的选项
-c 统计每一系统调用的所执行的时间,次数和出错的次数等.
-d 输出strace关于标准错误的调试信息.
-f 跟踪由fork调用所产生的子进程.
-ff 如果提供-o filename,则所有进程的跟踪结果输出到相应的filename.pid中,pid是各进程的进程号.
-F 尝试跟踪vfork调用.在-f时,vfork不被跟踪.
-h 输出简要的帮助信息.
-i 输出系统调用的入口指针.
-q 禁止输出关于脱离的消息.
-r 打印出相对时间关于,,每一个系统调用.
-t 在输出中的每一行前加上时间信息.
-tt 在输出中的每一行前加上时间信息,微秒级.
-ttt 微秒级输出,以秒了表示时间.
-T 显示每一调用所耗的时间.
-v 输出所有的系统调用.一些调用关于环境变量,状态,输入输出等调用由于使用频繁,默认不输出.
-V 输出strace的版本信息.
-x 以十六进制形式输出非标准字符串
-xx 所有字符串以十六进制形式输出.
-a column 设置返回值的输出位置.默认 为40.
-e expr 指定一个表达式,用来控制如何跟踪.格式如下:
[qualifier=]
[!]value1[,value2]…
qualifier只能是 trace,abbrev,verbose,raw,signal,read,write其中之一.value是用来限定的符号或数字.默认的 qualifier是 trace.感叹号是否定符号.例如:
-eopen等价于 -e trace=open,表示只跟踪open调用.而-etrace!=open表示跟踪除了open以外的其他调用.有两个特殊的符号 all 和 none.
注意有些shell使用!来执行历史记录里的命令,所以要使用\.
-e trace=set
只跟踪指定的系统 调用.例如:-e trace=open,close,rean,write表示只跟踪这四个系统调用.默认的为set=all.
-e trace=file
只跟踪有关文件操作的系统调用.
-e trace=process
只跟踪有关进程控制的系统调用.
-e trace=network
跟踪与网络有关的所有系统调用.
-e strace=signal
跟踪所有与系统信号有关的 系统调用
-e trace=ipc
跟踪所有与进程通讯有关的系统调用
-e abbrev=set
设定 strace输出的系统调用的结果集.-v 等与 abbrev=none.默认为abbrev=all.
-e raw=set
将指 定的系统调用的参数以十六进制显示.
-e signal=set
指定跟踪的系统信号.默认为all.如 signal=!SIGIO(或者signal=!io),表示不跟踪SIGIO信号.
-e read=set
输出从指定文件中读出 的数据.例如:
-e read=3,5
-e write=set
输出写入到指定文件中的数据.
-o filename
将strace的输出写入文件filename
-p pid
跟踪指定的进程pid.
-s strsize
指定输出的字符串的最大长度.默认为32.文件名一直全部输出.
-u username
以username 的UID和GID执行被跟踪的命令
strace 输出一部分简单的解释
execve(“./main”, [“./main”], [/* 43 vars */]) = 0
对于命令行下执行的程序,execve(或exec系列调用中的某一个)均为strace输出系统调用中的第一个。
strace首先调用fork或clone函数新建一个子进程,然后在子进程中调用exec载入需要执行的程序(这里为./main)
brk(0) = 0x9ac4000
以0作为参数调用brk,返回值为内存管理的起始地址(若在子进程中调用malloc,则从0x9ac4000地址开始分配空间)
access(“/etc/ld.so.nohwcap”, F_OK) = -1 ENOENT (No such file or directory)
调用access函数检验/etc/ld.so.nohwcap是否存在
mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7739000
使用mmap2函数进行匿名内存映射,以此来获取8192bytes内存空间,该空间起始地址为0xb7739000
open(“/etc/ld.so.cache”, O_RDONLY) = 3
调用open函数尝试打开/etc/ld.so.cache文件,返回文件描述符为3
fstat64(3, {st_mode=S_IFREG|0644, st_size=80682, …}) = 0
fstat64函数获取/etc/ld.so.cache文件信息
mmap2(NULL, 80682, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7725000
调用mmap2函数将/etc/ld.so.cache文件映射至内存
close(3) = 0
close关闭文件描述符为3指向的/etc/ld.so.cache文件
open(“/lib/i386-linux-gnu/libc.so.6”, O_RDONLY) = 3
read(3, “\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\220o\1\0004\0\0\0″…, 512) = 512
调用read,从/lib/i386-linux-gnu/libc.so.6该libc库文件中读取512bytes,即读取ELF头信息
mprotect(0x6c7000, 4096, PROT_NONE) = 0
使用mprotect函数对0x6c7000起始的4096bytes空间进行保护(PROT_NONE表示不能访问,PROT_READ表示可以读取)
文章来源:www.rakbuluo.com/p78
can i buy viagra over the counter <a href="http://viagratx.com/ ">viagra ebay</a> off brand viagra
viagra dosage women <a href="https://viagriyvik.com/ ">http://viagriyvik.com/ </a> viagra brand
best viagra tablets in india online <a href="https://vigedon.com/ ">200 mg viagra india </a> viagra over the counter price
payday loan monthly installments <a href="http://ascashapply.com/ ">compare payday loan lenders no credit check</a> 44 cash loans
payday loan edmonton <a href="http://samcash21.com/ ">cash generator loans wythenshawe</a> payday loan companies in birmingham
cialis pharmacy rx one <a href="http://edpharmacystore.com/">via</a> canadianpharmacymeds.com
<a href=http://edpharmacystore.com/>browse around here</a>
cialis generic reviews <a href="http://llecialisjaw.com/ ">http://llecialisjaw.com/ </a> cheap tablet cialis
legitimate online pharmacies india <a href="http://edpharmacystore.com/">at bing</a> northwestpharmacy.com canada
<a href=http://edpharmacystore.com/>Visit Website</a>
cialis from usa pharmacy <a href="http://edpharmacystore.com/">Additional Info</a> canada pharmacies online viagra
<a href=http://edpharmacystore.com/>full report</a>
achat levitra cialis <a href="https://jecialisbn.com/ ">how cialis daily works</a> cialis every 3 days
think money loan apr <a href="http://daymoneygo.com/ ">payday loans riverside mo</a> cash loan with montel williams
payday loans on jobseekers allowance <a href="http://rirocash.com/ ">buying a car with cash vs loan</a> is tuition a cash advance
onde comprar generico do cialis <a href="http://ljcialishe.com/ ">daily cialis 20mg</a> cialis kopfschmerzen aspirin
viagra without prescirption <a href="http://lightvigra.com/ ">generic viagra australia</a> viagra with out presctiption
viagra cialis samples <a href="http://cialisvja.com/ ">36 hour cialis</a> generic cialis buy
Viagra Oral Jelly <a href="http://online21rxon.com/ ">online pharmacies canada</a> navarro pharmacy miami
prescription cost <a href="http://happyrxpharmacy21.com/ ">cheap drugs online</a> canadian pharmacy online canada
viagra professional online pharmacy <a href="http://hopeviagrin.com/ ">las vegas buy viagra</a> viagra cheap au
canadian online pharmacy <a href="https://ssviagriia.com/ ">online viagra australia</a> northwest pharmacy canada
canadian pharmacy uk delivery <a href="http://storerxpharmcanada.com/ ">canadian online pharmacies</a> non prescription online pharmacy reviews
walgreens online pharmacy <a href="http://xuypharmacyonline.com/">canada viagra</a> canadian pharmacy online
best canadian online pharmacy <a href="http://canadianpharmnorx.com/ ">brand viagra</a> legitimate online pharmacies
female viagra pills <a href="https://api.gridpointweather.com/community/member.php?action=profile&uid=110993">generic drugs</a> sildenafil viagra <a href=https://funsilo.date/wiki/Overview_On_How_To_Overcome_Diabetes_Easily>cialis canadian pharmacies</a> cheapest viagra in uk
viagra for men <a href="http://zoe-beauty.be/user/HorowitzKolding5/">cost of cialis</a> buy cheap viagra <a href=http://www.sdmnapoli.it/index.php?option=com_k2&view=itemlist&task=user&id=547858>online medications</a> canadian pharmacy - cialis
ed meds <a href="https://www.indiegogo.com/individuals/25822517">www.canadian pharmacy</a> ordering medications from canada <a href=http://camp-ete-2018.matutinal.fr/questions/index.php?qa=user&qa_1=horowitzstuart5>onlinepharmaciescanada.com</a> generic viagra 100mg
pharmacy rx one
meds canada <a href=http://www.canada1drugstore.com/tadalafil/>canadian pharmacy and viagra</a> canada drug prices
<a href="http://www.canada1drugstore.com/tadalafil/">ordering viagra</a> supermarket near me
Provera <a href="https://canadianpharmacy-yy.com/">drugs for sale</a> canada drugs direct https://canadianpharmacy-yy.com/ - pharmacy online store ’
cialis from canadian pharmacy <a href="https://www.eater.com/users/mcintyrevang">canadian cialis online pharmacy</a> viagra online canada <a href=https://mozillabd.science/wiki/Guide_On_How_To_Overcome_Diabetes_Easily>canadian meds</a> what is viagra used for
generic viagra canada <a href="https://vimeo.com/abdimartinsen6">online generic viagra</a> the canada pharmacy <a href=http://www.alcestersingers.co.uk/forum/member.php?action=profile&uid=25146>canada rx pharmacy</a> canada cialis
canada drug prices <a href="https://championsleage.review/wiki/Take_Control_Of_Your_Health_With_These_Great_Acid_Reflux_Tips">canada online pharmacy viagra</a> viagra brand for sale <a href=http://megazvezda.info/user/HorowitzHorowitz4/>buy discount viagra</a> canadian drugstore
viagra expiration date
best price on cialis <a href="https://impotencecdny.com/info/history.php">cialis buy onilne</a> cialis online delivery overnight https://impotencecdny.com/info/history.php - cialis sale ’
overnight delivery cialis <a href="https://impotencecdny.com/">Erythromycin</a> cialis only https://impotencecdny.com/ - canadian pharma companies ’
generic viagra mexico pharmacy <a href="http://canadianpharmacy-yy.com/Fitness/how-to-get-a-six-pack.html">viagra without presc</a> order viagra us http://canadianpharmacy-yy.com/Fitness/how-to-get-a-six-pack.html - how much is generic viagra in canada ’
viagra <a href="http://erectilejyzd.com/#">Cleocin</a> cheap viagra uk http://erectilejyzd.com/ - legit online pharmacy ’
buy viagra <a href="http://erectilejyzd.com/index.php?called=terms">viagra with dapoxetine overnight delivery australia</a> 36 hour viagra no prescription http://erectilejyzd.com/index.php?called=terms - generic viagra (tadalafil) 20mg 30 ’
prescription cialis <a href=http://www.canada1drugstore.com/tadalafil/>viagra pills</a> viagra prescription online
<a href="http://www.canada1drugstore.com/tadalafil/">online pharmacy cialis</a> cost viagra
viagra for sal <a href="https://canadianpharmacy-usx.com/organic.htm">viagra online in usa</a> generic viagra india online https://canadianpharmacy-usx.com/organic.htm - canadian pharmacy viagra cialis ’
buying cialis in canada <a href=http://www.canada1drugstore.com/tadalafil/>cialis pills for sale</a> overnight viagra
<a href="http://www.canada1drugstore.com/tadalafil/">canada rx pharmacy</a> viagra buy online
female cialis <a href="http://sjcialis.com/#">which is better viagra cialis or levitra</a> generic cialis http://sjcialis.com/ - cialisВ® ’
cialis priligy online australia <a href="http://cialmenshoprx.com/#">cialis generic overnite</a> cialissite:au http://cialmenshoprx.com/ - generic cialis ’
viagra with dapoxetine 365 pills <a href="http://xz-pharmacyonline.com/en/career-opportunities.html">viagra online australia paypal</a> viagra en sydney http://xz-pharmacyonline.com/en/career-opportunities.html - looking for secure website to purchase cheap viagra in the united states ’
cialis with dapoxetine overnight delivery australia <a href="https://xz-pharmacyonline.com/#">compare rx prices</a> order cialis 20 online https://xz-pharmacyonline.com - canadianpharmacy ’
where can i buy cialis 20mg <a href="http://loncialis.com/#">google south africa cialis</a> buy cialis and receive in 48 hrs http://loncialis.com/ - cialis 60 mg ’
generic cialis <a href="http://21cialismen.com/#">how does cialis work</a> generic cialis cipla http://21cialismen.com/ - cialis and douextine ’
viagra cost <a href="http://genericrxxx.com/#">buying real viagra online</a> buy viagra onlinne http://genericrxxx.com/ - viagra sale cheap ’
viagra kaufen per nach nahme <a href="http://acialaarx.com/#">purchase generic viagra</a> buy viagra 100 mg http://acialaarx.com/ - cvs viagra ’
cialis kaufen mit paypal zahlen <a href="http://cialijomen.com/#">cialis in canada fast shipping</a> generica cialis http://cialijomen.com/ - cialis 20mg overnight ’
i need cialis <a href="http://mycialedst.com/#">best price on cialis</a> cialis order http://mycialedst.com/ - generic cialis forums ’
buy cialis in australia online <a href="http://21cialismen.com/#">cialis&dapoxetine</a> cialis 20mg П„О№ОјО· http://21cialismen.com/ - cialis reliable sites ’
buy viagra sydney <a href="http://genqpviag.com/#">viagra, canada</a> viagra with dapoxetine overnight delivery http://genqpviag.com/ - viagra rapid tabs ’
viagra without prescription needed <a href="http://llviabest.com/#">viagra on line pay pall australia</a> order viagra overnight shipping http://llviabest.com/ - what\'s the least expensive place to buy viagra ’
buy cialis online <a href="http://phrcialiled.com/#">wallmart cialis</a> viagra or cialis reviews http://phrcialiled.com/ - cialis dapoxetine online canada ’
where to buy viagra sydney <a href="http://ltdviagragogo.com/#">liquid viagra shot</a> viagra super active plus viagra in kanada <a href="http://hdgenericviagraxk.com/#">womens viagra</a> supreme suppliers viagra windsor viagra <a href="http://buygenericviarga.com/#">generic viagra india online</a> cheap viagra in chicago viagra no pascription <a href="http://buyhdpillvia.com/#">buy cheap viagra in canada</a> viagra 800mg generic viagra 50mg <a href="http://genericviagrix.com/#">brand viagra</a> where can i buy viagra in canada
viagra quiz <a href="http://viashoprx.com/#">best prices in america for viagra</a> viagra super force side effects canadian viagra suppliers <a href="http://xviagarrx.com/#">100mg viagra on line</a> how much viagra is safe to take viagra with <a href="http://viagraviagria.com/#">viagra cost</a> wallgreens viagra military viagra <a href="http://asgenviagria.com/#">viagrasites</a> generic viagra professional cheap viagra and cialis in australia <a href="http://viagengen.com/#">doctor burlington vt viagra free trial</a> buy viagra from germany
when will viagra patent run out? <a href="http://bestviagrx.com/#">where to get viagra samples</a> cost of viagra at walmart canadian pharmacies selling viagra <a href="http://viarxhd.com/#">pills like viagra</a> viagra and dapoxetine with try viagra for free <a href="http://viagetpill.com/#">viagra jelly america</a> buy viagra from germany where to buy viagra on line <a href="http://pillexrx.com/#">online viagra in united states</a> by viagra online buy viagra online generic <a href="http://usggrxmed.com/#">viagra for sale with a prescription in las vegas nv</a> buy viagra online without a prescription with overnight delivery
top college application essays <a href="https://thesisbyd.com/#">guidelines to writing a research paper</a> essay writing toronto
do my homework for money <a href="https://customessaywriterbyz.com/#">presentation speech</a> essay writing online
writing a research paper powerpoint <a href="https://dissertationhelpvfh.com/#">essays practice</a> essay writing 7th grade biomes
writing essay <a href="https://researchpaperssfk.com/#">term paper writers</a> good writing essay
writing a narrative essay <a href="https://essaywritingservicesjy.com/#">best website to buy essays</a> college essay entrance
custom essay writing services reviews <a href="https://thesiswritinghelpsjj.com/#">writing a good narrative essay</a> college essay prepscholar
top essay writing promo code <a href="https://essayhelpbgs.com/#">essay writing argumentative</a> aa seat assignment
chemistry homework help online <a href="https://writemypaperbuyhrd.com/#">english essay</a> interesting persuasive essays
where can i buy viagra online uk <a href="https://mygoviagar.com/#">cost of sildenafil online</a> viagra 100mg price in india
viagra contro ansia da prestazione <a href="https://genericrxxx.com/#">generic viagra for men and women</a> wordpress viagra search results
viagra super active plus <a href="https://genqpviag.com/#">viagra for sale</a> viagra overnight delivery in us
sildenafil 1 pill <a href="https://lightvigra.com/#">viagra pills price in usa</a> generic viagra professional 100mg
is viagra legal in uk <a href="https://siviagmen.com/#">generico viagra melhor</a> viagra kamagra
paiement cod viagra <a href="https://llviabest.com/#">where do i buy viagra in sydney</a> generic viagra\'
cheap generic viagra online <a href="https://miraclevigra.com/#">pfizer online viagra</a> where to get female viagra
viagra brand name online <a href="https://hopeviagrin.com/#">viagra buy usa</a> viagra 10
cost of viagra from pharmacy <a href="https://purevigra.com/#">can i take viagra after dinner</a> will a doctor prescribe viagra for performance anxiety
micardis e viagra <a href="https://buybuyviamen.com/#">https://buybuyviamen.com/</a> lowest dose of viagra
viagra from china <a href="https://paradiseviagira.com/#">cialis vs viagra</a> canadian viagra suppliers
what is a safe website to buy viagra <a href="https://buybuyviamen.com/#">designer viagra</a> generic viagra in thailand
viagra/ mastercard accepted <a href="https://wowviaprice.com/#">where to order pink viagra</a> buy viagra usa
quando non si deve prendere il viagra <a href="https://purevigra.com/#">purevigra.com</a> viagra ca marche
viagra 50mg price <a href="https://wowviaprice.com/#">https://wowviaprice.com</a> professional viagra
canada pharmacy viagra <a href="https://paradiseviagira.com/#">https://paradiseviagira.com/</a> generic viagra
is viagra generic yet http://fmedrx.com/ <a href="http://fmedrx.com/#">viagra and cialis online</a> viagra goes generic
where to buy viagra online safely http://usggrxmed.com/ <a href="http://usggrxmed.com/#">generic viagra for sale</a> buying viagra online legal
IF YOU HAVE ANY QUESTIONS OR CONCERNS YOU CAN CONTACT THE COLLEGE AT: 200-1765 WEST 8TH AVE
VANCOUVER, BC V6J 5C6 CANADA. <a href="http://llviabest.com/">viagra cheap online</a> buy generic viagra online paypal
Publishers <a href="http://siviagmen.com/">http://siviagmen.com</a> viagra online canadian pharmacy
viagra walmart <a href=" http://sild100fast.com/# ">buying viagra online</a> online doctor prescription for viagra