S60 3rd下如何使用HookLogger查找内存泄漏错误?(转)

2024-01-27 11:32

本文主要是介绍S60 3rd下如何使用HookLogger查找内存泄漏错误?(转),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

近日,在一个S60 3rd的项目里,调试一个内存泄漏错误,总也找不到是哪里出了问题。想到以前曾碰到过一个HookLogger的工具可以检测内存泄漏,于是就下载过来。试用了一下效果相当不错,很快就找到了发生错误的位置。下面具体描述在S60 3rd环境下怎么安装与使用HookLogger:

1、下载:
http://developer.symbian.com/main/downloads/files/HookLogger_Setup.zip

2、安装:(假定使用的是S60 3rd MR版)
解压HookLogger_Setup.zip后运行安装程序,按默认安装。

在S60 3rd下使用HookLogger,稍微有些问题,修改如下:
1) 在系统的环境变量设置里,添加环境变量EPOCROOT,其值为/Symbian/9.1/S60_3rd_MR/
2) (可用记事本)打开文件
C:/Program Files/Common Files/Symbian/tools/HookEUSER.pl
替换
    my $cmd = "copy $hooks_src";

    my $cmd = "copy /"$hooks_src/"";
以及替换
    $cmd = "$Bin/AttachDll $euser $hooks $hooked_euser";

    $cmd = "/"$Bin/AttachDll/" $euser $hooks $hooked_euser";
保存后退出。
3)打开一个控制台(DOS窗口),改变当前目录为:
C:/Program Files/Common Files/Symbian/tools
然后运行
hookeuser winscw

3、使用:
先启动HookLogger,然后启动Emulator。运行你的程序,再现MemLeak直到异常退出。这时,转到HookLogger的Heap页,点击下面的按钮“List All Allocs”将列出发生内存泄漏的地址。然后双击某条信息即可查看明细情况,甚至可以打开源代码文件,非常方便!

详情可参考[注2]。

4、卸载:
参考2.3,运行
hookeuser -r winscw

评:HookLogger是一个好工具,在对内存泄漏毫无头绪时,可帮你迅速找到问题之所在。

[注1] http://developer.symbian.com/main/tools/devtools/code/index.jsp#debugging
[注2] http://www.symbian.net.cn/blog/post/5.html 

 

Use HookLogger to trace memroy leak in S60 3rd SDK

 

Link to download HoopLogger: http://developer.symbian.com/main/tools/devtools/code/index.jsp

The HookLogger application is a Windows GUI-based tool which provides easy journalling facilities for logging memory allocations, processes, thread  creation and leaves when executing an application under the Symbian OS Emulator. The main use for most developers is pin-pointing the source of a leaked  heap cell. This tool can be installed in any directory and monitors the execution of a Symbian application under any Symbian OS SDK. The user has to  issue a command in order to replace EUSER.DLL of the target Symbian OS SDK with a version that allows the attachment of "hooks" which are used by the  HookLogger tool. After the execution session is finished the user can issue the same command in order to restore the original version of EUSER.DLL.

This article demonstrates how to use the HoopLogger in S60 3rd SDK, refer to http://developer.sonyericsson.com/site/global/techsupport/tipstrickscode/symbian/p_hooklogger_trace_memory_leaks_uiq3.jsp to know about how to use it in UIQ3 SDK. OK, here we go!

First, you should download the software from the link above and install it. It's recommended that you install the software in the default directory. Then you have to tell "HoopLogger" what SDK she is working on, so you open a console window and input the command "HookEUSER winscw" ("HookEUSER wins" for Symbian v7.0 or below). This is done by modifying euser.dll, again, the user can issue the same command in order to restore the original version of the file.

However, usually you may meet some problems when you excuting this command. I met 2 actually. If you have the error code:

Failed setting cwd to epoc32/release/winscw/udeb at C:/Symbian/HookLogger/HookEUSER.pl line 54.

