You can build the plug-in in the absence of Mozilla's source tree but
for any serious development you'll want to run a debugging build of
the browser.

Building Mozilla for Plug-in Development
========================================

Step 1:

  First, check out the source from CVS, following the steps at

  http://www.mozilla.org/cvs.html

  You must use the client.mk file to do the checkout so that the
  correct modules are retreived.

Step 2:

  Apply any patches you need.

Step 3:

  Create a build directory next to the mozilla tree.

Step 4:

  Now you need to configure Mozilla.  Change to the build directory
  and run:

  ../mozilla/configure --enable-extensions=default,irc --enable-crypto --without-system-nspr --enable-xft --enable-default-toolkit=gtk2 --enable-xinerama --disable-mailnews --prefix=`pwd`/dist

  This set of flags is suitable for plug-in development.

Step 4:

  Now build Mozilla, preferably using gcc 3.2.  Problems have been
  reported when building with more recent versions of gcc.

  make -s
  make -s install

  The resulting binary and wrapper scripts end up in dist/bin in the
  build directory.  Run the browser using the "mozilla" script.

Debugging gcjwebplugin in Mozilla
=================================

From dist/bin in the Mozilla build directory:

  export LD_LIBRARY_PATH=`pwd`:$(libgcj_prefix)/lib

  gdb ./mozilla-bin

Now from gdb:

  run

Wait for the Mozilla window to come up.  Then, from the gdb window,
press Ctrl-C to suspend the browser's execution.

Now you need to set a breakpoint in Mozilla at a point just after the
plug-in has been loaded, but before any of its functions have been
called.  At that point, the plug-in's symbols will be available to
gdb, so you will be able to set breakpoints in the plug-in code.

The call to load the plug-in .so is
pluginFile.LoadPlugin(pluginLibrary) in
modules/plugin/base/src/nsPluginHostImpl.cpp.  So for my version of
Mozilla, I do this:

  break nsPluginHostImpl.cpp:4545

which sets a breakpoint just after the LoadPlugin call.

Then,

  continue

In Mozilla, enter the URL of a web page that loads an applet
(preferably a local one, for security reasons!).  This will cause
Mozilla to load the plug-in .so and hit the breakpoint you set.  From
this point, you should be able to set breakpoints anywhere in the
plug-in.
