18video性欧美19sex,欧美高清videosddfsexhd,性少妇videosexfreexxx片中国,激情五月激情综合五月看花,亚洲人成网77777色在线播放

0
  • 聊天消息
  • 系統(tǒng)消息
  • 評(píng)論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫(xiě)文章/發(fā)帖/加入社區(qū)
會(huì)員中心
創(chuàng)作中心

完善資料讓更多小伙伴認(rèn)識(shí)你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

【鴻蒙】OpenHarmony使用strace

王程 ? 來(lái)源: jf_75796907 ? 作者: jf_75796907 ? 2024-03-01 09:41 ? 次閱讀
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

簡(jiǎn)介

Strace 是一個(gè)強(qiáng)大的進(jìn)程行為跟蹤工具,當(dāng)懷疑某個(gè)進(jìn)程運(yùn)行異常的時(shí)候,比如死鎖,CPU 高或者莫名卡頓等,可以使用 strace 查看該進(jìn)程發(fā)起的系統(tǒng)調(diào)用和接收到的信號(hào),從而確定問(wèn)題所在。當(dāng)然也可以利用 strace 去學(xué)習(xí)了解進(jìn)程的運(yùn)行流程,調(diào)用庫(kù)以及參數(shù)和統(tǒng)計(jì)。那么如何在 OpenHarmony 里編譯使用此工具就是我們這篇文章要分享的話題。

編譯構(gòu)建

下載:從https://github.com/strace 下載最新源碼

//下載地址
wget https://github.com/strace/strace/releases/download/v6.6/strace-6.6.tar.xz

安裝編譯環(huán)境

//編譯工具鏈(32位)
sudo apt-get install gcc-arm-linux-gnueabi
//ohos的源碼下載后,其實(shí)也有對(duì)應(yīng)的工具鏈,位置如下
prebuilts/gcc/linux-x86/arm(32位)/gcc-linaro-7.5.0-arm-linux-gnueabi/bin

編譯

//設(shè)置環(huán)境變量
export CC=arm-linux-gnueabi-gcc
export CFLAGS=-static
export CPPFLAGS=-static
export LDFLAGS='-static -pthread'
//配置
 ./configure CC=arm-linux-gnueabi-gcc CXX=arm-linux-gnueabi-cpp  LD=arm-linux-gnueabi-ld RANLIB=arm-linux-gnueabi-ranlib --host=arm-linux --target=arm-linux --enable-mpers=no 
//編譯
make
//strip
arm-linux-gnueabi-strip strace

?

運(yùn)行測(cè)試

//傳到板子上
hdc_std.exe shell mount -o rw,remount /
hdc_std.exe file send strace /system/bin
hdc_std.exe shell chmod +x /system/bin/strace

//運(yùn)行測(cè)試
hdc_std.exe shell
# strace --help
Usage: strace [-ACdffhiqqrtttTvVwxxyyzZ] [-I N] [-b execve] [-e EXPR]...
              [-a COLUMN] [-o FILE] [-s STRSIZE] [-X FORMAT] [-P PATH]...
              [-p PID]... [--seccomp-bpf]
              { -p PID | [-DDD] [-E VAR=VAL]... [-u USERNAME] PROG [ARGS] }
   or: strace -c[dfwzZ] [-I N] [-b execve] [-e EXPR]... [-O OVERHEAD]
              [-S SORTBY] [-P PATH]... [-p PID]... [--seccomp-bpf]
              { -p PID | [-DDD] [-E VAR=VAL]... [-u USERNAME] PROG [ARGS] }

General:
  -e EXPR        a qualifying expression: OPTION=[!]all or OPTION=[!]VAL1[,VAL2]...
     options:    trace, abbrev, verbose, raw, signal, read, write, fault,
                 inject, status, kvm

Startup:
  -E VAR=VAL, --env=VAR=VAL
                 put VAR=VAL in the environment for command
  -E VAR, --env=VAR
                 remove VAR from the environment for command
  -p PID, --attach=PID
                 trace process with process id PID, may be repeated
  -u USERNAME, --user=USERNAME
                 run command as USERNAME handling setuid and/or setgid

