Archive for May, 2012

Part 1: TI’s EXP430F5529 Experimenter Board setup

After several tries, I finally succeeded in getting my EXP430F5529 Experimenter Board to work.

Main site:

http://www.ti.com/tool/MSP-EXP430F5529

The steps taken are as follows:

a. Download CCSv4 from TI here and install it:

http://software-dl.ti.com/download/dsps/RMIAZSQERFRRJSJ5MKM33QE_@KKAPPFD/setup_CCS_MC_Core.zip

This version of CCSv4 is meant for the experimenter board, and therefore requires no license.

b. Download the examples for the experimenter board here and install it:

http://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/MSPEXP430F5529UE/latest/index_FDS.html

c. Using the CCSv4’s “Files->Import” feature, navigate to the above samples’ directory (default is C:\TI) and try importing the examples as “existing projects”.

d. Using the CCSv4’s “View->C/C++ Projects” feature, select “build” to build the specific projects required (the chosen by me is called “User Experience”, setting it as the active project).

e. Then through many other unexplainable clicking/setting the target configuration:

0x043A2: 27FC JEQ (0x439c)
0x043A4: 89EA FD78 SUB.B @R9,0xfd78(R10)
0x043A8: B5F5 98A4 BIT.B @R5+,0x98a4(R5)
0x043AC: 8D7B SUB.B @R13+,R11
0x043AE: DF75 BIS.B @R15+,R5
0x043B0: D6F7 49B3 BIS.B @R6+,0x49b3(R7)
0x043B4: E7F0 F43D XOR.B @R7+,0x37f3
0x043B8: 735E SUBC.B #1,R14
0x043BA: F57C AND.B @R5+,R12
0x043BC: BD3F BIT.W @R13+,R15
0x043BE: F52B AND.W @R5,R11
0x043C0: BBFF EFA5 BIT.B @R11+,0xefa5(R15)
0x043C4: 6757 529E ADDC.B 0x529e(R7),R7
0x043C8: F497 5C7A 672B AND.W 0x5c7a(R4),0x672b(R7)
0x043CE: BF9A FABF E5B7 BIT.W 0xfabf(R15),0xe5b7(R10)
0x043D4: 2DEF JHS (0x47b4)
0x043D6: AFAF 6E98 DADD.W @R15,0x6e98(R15)
0x043DA: D4CE 67DF BIS.B R4,0x67df(R14)
0x043DE: 9CFD E41C CMP.B @R12+,0xe41c(R13)
0x043E2: 0000 BRA @PC
0x043E4: 1100 RRA PC
0x043E6: 0010 BRA @PC+
0x043E8: E53E XOR.W @R5+,R14
0x043EA: 0000 BRA @PC
0x043EC: 5AFD FFFF ADD.B @R10+,0xffff(R13)
0x043F0: 0003 MOVA @PC,R3
0x043F2: 5AFD 5AFD ADD.B @R10+,0x5afd(R13)
0x043F6: 5AFD 000B ADD.B @R10+,0x000b(R13)
0x043FA: AF76 DADD.B @R15+,R6
0x043FC: 4418 0000 MOV.W 0x0000(R4),R8
0x04400: 4031 4400 MOV.W #0x4400,SP==========>the start of system_pre_init(), where I set my breakpoint (filename is called src/CCS/system_pre_init.c).

0x04404: 13B0 F8B8 CALLA #0x0f8b8
0x04408: 930C TST.W R12
0x0440A: 240E JEQ (0x4428)
0x0440C: 403C 2484 MOV.W #0x2484,R12
0x04410: 403D 0FA2 MOV.W #0x0fa2,R13
0x04414: 13B0 F73C CALLA #0x0f73c
0x04418: 403C 2400 MOV.W #0x2400,R12
0x0441C: 403D 6322 MOV.W #0x6322,R13
0x04420: 403E 0083 MOV.W #0x0083,R14
0x04424: 13B0 F95A CALLA #0x0f95a
0x04428: 13B0 AED6 CALLA #0x0aed6
0x0442C: 13B0 F926 CALLA #0x0f926
0x04430: 93A2 04AE CMP.W #2,&RTC__Real_Time_Clock_RTCIV

And the copy register feature allow us to copy the contents to the clipboard as well:

http://pastebin.com/XbyrMTpF

Other references:

http://software-dl.ti.com/dsps/dsps_public_sw/sdo_ccstudio/workshops/CCSv5/CCSv5_AdvancedWorkshop.pdf

http://www.ti.com/lit/ug/slau330a/slau330a.pdf

Advertisements

