HookLogger的安装使用方法

下载解压后,开始安装,再选择安装文件夹的时候,千万注意不要用默认的"C:\Program Files\Common Files\Symbian\tools..."这个目录,这个路径含有空格,呆会配置的时候会出错,所以你要挑个名称不含空格的文件夹来放如:"C:\symbian\tools",安装好之后,此时你运行是没有用的(还未连接模拟器).

将下面的代码复制到记事本里,并改名为"1.bat"

@echo off

   REM 下面的是设置你安装的SDK中epoc32的路径(下面的是我的,注意斜杠的区别)

   set EPOCROOT=C:/Symbian/7.0s/Series60_v21_C/

   echo HookEUSER

REM 下面的是设置HookLogger安装路径(下面的是我的)

set path="C:\Symbian\tool";%path%

cmd

运行1.bat后,在其中输入HookEUSER.pl winscw(或者HookEUSER.pl wins)

回车后,会提示你已经拷贝一个文件,并且已经将...改名为...,那就是成功了,现在打开HookEUSER,再启动模拟器,哈哈,怎么样?HookEUSER是不是已经有反应了?...不必修改HookEUSER.pl,方便快捷

在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...!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值