Tracing:
  -b execve, --detach-on=execve
                 detach on execve syscall
  -D             run tracer process as a grandchild, not as a parent
  -DD            run tracer process in a separate process group
  -DDD           run tracer process in a separate session
  -f             follow forks
  -ff            follow forks with output into separate files
  -I INTERRUPTIBLE
     1:          no signals are blocked
     2:          fatal signals are blocked while decoding syscall (default)
     3:          fatal signals are always blocked (default if '-o FILE PROG')
     4:          fatal signals and SIGTSTP (^Z) are always blocked
                 (useful to make 'strace -o FILE PROG' not stop on ^Z)

Filtering:
  -e trace=[!]{[?]SYSCALL[@64|@32|@x32]|[?]/REGEX|GROUP|all|none},
  --trace=[!]{[?]SYSCALL[@64|@32|@x32]|[?]/REGEX|GROUP|all|none}
                 trace only specified syscalls.
     groups:     %creds, %desc, %file, %fstat, %fstatfs %ipc, %lstat,
                 %memory, %net, %process, %pure, %signal, %stat, %%stat,
                 %statfs, %%statfs
  -e signal=SET, --signal=SET
                 trace only the specified set of signals
                 print only the signals from SET
  -e status=SET, --status=SET
                 print only system calls with the return statuses in SET
     statuses:   successful, failed, unfinished, unavailable, detached
  -P PATH, --trace-path=PATH
                 trace accesses to PATH
  -z             print only syscalls that returned without an error code
  -Z             print only syscalls that returned with an error code

Output format:
  -a COLUMN, --columns=COLUMN
                 alignment COLUMN for printing syscall results (default 40)
  -e abbrev=SET, --abbrev=SET
                 abbreviate output for the syscalls in SET
  -e verbose=SET, --verbose=SET
                 dereference structures for the syscall in SET
  -e raw=SET, --raw=SET
                 print undecoded arguments for the syscalls in SET
  -e read=SET, --read=SET
                 dump the data read from the file descriptors in SET
  -e write=SET, --write=SET
                 dump the data written to the file descriptors in SET
  -e kvm=vcpu, --kvm=vcpu
                 print exit reason of kvm vcpu
  -i, --instruction-pointer
                 print instruction pointer at time of syscall
  -o FILE, --output=FILE
                 send trace output to FILE instead of stderr
  -A, --output-append-mode
                 open the file provided in the -o option in append mode
  -q             suppress messages about attaching, detaching, etc.
  -qq            suppress messages about process exit status as well.
  -r             print relative timestamp
  -s STRSIZE, --string-limit=STRSIZE
                 limit length of print strings to STRSIZE chars (default 32)
  -t             print absolute timestamp
  -tt            print absolute timestamp with usecs
  -ttt           print absolute UNIX time with usecs
  -T             print time spent in each syscall
  -v, --no-abbrev
                 verbose mode: print entities unabbreviated
  -x             print non-ascii strings in hex
  -xx            print all strings in hex
  -X FORMAT      set the FORMAT for printing of named constants and flags
     formats:    raw, abbrev, verbose
  -y             print paths associated with file descriptor arguments
  -yy            print protocol specific information associated with socket
                 file descriptors

Statistics:
  -c, --summary-only
                 count time, calls, and errors for each syscall and report
                 summary
  -C, --summary  like -c, but also print the regular output
  -O OVERHEAD    set overhead for tracing syscalls to OVERHEAD usecs
  -S SORTBY, --summary-sort-by=SORTBY
                 sort syscall counts by: time, calls, errors, name, nothing
                 (default time)
  -w             summarise syscall latency (default is system time)