Code Snippets for Firefox (from MDN)

  1. Code snippets – MDN

    https://developer.mozilla.org/en/Code_snippets
    20 Mar 2012 – This is a quick list of useful code snippets (small code samples) available for developers of extensions for the various Mozilla applications.

  2. Code snippets Alerts and Notifications – Mozilla Developer Network

    https://developer.mozilla.org/en/Code…/Alerts_and_Notifications
    16 Sep 2010 – Pop-ups. notify.png. The following code presents a non-modal pop-up, which automatically disappears after an appropriate delay. It uses

  3. Code snippets Tree – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/Tree
    2 Jul 2010 – Expanding/Collapsing all tree nodes. To expand all tree nodes: var treeView = tree.treeBoxObject.view; for (var i = 0; i < treeView.rowCount

  4. Code snippets Customizing the download progress bar

    https://developer.mozilla.org/…/Customizing_the_download_progres
    17 Nov 2009 – This example illustrates how to customize the progress bar displayed for a given download in the Downloads window. First you need to overlay

  5. Code snippets JavaScript Debugger Service – Mozilla Developer

    https://developer.mozilla.org/en/Code…/JavaScript_Debugger_Servic
    23 May 2011 – is an XPCOM Component that allows the tracking of JavaScript while it is being executed in the browser. An Overview. Acquiring the Service

  6. Code snippets On page load – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/On_page_load
    This article is for XUL/JavaScript developers who want to have custom code executed each time a new page is loaded in browser/mail. If you need finer control

  7. Code snippets HTML in XUL for rich tooltips – Mozilla Developer

    https://developer.mozilla.org/en/…/HTML_in_XUL_for_rich_tooltips
    19 Dec 2009 – Dynamic HTML in XUL Tooltip. Insert the appropriate code from below into your XUL overlay. This example is what the final XUL overlay could

  8. Code snippets Windows – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/Windows
    12 Jul 2011 – Opening new browser windows. To open a new browser window, you can simply use window.open() . However, window.open() returns a

  9. Code snippets HTML to DOM – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/HTML_to_DOM
    21 Mar 2012 – Using a hidden iframe element to parse HTML to a window’s DOM; 3. Using a hidden XUL iframe (alternate example). Although you can now

  10. Bookmarks – MDN

    https://developer.mozilla.org/en/Code_snippets/Bookmarks
    30 Jan 2009 – Creating a new bookmark. var win = myBrowser.contentWindow; // Get the bookmarks service const BMSVC

  11. Code snippets Sidebar – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/Sidebar
    26 Jan 2012 – Opening and closing the sidebar. Firefox provides a built-in toggleSidebar() function defined in browser.js . This means that the function is

  12. Miscellaneous – MDN – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/Miscellaneous
    11 May 2011 – Saving the current web page to a local file. Although the following code does not prompt the user for a filename, you can do so using the file

  13. Code snippets Finding window handles – Mozilla Developer Network

    https://developer.mozilla.org/…/Code_snippets:Finding_Window_Ha
    10 Sep 2010 – Starting in Gecko 2.0 (Firefox 4 / Thunderbird 3.3 / SeaMonkey 2.1) , only the top level browser window has an HWND. Web content windows

  14. Code snippets Finding window handles – Mozilla Developer Network

    https://developer.mozilla.org/en/Code…/Finding_Window_Handles
    10 Sep 2010 – 3. Yet Another way to find a window handle (parent window handle). When working on Windows platforms, many APIs and frameworks require

  15. browser.xul – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/Tabbed_browser
    12 Jan 2012 – Here you should find a set of useful code snippets to help you work with Firefox’s tabbed browser. The comments normally mark where you

  16. Post data to window – MDN

    https://developer.mozilla.org/en/Code…/Post_data_to_window
    9 Jun 2011 – This offers examples of sending POST data to the server and displaying the server response. Need more elaborate examples, examples of

  17. Code snippets LookupNamespaceURI – Mozilla Developer Network

    https://developer.mozilla.org/En/Code…/LookupNamespaceURI
    23 Sep 2010 – Note that all Gecko-based browsers (including Firefox) support Node.lookupNamespaceURI. This function is not necessary for Gecko-based

  18. Code snippets Cookies – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/Cookies
    26 Jan 2012 – Reading existing cookies. var ios = Components.classes[“@mozilla.org/network/io-service;1”] .getService(Components.interfaces.nsIIOService)

    You visited this page on 5/6/12.

  19. Canvas – MDN

    https://developer.mozilla.org/en/Code_snippets/Canvas
    29 Nov 2011 – For general information about using <canvas> see the canvas topic page. Chaining methods. Class to give jQuery-style chained access to 2D

  20. Label and description – MDN

    https://developer.mozilla.org/en/Code…/Label_and_description
    10 Oct 2008 – Line breaking. Under normal conditions, a description will not break long-running text and the text may be cropped or hidden. To cause the text

  21. Threads – MDN

    https://developer.mozilla.org/en/Code_snippets/Threads
    20 Feb 2011 – One of the most common questions related to extension development is how to perform long-running operations in the background. If not done

  22. getAttributeNS – MDN

    https://developer.mozilla.org/en/Code_snippets/getAttributeNS
    18 Feb 2009 – As some browsers do not support getAttributeNS, the following might be used to work on them as well. While namespaced attributes are less

  23. Embedding SVG – MDN

    https://developer.mozilla.org/en/Code_snippets/Embedding_SVG
    29 Oct 2008 – Embedding in XHTML. Make sure you use the right namespace when embedding. Notice the template and example use XHTML to handle the

  24. Code snippets Downloading Files – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/Downloading_Files
    12 Feb 2011 – Downloading files. To download a file, create an instance of nsIWebBrowserPersist and call its nsIWebBrowserPersist.saveURI() method

    You visited this page on 5/6/12.

  25. JS XPCOM – MDN

    https://developer.mozilla.org/en/Code_snippets/JS_XPCOM
    4 Mar 2009 – Interfaces. Every XPCOM object implements one or more interfaces. An interface is simply a list of constants and methods that can be called on

  26. Code snippets Running applications – Mozilla Developer Network

    https://developer.mozilla.org/en/Code…/Running_applications
    14 Jul 2011 – This method has the same effect as if you double-clicked the file, so for executable files—it will just run the file without any parameters. For more

  27. IsDefaultNamespace – MDN

    https://developer.mozilla.org/En/Code_snippets/IsDefaultNamespace
    18 Feb 2009 – quickly return the standard value for Mozilla browsers). // http://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-isDefaultNamespace

  28. Code snippets Progress Listeners – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/Progress_Listeners
    22 Feb 2011 – Progress Listeners. Progress listeners allow extensions to be notified of events associated with documents loading in the browser and with tab

  29. Code snippets Dialogs and Prompts – Mozilla Developer Network

    https://developer.mozilla.org/en/Code…/Dialogs_and_Prompts
    8 Nov 2011 – Dialogs in Mozilla. Whenever you want to create a dialog in your application, use <dialog> (instead of usual <window>) as root element in the

  30. Preferences – MDN

    https://developer.mozilla.org/en/Code_snippets/Preferences
    20 Mar 2012 – This article provides examples for extension developers that wish to use the Mozilla preferences system. Information here applies to the Mozilla

  31. Scrollbar – MDN

    https://developer.mozilla.org/en/Code_snippets/Scrollbar
    16 Jun 2010 – This example shows how to style the scrollbars in your xul application. Scrollbars inside browser elements will be styled to. Tested on windows

  32. Code snippets LookupPrefix – Mozilla Developer Network

    https://developer.mozilla.org/En/Code_snippets/LookupPrefix
    15 Apr 2010 – This function is not necessary for Gecko-based browsers when used in XHTML. function lookupPrefix (node, namespaceURI) { var htmlMode

  33. Code snippets QuerySelector – Mozilla Developer Network

    https://developer.mozilla.org/En/Code_snippets/QuerySelector
    23 Dec 2011 – Along the lines of other frameworks such as jQuery or Prototype, shortening the “querySelector” name can be convenient. function $ (selector

  34. Code snippets Toolbar – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/Toolbar
    1 Feb 2012 – Adding a toolbar button. There are two tutorials available: An elaborate step by step tutorial for beginners: Custom Toolbar Button; A tutorial

  35. Tabbox – MDN

    https://developer.mozilla.org/En/Code_snippets/Tabbox
    3 Aug 2010 – Handling onclosetab Event. Assuming the tabbox, tabs, and tabpanels widgets with id’s the same as their nodeName, this function will correctly

  36. Page Loading – MDN

    https://developer.mozilla.org/en/Code_snippets/Page_Loading
    24 Apr 2007 – Page Loading. On page load: How to execute code each time a new page is loaded in browser/mail. Progress Listeners: Progress listeners

  37. SVG General – MDN

    https://developer.mozilla.org/en/Code_snippets/SVG_General
    26 Mar 2011 – On this page you will find some simple, general information on SVG markup. Hopefully, enough to get you creating some SVG images. You will

  38. XPath – MDN

    https://developer.mozilla.org/En/Code_snippets/XPath
    15 Nov 2008 – Notes and sample code for XPath and Ajax. (The following was moved from document.evaluate) obj.evaluate(xpathExpression,contextNode

  39. Boxes – MDN

    https://developer.mozilla.org/en/Code_snippets/Boxes
    23 Jun 2008 – Wrapping contents. In HTML you can use a DIV as a container and when the DIV changes size, the contents will wrap or adjust the layout.

  40. XML – MDN

    https://developer.mozilla.org/en/Code_snippets/XML
    24 Jun 2008 – How to Create a DOM tree · Using XMLHttpRequest · Parsing and serializing XML · Using XPath · XSL Transforms · XLink · XInclude · xml:id

  41. Autocomplete – MDN

    https://developer.mozilla.org/en/Code_snippets/Autocomplete
    30 Jul 2011 – Turning on autocomplete. First, declare a panel with the “autocomplete” type, like so: <panel id=”popup_autocomplete” type=”autocomplete”

  42. Code snippets URI parsing – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/URI_parsing
    30 Nov 2009 – Grabbing the main domain using the EffectiveTLDService. Even using the ETLDService, you’re unable to get just the base domain sans TLD.

  43. Code snippets Modules – Mozilla Developer Network

    https://developer.mozilla.org/En/Code_snippets/Modules
    9 Jan 2010 – Some simple code to turn a JavaScript module into non-Mozilla-specific code (e.g., if porting to the browser). The use of eval() will probably not

  44. Interaction between privileged and non – Mozilla Developer Network

    https://developer.mozilla.org/…/Interaction_between_privileged_and
    13 Sep 2011 – Sending data from unprivileged document to chrome. An easy way to send data from a web page to an extension is by using custom DOM

  45. base function – MDN

    https://developer.mozilla.org/en/Code_snippets/xml/base_function
    24 Jun 2008 – These two functions aim to allow some support for xml:base. Note however, that this code is not based on a thorough examination of the specs

  46. Code snippets HTML in XUL for rich tooltips – Mozilla Developer

    https://developer.mozilla.org/…/HTML_in_XUL_for_rich_tooltips?…
    19 Dec 2009 – Dynamic HTML in XUL Tooltip. Insert the appropriate code from below into your XUL overlay. This example is what the final XUL overlay could

  47. Code snippets Windows – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/Windows?action
    12 Jul 2011 – Opening new browser windows. To open a new browser window, you can simply use window.open() . However, window.open() returns a

  48. Code snippets QuerySelector – Mozilla Developer Network

    https://developer.mozilla.org/En/Code_snippets/QuerySelector?…
    23 Dec 2011 – Along the lines of other frameworks such as jQuery or Prototype, shortening the “querySelector” name can be convenient. function $ (selector

  49. Code snippets Sidebar – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/Sidebar?action=edit
    26 Jan 2012 – Opening and closing the sidebar. Firefox provides a built-in toggleSidebar() function defined in browser.js . This means that the function is

  50. Code snippets Dialogs and Prompts – Mozilla Developer Network

    https://developer.mozilla.org/en/Code…/Dialogs_and_Prompts?action
    8 Nov 2011 – Dialogs in Mozilla. Whenever you want to create a dialog in your application, use <dialog> (instead of usual <window>) as root element in the

  51. Code snippets Downloading Files – Mozilla Developer Network

    https://developer.mozilla.org/en/Code…/Downloading_Files?action
    12 Feb 2011 – Downloading files. To download a file, create an instance of nsIWebBrowserPersist and call its nsIWebBrowserPersist.saveURI() method

  52. Code snippets Progress Listeners – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/Progress_Listeners?…
    22 Feb 2011 – Progress Listeners. Progress listeners allow extensions to be notified of events associated with documents loading in the browser and with tab

  53. Code snippets Cookies – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/Cookies?action=edit
    26 Jan 2012 – Reading existing cookies. var ios = Components.classes[“@mozilla.org/network/io-service;1”] .getService(Components.interfaces.nsIIOService)

  54. Code snippets Customizing the download progress bar

    https://developer.mozilla.org/…/Customizing_the_download_progres
    17 Nov 2009 – This example illustrates how to customize the progress bar displayed for a given download in the Downloads window. First you need to overlay

  55. Miscellaneous – MDN – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/Miscellaneous?…
    11 May 2011 – Saving the current web page to a local file. Although the following code does not prompt the user for a filename, you can do so using the file

  56. Code snippets HTML to DOM – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/HTML_to_DOM?…
    22 Feb 2012 – Using a hidden XUL iframe (alternate example). Although you can now natively parse HTML using DOMParser and XMLHttpRequest , this is a

  57. Code snippets JavaScript Debugger Service – Mozilla Developer

    https://developer.mozilla.org/en/…/JavaScript_Debugger_Service?…
    23 May 2011 – reference to undefined name ‘syntax’ Exception of type ‘MindTouch.Deki.Script.Runtime.DekiScriptUndefinedNameException’ was thrown.

  58. Code snippets On page load – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/On_page_load?…
    This article is for XUL/JavaScript developers who want to have custom code executed each time a new page is loaded in browser/mail. If you need finer control

  59. Code snippets Toolbar – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/Toolbar?action=edit
    1 Feb 2012 – Adding a toolbar button. There are two tutorials available: An elaborate step by step tutorial for beginners: Custom Toolbar Button; A tutorial

  60. Code snippets Tree – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/Tree?action=edit
    2 Jul 2010 – Expanding/Collapsing all tree nodes. To expand all tree nodes: var treeView = tree.treeBoxObject.view; for (var i = 0; i < treeView.rowCount

  61. Code snippets LookupPrefix – Mozilla Developer Network

    https://developer.mozilla.org/En/Code_snippets/LookupPrefix?…
    15 Apr 2010 – This function is not necessary for Gecko-based browsers when used in XHTML. function lookupPrefix (node, namespaceURI) { var htmlMode

  62. browser.xul – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/Tabbed_browser?…
    12 Jan 2012 – Here you should find a set of useful code snippets to help you work with Firefox’s tabbed browser. The comments normally mark where you

  63. Code snippets Finding window handles – Mozilla Developer Network

    https://developer.mozilla.org/en/Code…/Finding_Window_Handles?…
    10 Sep 2010 – 3. Yet Another way to find a window handle (parent window handle). When working on Windows platforms, many APIs and frameworks require

  64. Code snippets LookupNamespaceURI – Mozilla Developer Network

    https://developer.mozilla.org/En/Code…/LookupNamespaceURI?…
    23 Sep 2010 – Note that all Gecko-based browsers (including Firefox) support Node.lookupNamespaceURI. This function is not necessary for Gecko-based

  65. Code snippets Alerts and Notifications – Mozilla Developer Network

    https://developer.mozilla.org/en/Code…/Alerts_and_Notifications?…
    16 Sep 2010 – Pop-ups. notify.png. The following code presents a non-modal pop-up, which automatically disappears after an appropriate delay. It uses

  66. Code snippets Running applications – Mozilla Developer Network

    https://developer.mozilla.org/en/Code…/Running_applications?action
    14 Jul 2011 – This method has the same effect as if you double-clicked the file, so for executable files—it will just run the file without any parameters. For more

  67. Code snippets Modules – Mozilla Developer Network

    https://developer.mozilla.org/En/Code_snippets/Modules?action
    9 Jan 2010 – Some simple code to turn a JavaScript module into non-Mozilla-specific code (e.g., if porting to the browser). The use of eval() will probably not

  68. Code snippets URI parsing – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/URI_parsing?action
    30 Nov 2009 – Grabbing the main domain using the EffectiveTLDService. Even using the ETLDService, you’re unable to get just the base domain sans TLD.

  69. Code snippets File I/O – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/File_I%2F%2FO
    31 Mar 2012 – Available libraries. There are a few JavaScript wrappers for I/O XPCOM components. See JSLib and io.js (original by MonkeeSage). The io.js

    You visited this page on 5/6/12.

  70. Interaction between privileged and non – Mozilla Developer Network

    https://developer.mozilla.org/…/Interaction_between_privileged_and
    13 Sep 2011 – Sending data from unprivileged document to chrome. An easy way to send data from a web page to an extension is by using custom DOM

  71. Code snippets File I/O – Mozilla Developer Network

    https://developer.mozilla.org/en/Code_snippets/File_I%2F%2FO?…
    4 Sep 2011 – Available libraries. There are a few JavaScript wrappers for I/O XPCOM components. See JSLib and io.js (original by MonkeeSage). The io.js

More firefox gems

  1. Dev : Firefox Chrome URLs – MozillaZine Knowledge Base

    kb.mozillazine.org/Dev_:_Firefox_Chrome_URLs
    130+ items – This page is currently in need of being merged into a duplicate

    Chrome URL Description
    chrome://browser/content/aboutDialog.xul Help->About Mozilla
    chrome://browser/content/browser.xul Main browser window
  2. Dev : Extending the Chrome Protocol – MozillaZine Knowledge Base

    kb.mozillazine.org/Dev_:_Extending_the_Chrome_Protocol
    15 May 2005 – This component implements an extension mechanism to the chrome protocol handler for mapping in dynamically generated content into

  3. Extension development – MozillaZine Knowledge Base

    kb.mozillazine.org/Dev_:_Extensions
    2 Feb 2007 – Introduction.

    Extensions allow programmers to add new features to Mozilla applications or allow existing features to be modified. Typically

  4. Dev : Project ideas – MozillaZine Knowledge Base

    kb.mozillazine.org/Dev_:_Project_ideas
    29 Sep 2006 – Project ideas. This is a page for developers who are looking for ideas to start hacking on. Users, please discuss it on the forums (in Features or

  5. Dev : Protocol Handlers – MozillaZine Knowledge Base

    kb.mozillazine.org/Dev_:_Protocol_Handlers
    16 Apr 2005 – All URIs and URLs start with a specific scheme such as HTTP or FTP. Mozilla uses XPCOM components to implement protocol handlers for

  6. Setting up extension development environment – MozillaZine

    kb.mozillazine.org/Dev_:_Useful_prefs
    24 May 2007 – From MozillaZine Knowledge Base. (Redirected from Dev : Useful prefs). See Setting up extension development environment at MDC.

  7. Application framework – MozillaZine Knowledge Base

    kb.mozillazine.org/Dev_:_Application_framework
    10 May 2006 – See Mozilla Application Framework in Detail at developer.mozilla.org. Retrieved from “http://kb.mozillazine.org/Application_framework”

  8. Dev : Plugins – MozillaZine Knowledge Base

    kb.mozillazine.org/Dev_:_Plugins
    7 May 2006 – See Gecko Plugin API Reference at developer.mozilla.org. Retrieved from “http://kb.mozillazine.org/Dev_:_Plugins”. Category: Redirects

  9. Theme development – MozillaZine Knowledge Base

    kb.mozillazine.org/Dev_:_Themes
    14 Dec 2009 – (Redirected

    from Dev : Themes). See Themes at the Mozilla Developer Center. There’s also a Theme Development forum at MozillaZine.

  10. JavaScript coding guidelines – MozillaZine Knowledge Base

    kb.mozillazine.org/Dev_:_Javascript_coding_guidelines
    22 May 2007 – From MozillaZine Knowledge Base. (Redirected from Dev : Javascript coding guidelines). See JavaScript style guide at developer.mozilla.org.

  11. JavaScript variables – MozillaZine Knowledge Base

    kb.mozillazine.org/Dev_:_Javascript_variables
    9 May 2006 – From MozillaZine Knowledge Base. (Redirected from Dev : Javascript variables). See Javscript 1.5 Guide: Variables at developer.mozilla.org.

  12. Dev : Using preferences – MozillaZine Knowledge Base

    kb.mozillazine.org/Dev_:_Using_preferences
    22 Jan 2007 – Dev : Using preferences. From MozillaZine Knowledge Base. Moved here. Retrieved from “http://kb.mozillazine.org/Dev_:_Using_preferences”

  13. Development resources – MozillaZine Knowledge Base

    kb.mozillazine.org/Dev_:_Extensions_:_Resources
    24 Jun 2007 – XUL. XML User Interface Language, widely used in Mozilla to specify user interfaces in a platform-independent way. XulPlanet the premier

  14. DOM Inspector – MozillaZine Knowledge Base

    kb.mozillazine.org/Dev_:_Tools_:_DOM_Inspector
    Available documentation. The article “Introduction to the DOM Inspector” provides a basic overview of the DOMi. It’s a good place to orient yourself with the DOMi

  15. Bash build script – MozillaZine Knowledge Base

    kb.mozillazine.org/Dev_:_Extensions_:_Bash_build_script
    11 Jul 2010 – Script 1. Here is a bash script I’m using to package my extensions (under Cygwin). See also Windows build script. #!/bin/bash # build.sh

  16. Windows build script – MozillaZine Knowledge Base

    kb.mozillazine.org/Dev_:_Extensions_:_Windows_cmd_build_script
    20 Jan 2007 – Using 7-zip. Inspired by roachfiend’s build script, which uses 7-Zip and Windows cmd/command.com shell. Here’s what you need to do:

  17. Dev : Extensions : Extension does not install – MozillaZine

    kb.mozillazine.org/Dev_:_Extensions_:_Extension_does_not_install
    17 Apr 2005 – This page describes possible reasons for extension installation problems. Intended audience is extension developers, not end-users.

  18. Releasing extension – MozillaZine Knowledge Base

    kb.mozillazine.org/Dev_:_Extensions_:_Releasing
    5 Jun 2007 – Once you have created an extension, share it with the community! There are a few major sites that list extensions for Mozilla products. The most

  19. Dev : Extensions : Example Code – MozillaZine Knowledge Base

    kb.mozillazine.org/Dev_:_Extensions_:_Example_Code
    7 Oct 2005 – From MozillaZine Knowledge Base. This page has been moved to Category:Example code. Please update your bookmarks. Retrieved from

  20. Dev : Extensions : Example Extensions – MozillaZine Knowledge Base

    kb.mozillazine.org/Dev_:_Extensions_:_Example_Extensions
    27 Jan 2006 – Java (not JavaScript) in Extensions. Java Firefox Extension A skeleton Firefox extension that demonstrates how to use Java inside a Firefox

  21. Overlays – MozillaZine Knowledge Base

    kb.mozillazine.org/Dev_:_Extensions_:_Overlays
    23 May 2007 – See XUL Overlays and XUL Tutorial: Cross Package Overlays at MDC. Retrieved from “http://kb.mozillazine.org/Overlays”. Category: Redirects

  22. Inserting text at cursor – MozillaZine Knowledge Base

    kb.mozillazine.org/Dev_:_Tips_:_Inserting_text_at_cursor
    25 May 2007 – See Code snippets: Miscellaneous – Inserting text at the cursor at MDC. Retrieved from “http://kb.mozillazine.org/Inserting_text_at_cursor”

  23. Error Console – MozillaZine Knowledge Base

    kb.mozillazine.org/Dev_:_Tips_:_Printing_to_JSConsole
    30 Apr 2009 – From MozillaZine Knowledge Base. (Redirected from Dev : Tips : Printing to JSConsole). See Error Console at developer.mozilla.org. Retrieved

  24. Viewing dump() output – MozillaZine Knowledge Base

    kb.mozillazine.org/Dev_:_Tips_:_Enabling_dump
    7 May 2006 – See dump() documentation at developer.mozilla.org. Retrieved from “http://kb.mozillazine.org/Viewing_dump%28%29_output”. Category:

  25. Dev : Gecko -moz – MozillaZine Knowledge Base

    kb.mozillazine.org/Dev_:_Gecko_-moz
    7 May 2006 – See CSS Reference: Mozilla Extensions and Creating a Skin for Mozilla: In-Depth – Mozilla CSS Properties at developer.mozilla.org. Retrieved

  26. Dev : Tips : Disable XUL cache – MozillaZine Knowledge Base

    kb.mozillazine.org/Dev_:_Tips_:_Disable_XUL_cache
    23 May 2007 – Dev : Tips : Disable XUL cache. From MozillaZine Knowledge Base. See Setting up extension development environment at MDC. Retrieved

  27. Dev : Extensions : Example Code : Adding Drag and Drop to

    kb.mozillazine.org/Dev_:_Extensions_:_Example_Code_:_Adding_…
    5 Feb 2007 – drag.js file. Add the code below to a javascript file and put it in the same directory as the overlay file. Change the flavour variable and the name

  28. Dev : Extensions : Cross-Version Compatibility Techniques

    kb.mozillazine.org/Dev_:_Extensions_:_Cross-Version_Compatibilit…
    24 Oct 2005 – Introduction.

    See also Adapting XUL Applications for Firefox_1.5 document on Devmo. The simplest way to distribute an extension is to have a

  29. Implementing XPCOM components in JavaScript – MozillaZine

    kb.mozillazine.org/Dev_:_Extensions_:_Example_Code_:_JS_XPCOM
    12 Jan 2012 – Welcome to Implementing XPCOM components in JavaScript. This article provides information about creating a Javascript XPCOM class.

  30. Adding items to menus – MozillaZine Knowledge Base

    kb.mozillazine.org/Dev_:_Extensions_:_Example_Code_:_Adding_it…
    5 Feb 2010 – Note: development documentation is in process of being moved to Mozilla Development Center (MDC). Note: Information in this section applies

  31. Install.rdf – MozillaZine Knowledge Base

    kb.mozillazine.org/Dev_:_Extensions_:_install.rdf
    30 Nov 2008 – Most of information here applies to install.rdf used in themes too. See below for detailed information. Firefox 0.9, Thunderbird 0.7, Nvu 0.? and

  32. Dev : Plugins : Printing : Unix – MozillaZine Knowledge Base

    kb.mozillazine.org/Dev_:_Plugins_:_Printing_:_Unix
    10 Mar 2006 – Plugin Printing On Unix. This page records the history of support for printing pages containing plugins. Note it’s not a complete reference to the

  33. Dev : Extensions : Example Code : Calling Java from Javascript

    kb.mozillazine.org/Dev_:_Extensions_:_Example_Code_:_Calling_J…
    3 Dec 2005 – From MozillaZine Knowledge Base. This page is currently notes of what I had to do to call Java from Javascript from Thunderbird. Here’s an

  34. Contents.rdf – MozillaZine Knowledge Base

    kb.mozillazine.org/Dev_:_Extensions_:_contents.rdf
    19 Sep 2005 – contents.rdf

    files were used to register chrome packages and overlays before Gecko 1.8 (Firefox/Thunderbird 1.1). Gecko 1.8 applications still

  35. Running applications – MozillaZine Knowledge Base

    kb.mozillazine.org/Dev_:_Extensions_:_Example_Code_:_Run_prog…
    9 Nov 2006 – From MozillaZine Knowledge Base. (Redirected from Dev : Extensions : Example Code : Run programs). Moved to MDC. Retrieved from

  36. On page load – MozillaZine Knowledge Base

    kb.mozillazine.org/Dev_:_Extensions_:_Example_Code_:_On_Tab_…
    30 Jan 2007 – From MozillaZine Knowledge Base. (Redirected from Dev : Extensions : Example Code : On Tab Load). Article moved to MDC. Retrieved from

  37. Progress listeners – MozillaZine Knowledge Base

    kb.mozillazine.org/Dev_:_Extensions_:_Example_Code_:_Progress_…
    30 Jan 2007 – From MozillaZine Knowledge Base. (Redirected from Dev : Extensions : Example Code : Progress Listeners). Moved to MDC. Retrieved from

  38. Inserting text at cursor – MozillaZine Knowledge Base

    kb.mozillazine.org/Dev_:_Extensions_:_Example_Code_:_Inserting_…
    25 May 2007 – See Code snippets: Miscellaneous – Inserting text at the cursor at MDC. Retrieved from “http://kb.mozillazine.org/Inserting_text_at_cursor”

  39. XPath – MozillaZine Knowledge Base

    kb.mozillazine.org/Dev_:_Extensions_:_Example_Code_:_Using_XP…
    8 Nov 2006 – From MozillaZine Knowledge Base. (Redirected from Dev : Extensions : Example Code : Using XPath to query a DOM object). Moved to here

  40. Enumerating tabbrowser tabs – MozillaZine Knowledge Base

    kb.mozillazine.org/Dev_:_Extensions_:_Example_Code_:_Enumerat…
    6 Feb 2007 – From MozillaZine Knowledge Base. (Redirected from Dev : Extensions : Example Code : Enumerating tabbrowser tabs). Moved to MDC

  41. Dev : Extensions : Example Code : Encoding – MozillaZine

    kb.mozillazine.org/Dev_:_Extensions_:_Example_Code_:_Encoding
    23 May 2007 – From MozillaZine Knowledge Base. See Code snippets: Miscellaneous – Simple and unsafe encoding at MDC. Retrieved from

  42. File IO – MozillaZine Knowledge Base

    kb.mozillazine.org/Dev_:_Extensions_:_Example_Code_:_File_IO
    8 Jun 2011 – (Redirected

    from Dev : Extensions : Example Code : File IO). Moved [1] (MDC). Retrieved from “http://kb.mozillazine.org/File_IO”. Category:

  43. Creating sidebar – MozillaZine Knowledge Base

    kb.mozillazine.org/Dev_:_Extensions_:_Example_Code_:_Opening_…
    23 May 2007 – From MozillaZine Knowledge Base. (Redirected from Dev : Extensions : Example Code : Opening Sidebar). See Creating a Firefox sidebar at

  44. Using observers – MozillaZine Knowledge Base

    kb.mozillazine.org/Dev_:_Extensions_:_Example_Code_:_Using_ob…
    23 May 2007 – See nsIObserver and nsIObserverService at MDC. Retrieved from “http://kb.mozillazine.org/Using_observers”. Category: Redirects

  45. Dev : Extensions : Example Code : Using the scrollwheel

    kb.mozillazine.org/Dev_:_Extensions_:_Example_Code_:_Using_the…
    24 May 2007 – Dev : Extensions : Example Code : Using the scrollwheel. From MozillaZine Knowledge Base. See Code snippets: Miscellaneous – Detecting

  46. Opening a new browser window (development) – MozillaZine

    kb.mozillazine.org/Dev_:_Extensions_:_Example_Code_:_Opening_…
    6 Feb 2007 – From MozillaZine Knowledge Base. (Redirected from Dev : Extensions : Example Code : Opening a new browser window). Moved to MDC.

  47. Creating dialogs – MozillaZine Knowledge Base

    kb.mozillazine.org/Dev_:_Extensions_:_Example_Code_:_Apply_bu…
    31 Oct 2006 – (Redirected

    from Dev : Extensions : Example Code : Apply button). Moved to MDC. Retrieved from “http://kb.mozillazine.org/Creating_dialogs”

  48. JavaScript Preferences Class – MozillaZine Knowledge Base

    kb.mozillazine.org/Dev_:_Extensions_:_Example_Code_:_Javascript…
    9 Dec 2006 – From MozillaZine Knowledge Base. (Redirected from Dev : Extensions : Example Code : Javascript Preferences Class). Moved to MDC

  49. Prompt service – MozillaZine Knowledge Base

    kb.mozillazine.org/Dev_:_Extensions_:_Example_Code_:_nsIPrompt
    31 Oct 2006 – (Redirected from Dev : Extensions : Example Code : nsIPrompt). See http://developer.mozilla.org/en/docs/nsIPromptService. Retrieved from

  50. Error Console – MozillaZine Knowledge Base

    kb.mozillazine.org/Dev_:_Extensions_:_Example_Code_:_Printing_t…
    30 Apr 2009 – Example Code : Printing to JSConsole). See Error Console at developer.mozilla.org. Retrieved from “http://kb.mozillazine.org/Error_Console”

  51. Creating dialogs – MozillaZine Knowledge Base

    kb.mozillazine.org/Dev_:_Extensions_:_Example_Code_:_Dialogs
    31 Oct 2006 – (Redirected

    from Dev : Extensions : Example Code : Dialogs). Moved to MDC. Retrieved from “http://kb.mozillazine.org/Creating_dialogs”

  52. XMLHttpRequest – MozillaZine Knowledge Base

    kb.mozillazine.org/Dev_:_Extensions_:_Example_Code_:_Using_…
    26 Sep 2006 – See XMLHttpRequest at the Mozilla Developer Center. Retrieved from “http://kb.mozillazine.org/XMLHttpRequest”. Category: Redirects

  53. Io.js – MozillaZine Knowledge Base

    kb.mozillazine.org/Dev_:_Extensions_:_Example_Code_:_File_IO_:…
    5 Feb 2007 – Basic JavaScript File and Directory IO module // By: MonkeeSage, v0.1 // ///////////////////////////////////////////////// ///////////////////////////////////////////////// if (typeof(JSIO)

  54. Dev : Extensions : Example Code : Creating a XUL mailto: link

    kb.mozillazine.org/Dev_:_Extensions_:_Example_Code_:_Creating_…
    23 May 2007 – Dev : Extensions : Example Code : Creating a XUL mailto: link. From MozillaZine Knowledge Base. See XUL:Attribute:href at MDC. Retrieved

Firefox analysis with source codes

After compiling Firefox 12, and then going a “gdb firefox” and then “break main” and then “run”:

We get:

Breakpoint 1, main (argc=1, argv=0x7fffffffe268)
at /mnt/cdrive/firefox/mozilla-beta/browser/app/nsBrowserApp.cpp:212
212 {

Now the function has stopped at main(), located at the above file (nsBrowserApp.c) and “list” in gdb to see source codes:

(gdb) list
207
208 return result;
209 }
210
211 int main(int argc, char* argv[])
212 {
213 char exePath[MAXPATHLEN];
214
215 #ifdef XP_MACOSX
216 TriggerQuirks();

Now we use “next” to step over the functions execution:

(gdb) next
219 nsresult rv = mozilla::BinaryPath::Get(argv[0], exePath);
(gdb)
225 char *lastSlash = strrchr(exePath, XPCOM_FILE_PATH_SEPARATOR[0]);
(gdb) next
226 if (!lastSlash || (lastSlash - exePath > MAXPATHLEN - sizeof(XPCOM_DLL) - 1))
(gdb)
225 char *lastSlash = strrchr(exePath, XPCOM_FILE_PATH_SEPARATOR[0]);
(gdb)
226 if (!lastSlash || (lastSlash - exePath > MAXPATHLEN - sizeof(XPCOM_DLL) - 1))
(gdb)
229 strcpy(++lastSlash, XPCOM_DLL);
(gdb)
107 return __builtin___strcpy_chk (__dest, __src, __bos (__dest));
(gdb) list
102 #endif
103
104 __extern_always_inline char *
105 __NTH (strcpy (char *__restrict __dest, __const char *__restrict __src))
106 {
107 return __builtin___strcpy_chk (__dest, __src, __bos (__dest));
108 }
109
110 #ifdef __USE_GNU
111 __extern_always_inline char *
(gdb) n
234 gotCounters = !getrusage(RUSAGE_SELF, &initialRUsage);
(gdb)
246 XPCOMGlueEnablePreload();
(gdb)
250 rv = XPCOMGlueStartup(exePath);
(gdb)
251 if (NS_FAILED(rv)) {
(gdb) list
246 XPCOMGlueEnablePreload();
247 }
248
249
250 rv = XPCOMGlueStartup(exePath);
251 if (NS_FAILED(rv)) {
252 Output("Couldn't load XPCOM.\n");
253 return 255;
254 }
255 // Reset exePath so that it is the directory name and not the xpcom dll name
(gdb) n
252 Output("Couldn't load XPCOM.\n");
(gdb)
251 if (NS_FAILED(rv)) {
(gdb)
258 rv = XPCOMGlueLoadXULFunctions(kXULFuncs);
(gdb)
256 *lastSlash = 0;
(gdb)
258 rv = XPCOMGlueLoadXULFunctions(kXULFuncs);
(gdb)
259 if (NS_FAILED(rv)) {
(gdb)
268 if (gotCounters) {
(gdb)
283 int(initialRUsage.ru_majflt));
(gdb)
285 if (!getrusage(RUSAGE_SELF, &newRUsage)) {
(gdb)
287 int(newRUsage.ru_majflt - initialRUsage.ru_majflt));
(gdb)
294 ScopedLogging log;
(gdb)
295 result = do_main(exePath, argc, argv);
(gdb)

Now once it goes into do_main() it will not return, and thus “control-C” and then setting other breakpoints is needed.

In our cases, “rbreak nsHtml5Parser::*” is executed to stop all any of the functions in the nsHtml5Parser object.

Now a backtrace (bt) revealed all the functions executed:

Breakpoint 2, nsHtml5Parser::AddRef (this=0x7fffcf429a00)
at /mnt/cdrive/firefox/mozilla-beta/parser/html/nsHtml5Parser.cpp:71
71 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsHtml5Parser)
(gdb) bt
#0 nsHtml5Parser::AddRef (this=0x7fffcf429a00)
at /mnt/cdrive/firefox/mozilla-beta/parser/html/nsHtml5Parser.cpp:71
#1 0x00007ffff4243b9b in nsHtml5Module::NewHtml5Parser ()
at /mnt/cdrive/firefox/mozilla-beta/parser/html/nsHtml5Module.cpp:108
#2 0x00007ffff40e21d7 in nsHTMLDocument::StartDocumentLoad (
this=0x7fffcece2800, aCommand=0x7ffff4cccb5f "view",
aChannel=0x7fffce8b7050, aLoadGroup=<value optimized out>,
aContainer=<value optimized out>, aDocListener=<value optimized out>,
aReset=<value optimized out>, aSink=0x0)
at /mnt/cdrive/firefox/mozilla-beta/content/html/document/src/nsHTMLDocument.cpp:656
#3 0x00007ffff3dfc80a in nsContentDLF::CreateDocument (
this=<value optimized out>, aCommand=0x7ffff4cccb5f "view",
aChannel=0x7fffce8b7050, aLoadGroup=0x7fffdcf24d40,
aContainer=0x7fffdcf8d940, aDocumentCID=<value optimized out>,
aDocListener=0x7fffcf4fcb18, aContentViewer=0x7fffffffb180)
at /mnt/cdrive/firefox/mozilla-beta/layout/build/nsContentDLF.cpp:461
#4 0x00007ffff3dfcfce in nsContentDLF::CreateInstance (
this=<value optimized out>, aCommand=0x7ffff4cccb5f "view",
aChannel=0x7fffce8b7050, aLoadGroup=0x7fffdcf24d40,
aContentType=0x7fffd0625228 "text/html", aContainer=0x7fffdcf8d940,
aExtraInfo=0x0, aDocListener=0x7fffcf4fcb18, aDocViewer=0x7fffffffb180)
at /mnt/cdrive/firefox/mozilla-beta/layout/build/nsContentDLF.cpp:263
---Type <return> to continue, or q <return> to quit---
#5 0x00007ffff4446f48 in nsDocShell::NewContentViewerObj (
this=<value optimized out>, aContentType=0x7fffd0625228 "text/html",
request=<value optimized out>, aLoadGroup=<value optimized out>,
aContentHandler=<value optimized out>, aViewer=0x7fffffffb180)
at /mnt/cdrive/firefox/mozilla-beta/docshell/base/nsDocShell.cpp:7544
#6 0x00007ffff4451017 in nsDocShell::CreateContentViewer (
this=0x7fffdcf8d800, aContentType=<value optimized out>,
request=0x7fffce8b7050, aContentHandler=<value optimized out>)
at /mnt/cdrive/firefox/mozilla-beta/docshell/base/nsDocShell.cpp:7357
#7 0x00007ffff44544ef in nsDSURIContentListener::DoContent (
this=0x7fffdcd13f40, aContentType=0x7fffd0625228 "text/html",
aIsContentPreferred=true, request=0x7fffce8b7050,
aContentHandler=0x7fffcf4fcb18, aAbortProcess=<value optimized out>)
at /mnt/cdrive/firefox/mozilla-beta/docshell/base/nsDSURIContentListener.cpp:164
#8 0x00007ffff44579fc in nsDocumentOpenInfo::TryContentListener (
this=0x7fffcf4fcb00, aListener=0x7fffdcd13f40, aChannel=0x7fffce8b7050)
at /mnt/cdrive/firefox/mozilla-beta/uriloader/base/nsURILoader.cpp:709
#9 0x00007ffff4457bd5 in nsDocumentOpenInfo::DispatchContent (
this=0x7fffcf4fcb00, request=0x7fffce8b7050, aCtxt=<value optimized out>)
at /mnt/cdrive/firefox/mozilla-beta/uriloader/base/nsURILoader.cpp:406
#10 0x00007ffff445834c in nsDocumentOpenInfo::OnStartRequest (
this=0x7fffcf4fcb00, request=0x7fffce8b7050, aCtxt=0x0)
---Type <return> to continue, or q <return> to quit---
at /mnt/cdrive/firefox/mozilla-beta/uriloader/base/nsURILoader.cpp:294
#11 0x00007ffff3d51135 in nsHttpChannel::CallOnStartRequest (
this=0x7fffce8b7000)
at /mnt/cdrive/firefox/mozilla-beta/netwerk/protocol/http/nsHttpChannel.cpp:764
#12 0x00007ffff3d514eb in nsHttpChannel::ContinueProcessNormal (
this=0x7fffce8b7000, rv=4115409808)
at /mnt/cdrive/firefox/mozilla-beta/netwerk/protocol/http/nsHttpChannel.cpp:1260
#13 0x00007ffff3d554f5 in nsHttpChannel::ProcessNormal (this=0x7fffce8b7000)
at /mnt/cdrive/firefox/mozilla-beta/netwerk/protocol/http/nsHttpChannel.cpp:1197
#14 0x00007ffff3d55a0a in nsHttpChannel::ProcessResponse (this=0x7fffce8b7000)
at /mnt/cdrive/firefox/mozilla-beta/netwerk/protocol/http/nsHttpChannel.cpp:1099
#15 0x00007ffff3d55c6a in nsHttpChannel::OnStartRequest (this=0x7fffce8b7000,
request=0x7fffd4e5f4e0, ctxt=<value optimized out>)
at /mnt/cdrive/firefox/mozilla-beta/netwerk/protocol/http/nsHttpChannel.cpp:4164
#16 0x00007ffff3cdc1a9 in nsInputStreamPump::OnStateStart (this=0x7fffd4e5f4e0)
at /mnt/cdrive/firefox/mozilla-beta/netwerk/base/src/nsInputStreamPump.cpp:444
#17 0x00007ffff3cdc552 in nsInputStreamPump::OnInputStreamReady (
---Type <return> to continue, or q <return> to quit---
this=0x7fffd4e5f4e0, stream=<value optimized out>)
at /mnt/cdrive/firefox/mozilla-beta/netwerk/base/src/nsInputStreamPump.cpp:399

