Monday, February 22, 2010

breaking the firefox

Since last Thursday when Dave taught us how to use ms visual studio(ms vs) to attach a process to debug, I started to want to figure how Firefox call its functions that inside the js files.

What I did last Thursday 
I attached to Firefox and went through the source code about how it handle the windows message event. However, I could only be able to work on that for three hours, and then I have to concentrate my attention on my project management course. And it keeps me busy until this after.

What I did today afternoon
At last time, I already saw some familiar windows api. Therefore, this time, I directly setup a break point at the message WM_LBUTTONUP(line 4139 of /widget/src/windows/nsWindow.cpp). What I want is try to find out where it connect to the js source code. Then I step into, step over again and again. I suddenly I lost on there. It looks like a maze. I am going to the same source code again and again. and then I realize my thought that the message WM_LBUTTONUP triggers the addTab(definition)(my previous post) directly is wrong. It is INDIRECTLY! There are many other message have been called between them. The ms vs is very slow, so that I can't go through them one by one.

To solve this problem 
I put a line 'printf("zbhuang1 Msg: %d", (int)msg);' before line 3739 of /widget/src/windows/nsWindow.cpp. By the way, when you are holding the scroll bar of debug terminal, the minefield will be pause. Ok, the build is done. I click the "open a new tab" button at the tab bar,then pause the browser, release it, pause it... try to get the message which show up when a new Tab is display.

What I get
3 Full HD 1080p screen shot, no.0, no.1, no.2.
What I wonder is the message 133 and 144, because they only display once each time. Then, I setup the break point at there like this. It turns out that actually the message 15 display the tab which doesn't make sense for me.

What I go to do next
I put a 'print("disk cache read broken!");' (copy and paste, and forgot to change. lol) into addTab. Now it is building. Hope it will tell me which windows message call it. And I need to prepare my dinner :)

Concision
Maybe what I have done so far is meaningless, but that kind of structure have seeded in my mind. There are many many questions in my mind now. Why they use such a difficult structure? How they make Mozilla cross platform? How they make the Cpp program call a js function?
There are so many questions I cannot answer by this time, but I know if I keep going I will fine the answer.

No comments:

Post a Comment