Tampering:
  -e inject=SET[:error=ERRNO|:retval=VALUE][:signal=SIG][:syscall=SYSCALL]
            [:delay_enter=DELAY][:delay_exit=DELAY][:when=WHEN],
  --inject=SET[:error=ERRNO|:retval=VALUE][:signal=SIG][:syscall=SYSCALL]
           [:delay_enter=DELAY][:delay_exit=DELAY][:when=WHEN]
                 perform syscall tampering for the syscalls in SET
     delay:      milliseconds or NUMBER{s|ms|us|ns}
     when:       FIRST, FIRST+, or FIRST+STEP
  -e fault=SET[:error=ERRNO][:when=WHEN], --fault=SET[:error=ERRNO][:when=WHEN]
                 synonym for -e inject with default ERRNO set to ENOSYS.
Miscellaneous:
  -d, --debug    enable debug output to stderr
  -h, --help     print help message
  --seccomp-bpf  enable seccomp-bpf filtering
  -V, --version  print version
?

小結(jié)

簡(jiǎn)單說(shuō)說(shuō) strace 的典型場(chǎng)景:

進(jìn)程統(tǒng)計(jì):針對(duì)某個(gè)運(yùn)行高 cpu 消耗的進(jìn)程,進(jìn)行監(jiān)控統(tǒng)計(jì),什么操作耗時(shí)多?后臺(tái)在做什么事?統(tǒng)計(jì)出來(lái)高消耗的系統(tǒng)操作

# top
Tasks: 243 total,   2 running, 237 sleeping,   0 stopped,   4 zombie
  Mem:  1992724K total,  1501188K used,   491536K free,   1830912 buffers
 Swap:  1048572K total,         0 used,  1048572K free,   683260K cached
400%cpu 125%user   1%nice  70%sys 202%idle   0%iow   0%irq   2%sirq   0%host
  PID USER         PR  NI VIRT  RES  SHR S[%CPU] %MEM     TIME+ ARGS
  555 graphics     -2  -8 150M  62M  45M S 72.4   3.1 895:19.80 render_service
  539 composer_ho+ -2  -8  17M 4.9M 3.8M S 23.2   0.2 282:37.59 composer_host           9 composer_host -8 1
  247 logd         20   0  16M 4.9M 2.3M S 12.2   0.2 167:45.62 hilogd
14516 root          0 -20    0    0    0 I  3.3   0.0   0:07.05 [kworker/u9:1-kbase_pm_poweroff_wait]
14587 root         25   5  14M 3.0M 2.6M R  2.9   0.1   0:00.12 top
  178 root         RT   0    0    0    0 S  2.3   0.0  36:26.03 [sugov:0]


# strace -cp 555
strace: Process 555 attached
strace: Process 555 detached
% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 22.34    0.456649          22     20705           clock_gettime64
 20.30    0.415126          66      6201           ioctl
 16.03    0.327786          45      7236           writev
 10.87    0.222298          31      7006           close
  7.24    0.148065          18      7855           gettid
  5.90    0.120715          58      2058       168 futex
  3.65    0.074596          22      3296           dup
  2.76    0.056384          68       825           munmap
  2.27    0.046345          55       828           write
  1.93    0.039523          27      1442           poll
  1.64    0.033546          40       824           mmap2
  1.49    0.030400          36       828           fcntl64
  1.40    0.028689          34       824           prctl
  0.80    0.016341          36       447       206 read
  0.50    0.010236          24       412           _llseek
  0.46    0.009408          45       207           madvise
  0.36    0.007341          35       206           epoll_pwait
  0.05    0.001017        1017         1           restart_syscall
------ ----------- ----------- --------- --------- ----------------
100.00    2.044465                 61201       374 total

?

跟進(jìn)分析:通過(guò)「T」選項(xiàng)可以獲取操作實(shí)際消耗的時(shí)間,通過(guò)「e」選項(xiàng)可以跟蹤某個(gè)操作

strace -T -e clock_gettime64 -p 555