Executing further:
(gdb) bt
#0 nsHTMLDocument::StartDocumentLoad (this=0x7fffcece2800,
aCommand=0x7ffff4cccb5f "view", aChannel=0x7fffce8b7050,
aLoadGroup=<value optimized out>, aContainer=<value optimized out>,
aDocListener=<value optimized out>, aReset=<value optimized out>,
aSink=0x0)
at /mnt/cdrive/firefox/mozilla-beta/content/html/document/src/nsHTMLDocument.cpp:860
#1 0x00007ffff3dfc80a in nsContentDLF::CreateDocument (
this=<value optimized out>, aCommand=0x7ffff4cccb5f "view",
aChannel=0x7fffce8b7050, aLoadGroup=0x7fffdcf24d40,
aContainer=0x7fffdcf8d940, aDocumentCID=<value optimized out>,
aDocListener=0x7fffcf4fcb18, aContentViewer=0x7fffffffb180)
at /mnt/cdrive/firefox/mozilla-beta/layout/build/nsContentDLF.cpp:461

and looking at the source code:
(gdb) list nsHTMLDocument::StartDocumentLoad
559 nsILoadGroup* aLoadGroup,
560 nsISupports* aContainer,
561 nsIStreamListener **aDocListener,
562 bool aReset,
563 nsIContentSink* aSink)
564 {
565 nsCAutoString contentType;
566 aChannel->GetContentType(contentType);

and jumpping ahead – here a check is done if the document is from POST command:

783 // check if current doc is from POST command
784 nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(aChannel));
785 if (httpChannel) {
786 nsCAutoString methodStr;
787 rv = httpChannel->GetRequestMethod(methodStr);
788 isPostPage = (NS_SUCCEEDED(rv) &&
(gdb)
789 methodStr.EqualsLiteral("POST"));
790 }