That is most likely to mean that your "EPOC ROOT" environment variable is not set properly. To get it right, you should set he epoc root as the diagram below(in this case, it's for S60 3rd SDK):

OK, let's go ahead. But you may meet the problem like:

The system cannot find the file specified.
Failed running "copy C:/Program Files/Common Files/Symbian/Tools/EUserParasite_eka1.dll" at C:/Program Files/Common Files/Symbian/Tools/HookEUSER.pl line 76.

This problem can be solved by modifying HookEUser.pl file. Open this and find the line

my $cmd = "copy $hooks_src";

Replace this by

my $cmd = "copy /"$hooks_src/"";

And locate the line

$cmd = "$Bin/AttachDll $euser $hooks $hooked_euser";

Replace this by

$cmd = "/"$Bin/AttachDll/" $euser $hooks $hooked_euser";

Then you are done, try to excute the command again, if the message below shows, then HoopLogger is ready.

Target path is /Symbian/9.1/S60_3rd_MR/epoc32/release/winscw/UDEB 1 file(s) copied.
Modified euser.dll to hook EUserParasite_eka2.dll, original is euser.orig.dll.
Run HookEUSER with -r to restore

 OK, now we open the IDE and make a little memory leak deliberately. We input the code like this:

TInt* i = new TInt;
 i = new TInt;
 delete i;

Compile the code and launch the HookLogger first and switch to the "thread" label, should be empty there. Then lauch the 3rd Emulator, you should see many running threads' info appear like the diagram below:

Then make the memory leak happen, record the error code(here's 250295e4), like this:

Next you choose all the threads in "thread" label then swith to "heap" label and click "list all allocs" button. Wait for a while then look for "250295e4" in "ptr"column like below:

Double click it and there will be a window poped:

Take a look at the line in blue, it indicates that the memory leak is caused by the code in line 44, Symbian1appui.cpp, check your source code, does it right? Cool ah...!

这篇关于S60 3rd下如何使用HookLogger查找内存泄漏错误?(转)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!


原文地址:
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.chinasem.cn/article/650118

相关文章

Python虚拟环境终极(含PyCharm的使用教程)

《Python虚拟环境终极(含PyCharm的使用教程)》:本文主要介绍Python虚拟环境终极(含PyCharm的使用教程),具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,... 目录一、为什么需要虚拟环境?二、虚拟环境创建方式对比三、命令行创建虚拟环境(venv)3.1 基础命令3

Python Transformer 库安装配置及使用方法

《PythonTransformer库安装配置及使用方法》HuggingFaceTransformers是自然语言处理(NLP)领域最流行的开源库之一,支持基于Transformer架构的预训练模... 目录python 中的 Transformer 库及使用方法一、库的概述二、安装与配置三、基础使用:Pi

关于pandas的read_csv方法使用解读

《关于pandas的read_csv方法使用解读》:本文主要介绍关于pandas的read_csv方法使用,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录pandas的read_csv方法解读read_csv中的参数基本参数通用解析参数空值处理相关参数时间处理相关

使用Node.js制作图片上传服务的详细教程

《使用Node.js制作图片上传服务的详细教程》在现代Web应用开发中,图片上传是一项常见且重要的功能,借助Node.js强大的生态系统,我们可以轻松搭建高效的图片上传服务,本文将深入探讨如何使用No... 目录准备工作搭建 Express 服务器配置 multer 进行图片上传处理图片上传请求完整代码示例

SpringBoot条件注解核心作用与使用场景详解

《SpringBoot条件注解核心作用与使用场景详解》SpringBoot的条件注解为开发者提供了强大的动态配置能力,理解其原理和适用场景是构建灵活、可扩展应用的关键,本文将系统梳理所有常用的条件注... 目录引言一、条件注解的核心机制二、SpringBoot内置条件注解详解1、@ConditionalOn

Python中使用正则表达式精准匹配IP地址的案例

《Python中使用正则表达式精准匹配IP地址的案例》Python的正则表达式(re模块)是完成这个任务的利器,但你知道怎么写才能准确匹配各种合法的IP地址吗,今天我们就来详细探讨这个问题,感兴趣的朋... 目录为什么需要IP正则表达式?IP地址的基本结构基础正则表达式写法精确匹配0-255的数字验证IP地

使用Python实现全能手机虚拟键盘的示例代码

《使用Python实现全能手机虚拟键盘的示例代码》在数字化办公时代,你是否遇到过这样的场景:会议室投影电脑突然键盘失灵、躺在沙发上想远程控制书房电脑、或者需要给长辈远程协助操作?今天我要分享的Pyth... 目录一、项目概述:不止于键盘的远程控制方案1.1 创新价值1.2 技术栈全景二、需求实现步骤一、需求

Spring LDAP目录服务的使用示例

《SpringLDAP目录服务的使用示例》本文主要介绍了SpringLDAP目录服务的使用示例... 目录引言一、Spring LDAP基础二、LdapTemplate详解三、LDAP对象映射四、基本LDAP操作4.1 查询操作4.2 添加操作4.3 修改操作4.4 删除操作五、认证与授权六、高级特性与最佳

Qt spdlog日志模块的使用详解

《Qtspdlog日志模块的使用详解》在Qt应用程序开发中,良好的日志系统至关重要,本文将介绍如何使用spdlog1.5.0创建满足以下要求的日志系统,感兴趣的朋友一起看看吧... 目录版本摘要例子logmanager.cpp文件main.cpp文件版本spdlog版本:1.5.0采用1.5.0版本主要

Java中使用Hutool进行AES加密解密的方法举例

《Java中使用Hutool进行AES加密解密的方法举例》AES是一种对称加密,所谓对称加密就是加密与解密使用的秘钥是一个,下面:本文主要介绍Java中使用Hutool进行AES加密解密的相关资料... 目录前言一、Hutool简介与引入1.1 Hutool简介1.2 引入Hutool二、AES加密解密基础