strace: Process 555 attached
clock_gettime64(CLOCK_MONOTONIC, {tv_sec=89616, tv_nsec=627412894}) = 0 
clock_gettime64(CLOCK_MONOTONIC, {tv_sec=89616, tv_nsec=627777769}) = 0 
clock_gettime64(CLOCK_REALTIME, {tv_sec=1702433139, tv_nsec=94341493}) = 0 
clock_gettime64(CLOCK_MONOTONIC, {tv_sec=89616, tv_nsec=628287311}) = 0 
clock_gettime64(CLOCK_MONOTONIC, {tv_sec=89616, tv_nsec=628442478}) = 0 
clock_gettime64(CLOCK_MONOTONIC, {tv_sec=89616, tv_nsec=628586853}) = 0 
clock_gettime64(CLOCK_MONOTONIC, {tv_sec=89616, tv_nsec=628774978}) = 0 
clock_gettime64(CLOCK_MONOTONIC, {tv_sec=89616, tv_nsec=629033978}) = 0 
clock_gettime64(CLOCK_MONOTONIC, {tv_sec=89616, tv_nsec=629318936}) = 0 
clock_gettime64(CLOCK_MONOTONIC, {tv_sec=89616, tv_nsec=629491020}) = 0 

?
這就是一個(gè)最簡(jiǎn)單的查看性能問(wèn)題的流程,先統(tǒng)計(jì),再看具體操作,然后查看代碼,鎖定問(wèn)題。剩下的就是祝好運(yùn)咯。當(dāng)然如果發(fā)現(xiàn)輸出比較少,還有個(gè)工具是 ltrace

為了能讓大家更好的學(xué)習(xí)鴻蒙 (OpenHarmony) 開(kāi)發(fā)技術(shù),這邊特意整理了《鴻蒙 (OpenHarmony)開(kāi)發(fā)學(xué)習(xí)手冊(cè)》,希望對(duì)大家有所幫助:

《鴻蒙(Harmony OS)開(kāi)發(fā)學(xué)習(xí)手冊(cè)》

入門(mén)必看:https://docs.qq.com/doc/DUk51cHZJaUpmSlhH
1.應(yīng)用開(kāi)發(fā)導(dǎo)讀(ArKTS)
2.……

wKgaomXW6N2AJp9uAAQXRxEAprs547.png

HarmonyOS概念:https://docs.qq.com/doc/DUk51cHZJaUpmSlhH
1.系統(tǒng)定義
2.技術(shù)框架
3.技術(shù)特性
4.系統(tǒng)安全

wKgaomXW6OSAFcCRAAV2zd2X_1s891.png

快速入門(mén):https://docs.qq.com/doc/DUk51cHZJaUpmSlhH
1.基本概念
2.構(gòu)建第一個(gè)ArkTS應(yīng)用
3.……

wKgZomXW6PuAA7wEAAKx6By_2Z8377.png

開(kāi)發(fā)基礎(chǔ)知識(shí):https://docs.qq.com/doc/DUk51cHZJaUpmSlhH
1.應(yīng)用基礎(chǔ)知識(shí)
2.配置文件
3.應(yīng)用數(shù)據(jù)管理
4.應(yīng)用安全管理
5.應(yīng)用隱私保護(hù)
6.三方應(yīng)用調(diào)用管控機(jī)制
7.資源分類與訪問(wèn)
8.學(xué)習(xí)ArkTS
9…

wKgZomXW6QaAM4niAAQzrXUUPik914.png

基于ArkTS 開(kāi)發(fā):https://docs.qq.com/doc/DUk51cHZJaUpmSlhH
1.Ability開(kāi)發(fā)
2.UI開(kāi)發(fā)
3.公共事件與通知
4.窗口管理
5.媒體
6.安全
7.網(wǎng)絡(luò)與鏈接
8.電話服務(wù)
9.數(shù)據(jù)管理
10.后臺(tái)任務(wù)(Background Task)管理
11.設(shè)備管理
12.設(shè)備使用信息統(tǒng)計(jì)
13.DFX
14.國(guó)際化開(kāi)發(fā)
15.折疊屏系列
16………

wKgZomXW6RKATahiAAKz-zSMnR4040.png