and next is the tokenization of the the HTML stream:
(gdb) bt
#0 nsHtml5Parser::StartTokenizer (this=0x7fffcf429a00, aScriptingEnabled=true)
at /mnt/cdrive/firefox/mozilla-beta/parser/html/nsHtml5Parser.cpp:742
#1 0x00007ffff424a432 in nsHtml5StreamParser::OnStartRequest (
this=0x7fffd6043bc0, aRequest=<value optimized out>,
aContext=<value optimized out>)
at /mnt/cdrive/firefox/mozilla-beta/parser/html/nsHtml5StreamParser.cpp:926
#2 0x00007ffff445836a in nsDocumentOpenInfo::OnStartRequest (
this=0x7fffcf4fcb00, request=0x7fffce8b7050, aCtxt=0x0)
at /mnt/cdrive/firefox/mozilla-beta/uriloader/base/nsURILoader.cpp:304
#3 0x00007ffff3d51135 in nsHttpChannel::CallOnStartRequest (
this=0x7fffce8b7000)
at /mnt/cdrive/firefox/mozilla-beta/netwerk/protocol/http/nsHttpChannel.cpp:764
#4 0x00007ffff3d514eb in nsHttpChannel::ContinueProcessNormal (
this=0x7fffce8b7000, rv=1)
at /mnt/cdrive/firefox/mozilla-beta/netwerk/protocol/http/nsHttpChannel.cpp:1260

