Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Kernel Liteos A
提交
ce66a234
K
Kernel Liteos A
项目概览
OpenHarmony
/
Kernel Liteos A
1 年多 前同步成功
通知
464
Star
414
Fork
55
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
4
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel Liteos A
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
4
Issue
4
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
ce66a234
编写于
8月 02, 2021
作者:
O
openharmony_ci
提交者:
Gitee
8月 02, 2021
浏览文件
操作
浏览文件
下载
差异文件
!471 fix: 将用户态内存调测解析脚本移至tools目录下
Merge pull request !471 from Harylee/mem
上级
f85c27de
85b4cb7a
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
110 addition
and
0 deletion
+110
-0
tools/scripts/parse_memory/parse_mem_info.sh
tools/scripts/parse_memory/parse_mem_info.sh
+110
-0
未找到文件。
tools/scripts/parse_memory/parse_mem_info.sh
0 → 100755
浏览文件 @
ce66a234
#!/bin/bash
#Copyright (c) 2020-2021 Huawei Device Co., Ltd.
#Licensed under the Apache License, Version 2.0 (the "License");
#you may not use this file except in compliance with the License.
#You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#Unless required by applicable law or agreed to in writing, software
#distributed under the License is distributed on an "AS IS" BASIS,
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#See the License for the specific language governing permissions and
#limitations under the License.
LOAD_BASE
=
"0x2000000"
LLVM_ADDR2LINE
=
llvm-addr2line
GCC_ADDR2LINE
=
addr2line
get_line
()
{
SYM_ADDR
=
$(
echo
$1
|
awk
'{print $2}'
)
ELF_OFFSET
=
`
echo
${
SYM_ADDR
}
|
cut
-d
'['
-f2
|
cut
-d
']'
-f1
`
FILE_LINE
=
`
${
ADDR2LINE
}
-f
-e
$2
${
ELF_OFFSET
}
|
awk
'NR==2'
`
if
[[
"
${
FILE_LINE
}
"
==
*
"?"
*
]]
;
then
typeset
ELF_OFFSET
=
$((
ELF_OFFSET+LOAD_BASE
))
ELF_OFFSET
=
$(
echo
"obase=16;
${
ELF_OFFSET
}
"
| bc
)
FILE_LINE
=
`
${
ADDR2LINE
}
-f
-e
$2
${
ELF_OFFSET
}
|
awk
'NR==2'
`
fi
echo
${
FILE_LINE
}
}
parse_line
()
{
FILE_PATH
=
$(
echo
$1
|
awk
'{print $4}'
)
ELF_FILE
=
${
FILE_PATH
##*/
}
ELF_FILE
=
${
ELF_FILE
//[
$'
\t\r\n
'
]
}
FLAG
=
false
for
i
in
$2
;
do
if
[
"
${
ELF_FILE
}
"
=
"
$i
"
]
;
then
if
[
!
-f
"
$i
"
]
;
then
echo
"Error: no such file:
$i
"
exit
1
fi
FILE_LINE
=
`
get_line
"
$1
"
$i
`
if
[[
"
${
FILE_LINE
}
"
==
*
"?"
*
]]
||
[
-z
"
${
FILE_LINE
}
"
]
;
then
echo
" * Error: you need ensure whether file: "
$i
" was compiled with -g or not! *"
exit
1
fi
LINE
=
`
echo
$1
|
tr
-d
'\r'
`
LINE
=
$(
echo
${
LINE
}
|
awk
'{print $1,$2}'
)
echo
" "
${
LINE
}
" at "
${
FILE_LINE
}
FLAG
=
true
break
fi
done
if
[[
"
${
FLAG
}
"
==
"false"
]]
;
then
echo
" "
$1
fi
}
if
[
$#
-le
1
]
;
then
echo
"Usage: ./out2line.sh text.txt elf1 elf2 ..."
exit
1
fi
read
-n5
-p
"Compiler is [gcc/llvm]: "
ANSWER
case
${
ANSWER
}
in
(
gcc
|
GCC
)
which
${
GCC_ADDR2LINE
}
>
/dev/null 2>&1
if
[
$?
-eq
0
]
;
then
ADDR2LINE
=
${
GCC_ADDR2LINE
}
else
echo
"
${
GCC_ADDR2LINE
}
command not found!"
exit
1
fi
;;
(
llvm
|
LLVM
)
which
${
LLVM_ADDR2LINE
}
>
/dev/null 2>&1
if
[
$?
-eq
0
]
;
then
ADDR2LINE
=
${
LLVM_ADDR2LINE
}
else
echo
"
${
LLVM_ADDR2LINE
}
command not found! Trying to use
${
GCC_ADDR2LINE
}
!"
which
${
GCC_ADDR2LINE
}
>
/dev/null 2>&1
if
[
$?
-eq
0
]
;
then
ADDR2LINE
=
${
GCC_ADDR2LINE
}
else
echo
"
${
GCC_ADDR2LINE
}
command not found!"
exit
1
fi
fi
;;
(
*
)
echo
"Error choise!"
exit
1
esac
echo
-e
"Now using
${
ADDR2LINE
}
...
\n
"
PARAM_LIST
=
"
${
*
:2
}
"
cat
$1
|
while
read
line
;
do
HEAD_STRING
=
$(
echo
${
line
}
|
awk
'{print $1}'
)
if
[[
"
${
HEAD_STRING
}
"
==
*
"#"
*
]]
;
then
parse_line
"
${
line
}
"
"
${
PARAM_LIST
}
"
else
if
[[
"
${
HEAD_STRING
}
"
==
*
"["
*
]]
;
then
echo
" "
${
line
}
else
echo
${
line
}
fi
fi
done
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录