審核編輯 黃宇

聲明:本文內(nèi)容及配圖由入駐作者撰寫(xiě)或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點(diǎn)僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場(chǎng)。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問(wèn)題,請(qǐng)聯(lián)系本站處理。 舉報(bào)投訴
  • 鴻蒙
    +關(guān)注

    關(guān)注

    60

    文章

    2744

    瀏覽量

    45103
  • HarmonyOS
    +關(guān)注

    關(guān)注

    80

    文章

    2143

    瀏覽量

    35142
收藏 人收藏
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

    評(píng)論

    相關(guān)推薦
    熱點(diǎn)推薦

    基于OPenHarmony的智慧牧場(chǎng)#鴻蒙

    鴻蒙HarmonyOSOpenHarmony
    發(fā)布于 :2022年09月23日 16:21:11

    基于 OpenHarmony,國(guó)內(nèi)首個(gè)輕鴻蒙手表 OS 發(fā)行版出爐

    基于OpenHarmony,國(guó)內(nèi)首個(gè)輕鴻蒙手表OS發(fā)行版出爐好叭科技近日發(fā)布了基于 OpenHarmony 的輕鴻蒙手表 OS 發(fā)行版。本次發(fā)行版主要有三個(gè)特性:UI 交互、數(shù)據(jù)與語(yǔ)音
    發(fā)表于 11-16 14:14

    Linux strace命令的用法

    簡(jiǎn)介strace常用來(lái)跟蹤進(jìn)程執(zhí)行時(shí)的系統(tǒng)調(diào)用和所接收的信號(hào)。 在Linux世界,進(jìn)程不能直接訪問(wèn)硬件設(shè)備,當(dāng)進(jìn)程需要訪問(wèn)硬件設(shè)備(比如讀取磁盤(pán)文件,接收網(wǎng)絡(luò)數(shù)據(jù)等等)時(shí),必須由用戶
    發(fā)表于 04-02 14:48 ?658次閱讀

    openharmony鴻蒙區(qū)別

    OpenHarmony是HarmonyOS的開(kāi)源版。 華為的鴻蒙操作系統(tǒng)是純自己研發(fā)的,但是openharmony卻不是華為的,openharmony是由開(kāi)放原子開(kāi)源基金會(huì)(OpenA
    的頭像 發(fā)表于 06-24 16:21 ?4757次閱讀

    openharmony鴻蒙有什么關(guān)系

    平板、手機(jī)、智能家居都可以通過(guò)建房子搭積木的方式來(lái)使用鴻蒙系統(tǒng)。 openharmony鴻蒙之間屬于相輔相成的,可以說(shuō)openharmony就是建設(shè)
    的頭像 發(fā)表于 06-22 16:02 ?1.3w次閱讀

    openharmony 鴻蒙

    openharmony 鴻蒙 openharmony 鴻蒙,HarmonyOS是一款“面向未來(lái)”、面向全場(chǎng)景(移動(dòng)辦公、運(yùn)動(dòng)健康、社交通信、媒體娛樂(lè)等)的分布式操作系統(tǒng)。在傳統(tǒng)的單設(shè)備
    的頭像 發(fā)表于 06-21 19:37 ?2242次閱讀

    openharmony官網(wǎng)和鴻蒙

    openharmony官網(wǎng)和鴻蒙 OpenHarmony(開(kāi)源鴻蒙系統(tǒng))是HarmonyOS的開(kāi)源版,由華為捐贈(zèng)給開(kāi)放原子開(kāi)源基金會(huì)(OpenAtom Foundation)開(kāi)源,第一
    的頭像 發(fā)表于 06-21 19:50 ?3522次閱讀

    openharmony鴻蒙的關(guān)系

    openharmony鴻蒙的關(guān)系 openharmony鴻蒙的關(guān)系,6月15日,華為發(fā)布了一份名為“2021 年 HarmonyOS 2 全國(guó)統(tǒng)一考試”的考卷,題型有聽(tīng)力題、單選題
    的頭像 發(fā)表于 06-21 19:56 ?3039次閱讀
    <b class='flag-5'>openharmony</b>和<b class='flag-5'>鴻蒙</b>的關(guān)系

    華為openharmony鴻蒙 2.0

    華為openharmony鴻蒙 2.0 IT之家 5 月 17 日消息 微博博主 @釗哥科普 此前爆料,華為鴻蒙 OpenHarmony 2.0 從 5 月 16 日開(kāi)始開(kāi)源,關(guān)鍵代碼
    的頭像 發(fā)表于 06-21 20:13 ?2455次閱讀

    openharmony2.0大會(huì) openharmony鴻蒙的關(guān)系

    近日,開(kāi)放原子開(kāi)源基金會(huì)(以下簡(jiǎn)稱“基金會(huì)”)在深圳·國(guó)際開(kāi)源谷舉辦了OpenHarmony 2.0共建邀請(qǐng)會(huì)。那么,OpenHarmony等于熱詞HarmonyOS嗎?openharmony
    的頭像 發(fā)表于 06-22 09:58 ?2654次閱讀

    openharmony鴻蒙區(qū)別

    我們知道華為是開(kāi)源了鴻蒙系統(tǒng)的,開(kāi)源的項(xiàng)目叫做OpenHarmony 2.0。華為捐贈(zèng)給了“開(kāi)放原子開(kāi)源基金會(huì)”,這樣可以根據(jù)不同的訴求來(lái)做不同的產(chǎn)品。那么這個(gè)開(kāi)源的OpenHarmony和華為
    的頭像 發(fā)表于 06-22 15:14 ?6628次閱讀

    openharmony鴻蒙2.0的關(guān)系

    openharmony鴻蒙2.0的關(guān)系到底是什么?下面就由小編帶領(lǐng)大家簡(jiǎn)單介紹一下!
    的頭像 發(fā)表于 06-23 11:10 ?2484次閱讀

    openharmony鴻蒙的區(qū)別是什么

    我們都知道,華為鴻蒙系統(tǒng)華為是開(kāi)源了的,開(kāi)源項(xiàng)目叫做OpenHarmony 2.0,那么這個(gè)開(kāi)源的OpenHarmony 2.0與華為自家使用的鴻蒙HarmonyOS 2,又有什么區(qū)別
    的頭像 發(fā)表于 06-23 11:53 ?1.1w次閱讀

    如何在開(kāi)源鴻蒙OpenHarmony開(kāi)啟SELinux模式?RK3566鴻蒙開(kāi)發(fā)板演示

    本文介紹開(kāi)源鴻蒙OpenHarmony系統(tǒng)下,開(kāi)啟/關(guān)閉SELinux權(quán)限的方法,觸覺(jué)智能Purple Pi OH鴻蒙開(kāi)發(fā)板演示,已適配全新OpenHarmony5.0 Release
    的頭像 發(fā)表于 11-18 19:03 ?1144次閱讀
    如何在開(kāi)源<b class='flag-5'>鴻蒙</b><b class='flag-5'>OpenHarmony</b>開(kāi)啟SELinux模式?RK3566<b class='flag-5'>鴻蒙</b>開(kāi)發(fā)板演示

    OpenHarmony怎么修改DPI密度值?觸覺(jué)智能RK3566鴻蒙開(kāi)發(fā)板演示

    開(kāi)源鴻蒙OpenHarmony系統(tǒng)下,修改DPI密度值的方法,觸覺(jué)智能Purple Pi OH鴻蒙開(kāi)發(fā)板演示,搭載了瑞芯微RK3566四核處理器,Laval鴻蒙社區(qū)推薦開(kāi)發(fā)板,已適配全
    的頭像 發(fā)表于 12-24 11:46 ?980次閱讀
    <b class='flag-5'>OpenHarmony</b>怎么修改DPI密度值?觸覺(jué)智能RK3566<b class='flag-5'>鴻蒙</b>開(kāi)發(fā)板演示