Continue next time.

Firefox reverse engineering via walking the stack

Firefox source is easily available, but too huge to read. So doing a “gdb -p <pid>” to attach to a particular <pid> of the running Firefox process, and issuing “bt”, “rbreak” commands I can walk into different stacktrace – as it revealed the sequence of functions called:
(gdb) bt
#0 0x00007fb313956543 in poll () from /lib/libc.so.6
#1 0x00007fb310c1669e in PollWrapper(_GPollFD*, unsigned int, int) ()
#2 0x00007fb30ea7d4a9 in ?? () from /lib/libglib-2.0.so.0
#3 0x00007fb30ea7d8fc in g_main_context_iteration ()
#4 0x00007fb310c1665f in nsAppShell::ProcessNextNativeEvent(bool) ()
#5 0x00007fb310c2d240 in nsBaseAppShell::OnProcessNextEvent(nsIThreadInternal*, bool, unsigned int) ()
#6 0x00007fb310d93936 in nsThread::ProcessNextEvent(bool, bool*) ()
#7 0x00007fb310d61c59 in NS_ProcessNextEvent_P(nsIThread*, bool) ()
#8 0x00007fb310cd82fb in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) ()
#9 0x00007fb310dc931e in MessageLoop::Run() ()
#10 0x00007fb310c2ccf7 in nsBaseAppShell::Run() ()
#11 0x00007fb310aedbd8 in nsAppStartup::Run() ()
#12 0x00007fb310235fd0 in XREMain::XRE_mainRun() ()
#13 0x00007fb3102331cc in XREMain::XRE_main(int, char**, nsXREAppData const*)
#14 0x00007fb31023332e in XRE_main ()
#15 0x0000000000402709 in main ()

from above….can see many functions too: XRE_main(), nsAppStartup::Run() etc.

First, download the Firefox from nightly built at:

http://nightly.mozilla.org/

and then gdb -p <pid> to attach to the running Firefox process.

Next, “rbreak”:

(gdb) rbreak nsBaseAppShell::*
Breakpoint 1 at 0x7fb310c2cca0
<function, no debug info> nsBaseAppShell::DoProcessMoreGeckoEvents();
Breakpoint 2 at 0x7fb310c2ccac
<function, no debug info> nsBaseAppShell::SuspendNative();
Breakpoint 3 at 0x7fb310c2ccb2
<function, no debug info> nsBaseAppShell::ResumeNative();
Breakpoint 4 at 0x7fb310c2ccb8
<function, no debug info> nsBaseAppShell::GetEventloopNestingLevel(unsigned int*);
Breakpoint 5 at 0x7fb310c2ccca
<function, no debug info> nsBaseAppShell::Run();
Breakpoint 6 at 0x7fb310c2cd10

And then “info breakpoints” to see all the breakpoints set:

(gdb) info breakpoints

Num Type Disp Enb Address What
1 breakpoint keep y 0x00007fb310c2cca0 <nsBaseAppShell::DoProcessMoreGeckoEvents()>
2 breakpoint keep y 0x00007fb310c2ccac <nsBaseAppShell::SuspendNative()>
3 breakpoint keep y 0x00007fb310c2ccb2 <nsBaseAppShell::ResumeNative()>
4 breakpoint keep y 0x00007fb310c2ccb8 <nsBaseAppShell::GetEventloopNestingLevel(unsigned int*)>
5 breakpoint keep y 0x00007fb310c2ccca <nsBaseAppShell::Run()>
6 breakpoint keep y 0x00007fb310c2cd10 <nsBaseAppShell::~nsBaseAppShell()>
7 breakpoint keep y 0x00007fb310c2cd10 <nsBaseAppShell::~nsBaseAppShell()>
8 breakpoint keep y 0x00007fb310c2cd48 <nsBaseAppShell::~nsBaseAppShell()>
9 breakpoint keep y 0x00007fb310c2cd5a <nsBaseAppShell::nsBaseAppShell()>
10 breakpoint keep y 0x00007fb310c2cd5a <nsBaseAppShell::nsBaseAppShell()>
11 breakpoint keep y 0x00007fb310c2cde4 <nsBaseAppShell::DoProcessNextNativeEvent(bool)>
12 breakpoint keep y 0x00007fb310c2ce14 <nsBaseAppShell::RunInStableS---Type <return> to continue, or q <return> to quit---
tate(nsIRunnable*)>
13 breakpoint keep y 0x00007fb310c2ce78 <nsBaseAppShell::Init()>
14 breakpoint keep y 0x00007fb310c2cef0 <nsBaseAppShell::FavorPerformanceHint(bool, unsigned int)>
15 breakpoint keep y 0x00007fb310c2cf30 <nsBaseAppShell::OnDispatchedEvent(nsIThreadInternal*)>
16 breakpoint keep y 0x00007fb310c2cf60 <non-virtual thunk to nsBaseAppShell::OnDispatchedEvent(nsIThreadInternal*)>
17 breakpoint keep y 0x00007fb310c2cf70 <nsBaseAppShell::Exit()>
18 breakpoint keep y 0x00007fb310c2cf96 <nsBaseAppShell::Observe(nsISupports*, char const*, unsigned short const*)>
19 breakpoint keep y 0x00007fb310c2cfc0 <non-virtual thunk to nsBaseAppShell::Observe(nsISupports*, char const*, unsigned short const*)>
20 breakpoint keep y 0x00007fb310c2cfd0 <nsBaseAppShell::QueryInterface(nsID const&, void**)>
21 breakpoint keep y 0x00007fb310c2cff0 <non-virtual thunk to nsBaseAppShell::QueryInterface(nsID const&, void**)>
22 breakpoint keep y 0x00007fb310c2d000 <non-virtual thunk to nsBaseAppShell::QueryInterface(nsID const&, void**)>
23 breakpoint keep y 0x00007fb310c2d010 <nsBaseAppShell::Release()>
24 breakpoint keep y 0x00007fb310c2d040 <non-virtual thunk to nsBaseAppShell::Release()>
25 breakpoint keep y 0x00007fb310c2d050 <non-virtual thunk to nsBaseA---Type <return> to continue, or q <return> to quit---
ppShell::Release()>
26 breakpoint keep y 0x00007fb310c2d060 <nsBaseAppShell::AddRef()>
27 breakpoint keep y 0x00007fb310c2d070 <non-virtual thunk to nsBaseAppShell::AddRef()>
28 breakpoint keep y 0x00007fb310c2d080 <non-virtual thunk to nsBaseAppShell::AddRef()>
breakpoint already hit 1 time
29 breakpoint keep y 0x00007fb310c2d090 <nsBaseAppShell::AfterProcessNextEvent(nsIThreadInternal*, unsigned int)>
30 breakpoint keep y 0x00007fb310c2d0f0 <non-virtual thunk to nsBaseAppShell::AfterProcessNextEvent(nsIThreadInternal*, unsigned int)>
31 breakpoint keep y 0x00007fb310c2d100 <nsBaseAppShell::OnProcessNextEvent(nsIThreadInternal*, bool, unsigned int)>
32 breakpoint keep y 0x00007fb310c2d400 <non-virtual thunk to nsBaseAppShell::OnProcessNextEvent(nsIThreadInternal*, bool, unsigned int)>
33 breakpoint keep y 0x00007fb310c2d410 <nsBaseAppShell::NativeEventCallback()>
34 breakpoint keep y 0x00007fb310c2d4aa <nsBaseAppShell::RunSyncSections()>

Issuing next a sequence of “cont” and “bt” (in succession) I can get the sequence of backtrace functions:

(gdb) bt

#0 0x00007fb310c2d080 in non-virtual thunk to nsBaseAppShell::AddRef() ()
#1 0x00007fb310d9371b in nsThread::PutEvent(nsIRunnable*) ()
#2 0x00007fb310d973fa in nsTimerImpl::PostTimerEvent() ()
#3 0x00007fb310d97f79 in TimerThread::Run() ()
#4 0x00007fb310d93d10 in nsThread::ProcessNextEvent(bool, bool*) ()
#5 0x00007fb310d61c59 in NS_ProcessNextEvent_P(nsIThread*, bool) ()
#6 0x00007fb310d94815 in nsThread::ThreadFunc(void*) ()
#7 0x00007fb3134ebb94 in _pt_root ()
from /home/tthtlc/Downloads/firefox_5may2012_nightly/firefox/libnspr4.so
#8 0x00007fb3147bf9ca in start_thread () from /lib/libpthread.so.0
#9 0x00007fb313962cdd in clone () from /lib/libc.so.6
#10 0x0000000000000000 in ?? ()

And another backtrace (from a different thread btw):

(gdb) bt

#0 0x00007fb310c2cf30 in nsBaseAppShell::OnDispatchedEvent(nsIThreadInternal*) ()
#1 0x00007fb310d93736 in nsThread::PutEvent(nsIRunnable*) ()
#2 0x00007fb310d973fa in nsTimerImpl::PostTimerEvent() ()
#3 0x00007fb310d97f79 in TimerThread::Run() ()
#4 0x00007fb310d93d10 in nsThread::ProcessNextEvent(bool, bool*) ()
#5 0x00007fb310d61c59 in NS_ProcessNextEvent_P(nsIThread*, bool) ()
#6 0x00007fb310d94815 in nsThread::ThreadFunc(void*) ()
#7 0x00007fb3134ebb94 in _pt_root ()
from /home/tthtlc/Downloads/firefox_5may2012_nightly/firefox/libnspr4.so
#8 0x00007fb3147bf9ca in start_thread () from /lib/libpthread.so.0
#9 0x00007fb313962cdd in clone () from /lib/libc.so.6
#10 0x0000000000000000 in ?? ()

To find out the parsing functions:

nm firefox/libxul.so |grep -i parse |grep -i htm

0000000000ba6f60 t _ZThn176_N15HTMLContentSink13OpenContainerERK13nsIParserNode
0000000000ba6310 t _ZThn176_N15HTMLContentSink7AddLeafERK13nsIParserNode
0000000000ba65f0 t _ZThn176_N15HTMLContentSink9SetParserEP12nsParserBase
0000000000ba4f40 t _ZThn176_N15HTMLContentSink9WillParseEv
0000000000d25930 t _ZThn176_N21nsHtml5TreeOpExecutor9SetParserEP12nsParserBase
0000000000d24a10 t _ZThn176_N21nsHtml5TreeOpExecutor9WillParseEv
0000000000ba4730 t _ZThn456_N18nsHTMLVideoElement18GetMozParsedFramesEPj
0000000000cf2b80 t _ZThn8_N13nsHtml5Parser14QueryInterfaceERK4nsIDPPv
0000000000cf2aa0 t _ZThn8_N13nsHtml5Parser6AddRefEv
0000000000cf3010 t _ZThn8_N13nsHtml5Parser7ReleaseEv
0000000000d27160 t _ZThn8_N19nsHtml5StreamParser14QueryInterfaceERK4nsIDPPv
0000000000d27070 t _ZThn8_N19nsHtml5StreamParser6AddRefEv

these are C++ mangled naming convention.

Using a “rbreak nsHtml5Parser” and TAB key, we can get all the names:
nsHtml5Parser::AddRef()
nsHtml5Parser::BeginEvaluatingParserInsertedScript()
nsHtml5Parser::BlockParser()
nsHtml5Parser::BuildModel()
nsHtml5Parser::CanInterrupt()
nsHtml5Parser::CancelParsingEvents()
nsHtml5Parser::ContinueAfterFailedCharsetSwitch()
nsHtml5Parser::ContinueInterruptedParsing()
nsHtml5Parser::ContinueInterruptedParsingAsync()
nsHtml5Parser::DropStreamParser()
nsHtml5Parser::EndEvaluatingParserInsertedScript()
nsHtml5Parser::GetChannel(nsIChannel**)
nsHtml5Parser::GetCommand(nsCString&)
nsHtml5Parser::GetContentSink()
nsHtml5Parser::GetDTD(nsIDTD**)
nsHtml5Parser::GetDocumentCharset(nsACString_internal&, int&)
nsHtml5Parser::GetStreamListener()
nsHtml5Parser::Initialize(nsIDocument*, nsIURI*, nsISupports*, nsIChannel*)
nsHtml5Parser::InitializeDocWriteParserState(nsAHtml5TreeBuilderState*, int)
nsHtml5Parser::IsComplete()
nsHtml5Parser::IsInsertionPointDefined()
nsHtml5Parser::IsParserEnabled()
nsHtml5Parser::IsScriptCreated()
nsHtml5Parser::MarkAsNotScriptCreated(char const*)
nsHtml5Parser::Parse(nsAString_internal const&, void*, nsACString_internal const&, bool, nsDTDMode)
nsHtml5Parser::Parse(nsIURI*, nsIRequestObserver*, void*, nsDTDMode)
nsHtml5Parser::ParseFragment(nsAString_internal const&, nsTArray<nsString, nsTArrayDefaultAllocator>&)
nsHtml5Parser::ParseUntilBlocked()
nsHtml5Parser::QueryInterface(nsID const&, void**)
nsHtml5Parser::QueryInterface(nsID const&, void**)::table
nsHtml5Parser::Release()
nsHtml5Parser::Reset()
nsHtml5Parser::SetCommand(char const*)
nsHtml5Parser::SetCommand(eParserCommands)
nsHtml5Parser::SetContentSink(nsIContentSink*)
nsHtml5Parser::SetDocumentCharset(nsACString_internal const&, int)
nsHtml5Parser::StartTokenizer(bool)
nsHtml5Parser::Terminate()
nsHtml5Parser::UnblockParser()
nsHtml5Parser::_cycleCollectorGlobal
nsHtml5Parser::cycleCollection::Traverse(void*, nsCycleCollectionTraversalCallback&)
nsHtml5Parser::cycleCollection::Unlink(void*)
nsHtml5Parser::cycleCollection::UnmarkIfPurple(nsISupports*)
nsHtml5Parser::nsHtml5Parser()
nsHtml5Parser::operator new(unsigned long)
nsHtml5Parser::~nsHtml5Parser()
nsHtml5ParserThreadTerminator::AddRef()
nsHtml5ParserThreadTerminator::Observe(nsISupports*, char const*, unsigned short const*)
nsHtml5ParserThreadTerminator::QueryInterface(nsID const&, void**)
nsHtml5ParserThreadTerminator::QueryInterface(nsID const&, void**)::table
nsHtml5ParserThreadTerminator::Release()
nsHtml5ParserThreadTerminator::nsHtml5ParserThreadTerminator(nsIThread*)

Doing a breakpoint via “rbreak nsHtml5Parser*” and “cont” and “bt” we get:

#0 0x00007fb310840620 in nsHtml5Parser::operator new(unsigned long) ()
#1 0x00007fb31084071b in nsHtml5Module::NewHtml5Parser() ()
#2 0x00007fb3106cc682 in nsHTMLDocument::StartDocumentLoad(char const*, nsIChannel*, nsILoadGroup*, nsISupports*, nsIStreamListener**, bool, nsIContentSink*) ()
#3 0x00007fb310376651 in nsContentDLF::CreateDocument(char const*, nsIChannel*, nsILoadGroup*, nsISupports*, nsID const&, nsIStreamListener**, nsIContentViewer**) ()
#4 0x00007fb310376bd7 in nsContentDLF::CreateInstance(char const*, nsIChannel*, nsILoadGroup*, char const*, nsISupports*, nsISupports*, nsIStreamListener**, nsIContentViewer**) ()
#5 0x00007fb310a87bde in nsDocShell::NewContentViewerObj(char const*, nsIRequest*, nsILoadGroup*, nsIStreamListener**, nsIContentViewer**) ()
#6 0x00007fb310a942df in nsDocShell::CreateContentViewer(char const*, nsIRequest*, nsIStreamListener**) ()
#7 0x00007fb310a965f5 in nsDSURIContentListener::DoContent(char const*, bool, nsIRequest*, nsIStreamListener**, bool*) ()
#8 0x00007fb310a99116 in nsDocumentOpenInfo::TryContentListener(nsIURIContentListener*, nsIChannel*) ()
#9 0x00007fb310a99342 in nsDocumentOpenInfo::DispatchContent(nsIRequest*, nsISupports*) ()
#10 0x00007fb310a99aef in nsDocumentOpenInfo::OnStartRequest(nsIRequest*, nsISupports*) ()
#11 0x00007fb3102d6f25 in nsHttpChannel::CallOnStartRequest() ()
#12 0x00007fb3102d7331 in nsHttpChannel::ContinueProcessNormal(unsigned int) ()
#13 0x00007fb3102d74bf in nsHttpChannel::ProcessNormal() ()
#14 0x00007fb3102d904e in nsHttpChannel::ProcessResponse() ()
#15 0x00007fb3102d9cc4 in nsHttpChannel::OnStartRequest(nsIRequest*, nsISupports*) ()
#16 0x00007fb310257d0b in nsInputStreamPump::OnStateStart() ()
#17 0x00007fb31025805a in nsInputStreamPump::OnInputStreamReady(nsIAsyncInputStream*) ()
#18 0x00007fb310d83732 in nsInputStreamReadyEvent::Run() ()
#19 0x00007fb310d93b23 in nsThread::ProcessNextEvent(bool, bool*) ()
#20 0x00007fb310d61c59 in NS_ProcessNextEvent_P(nsIThread*, bool) ()
#21 0x00007fb310cd82fb in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) ()
#22 0x00007fb310dc931e in MessageLoop::Run() ()
#23 0x00007fb310c2ccf7 in nsBaseAppShell::Run() ()
#24 0x00007fb310aedbd8 in nsAppStartup::Run() ()
#25 0x00007fb310235fd0 in XREMain::XRE_mainRun() () #26 0x00007fb3102331cc in XREMain::XRE_main(int, char**, nsXREAppData const*)
#27 0x00007fb31023332e in XRE_main ()
#28 0x0000000000402709 in main ()

Interesting reverse engineering of Firefox….

%d bloggers like this: