# Firefox with debug symbols - WITH_DEBUG doesn't work



## kenorb (Nov 4, 2010)

Installed Firefox:

```
> cd /usr/ports/www/firefox
> grep WITH_DEBUG *
Makefile,v:.if defined(WITH_DEBUG)
Makefile,v:CONFIGURE_ENV+=		WITH_DEBUG=yes
Makefile,v:.endif # defined(WITH_DEBUG)
Makefile,v:* Enable basic optimizations if WITH_DEBUG is not specified
distinfo,v:* Enable basic optimizations if WITH_DEBUG is not specified
pkg-descr,v:* Enable basic optimizations if WITH_DEBUG is not specified
pkg-message,v:* Enable basic optimizations if WITH_DEBUG is not specified
> make WITH_DEBUG install
```


```
(gdb) run
Starting program: /usr/local/lib/firefox3/firefox-bin 
(no debugging symbols found)...(no debugging symbols found)...(no debugging symbols found)...(no debugging symbols found)...(no debugging 
symbols found)...(no debugging symbols found)...(no debugging symbols found)...(no debugging symbols found)...(no debugging symbols found)...
(no debugging symbols found)...(no debugging symbols found)...(no debugging symbols found)...(no debugging symbols found)...(no debugging 
symbols found)...(no debugging symbols found)...(no debugging symbols found)...(no debugging symbols found)...(no debugging symbols found)...
(no debugging symbols found)...(no debugging symbols found)...(no debugging symbols found)...(no debugging symbols found)...(no debugging 
symbols found)...(no debugging symbols found)...(no debugging symbols found)...(no debugging symbols found)...(no debugging symbols found)...
(no debugging symbols found)...(no debugging symbols found)...(no debugging symbols found)...(no debugging symbols found)...(no debugging 
symbols found)...(no debugging symbols found)...(no debugging symbols found)...(no debugging symbols found)...(no debugging symbols found)...
(no debugging symbols found)...(no debugging symbols found)...[New LWP 100178]
```

Why it simply doesn't work?


----------



## SirDice (Nov 4, 2010)

You shouldn't have files that end in ,v in a port's directory. How did you get the ports tree?


----------



## kenorb (Nov 4, 2010)

No idea.
By:

```
> sudo csup -L2 /etc/ports-supfile
```
?
It was removed? If yes, why?


----------



## DutchDaemon (Nov 4, 2010)

There's no way to get e.g. pkg-descr*,v* using the default supfile. Like I said elsewhere: time to cut your losses and start over.


----------



## SirDice (Nov 5, 2010)

What tag did you use in your ports-supfile?

You've probably used cvs which isn't correct. It should be . (dot).

This probably explains all the problems you've been having. I'm surprised things even compiled.


----------



## kenorb (Nov 5, 2010)

```
...
*default host=cvsup.uk.FreeBSD.org
*default base=/var/db
*default prefix=/usr
*default release=cvs tag=.
*default delete use-rel-suffix
...
```
Copied from share/examples.


----------



## SirDice (Nov 5, 2010)

That looks good. But the files in /usr/ports/www/firefox/ should NOT end in *,v*. I don't know what went wrong but I think it's best to clear /usr/ports/ and csup again.


----------



## kenorb (Nov 5, 2010)

```
> sudo mv /usr/ports /usr/ports-bak
> sudo csup /etc/ports-supfile && cd /usr/ports/*/firefox && ll
-rw-r--r--  1 root  wheel  3802 Oct 28 12:46 Makefile
-rw-r--r--  1 root  wheel  8676 Jan 10  2009 Makefile.webplugins
-rw-r--r--  1 root  wheel   225 Oct 28 12:46 distinfo
drwxr-xr-x  2 root  wheel  1536 Nov  5 15:33 files
-rw-r--r--  1 root  wheel   329 Feb  7  2010 pkg-descr
-rw-r--r--  1 root  wheel  1535 Feb  7  2010 pkg-message
> grep WITH_DEBUG *
>
```
No more Makefile,v
WITH_DEBUG should work now?

Following methods:
http://developer.mozilla.org/en/Building_Firefox_with_Debug_Symbols
are already included in WITH_DEBUG? Because grep still returns empty files when looking for WITH_DEBUG inside Makefile.


----------



## SirDice (Nov 5, 2010)

The mozilla link is for adding debug symbols to Firefox *4*.


----------



## wblock@ (Nov 5, 2010)

kenorb said:
			
		

> ```
> *default host=cvsup.uk.FreeBSD.org
> *default base=/var/db
> *default prefix=/usr
> ...



It's an incomplete copy of /usr/share/examples/cvsup/ports-supfile, missing all the comments and the last two working lines.


----------



## luna (Nov 8, 2010)

Note, you don't have to install firefox to debug it.

```
$ make WITH_DEBUG= || make DEBUG_FLAGS=-g # the latter still defines -DNDEBUG
$ cd $(make -V WRKSRC)/dist/bin
$ LD_LIBRARY_PATH=$PWD gdb ./firefox-bin
```


----------



## kenorb (Nov 8, 2010)

wblock said:
			
		

> It's an incomplete copy of /usr/share/examples/cvsup/ports-supfile...



I just pasted the main part, the rest is fine.


----------



## kenorb (Nov 8, 2010)

luna said:
			
		

> Note, you don't have to install firefox to debug it.
> 
> ```
> $ make WITH_DEBUG= || make DEBUG_FLAGS=-g # the latter still defines -DNDEBUG
> ...



Sure, but the problem is that Firefox is not compiled with debug symbols at all.

BTW.

```
> cd $(make -V WRKSRC ) /dist/bin
Illegal variable name.
> LD_LIBRARY_PATH=$PWD gdb ./firefox-bin
LD_LIBRARY_PATH=/usr/ports/www/firefox: Command not found.
```
Probably it's for bash? I'm using tcsh.
Version for tcsh:

```
cd /usr/ports/www/firefox
cd `make -V WRKSRC`/browser/app
setenv LD_LIBRARY_PATH $PWD && gdb ./firefox-bin
```


----------



## kenorb (Nov 8, 2010)

Strict to the topic, if Makefile doesn't contain special WITH_DEBUG variable, it's a ports bug?


----------



## kenorb (Nov 8, 2010)

SirDice said:
			
		

> The mozilla link is for adding debug symbols to Firefox *4*.



No, second paragraph has header:
*Building older versions of Firefox with debug symbols*


----------



## kenorb (Nov 8, 2010)

With lack of responses, so here is the solution:

1.9.x branch

```
setenv MOZ_DEBUG_SYMBOLS 1 || export MOZ_DEBUG_SYMBOLS=1
setenv CFLAGS "-g -gfull" || export CFLAGS="-g -gfull"
setenv CXXFLAGS "-g -gfull" || export CXXFLAGS="-g -gfull"
cd /usr/ports/www/firefox && make
cd `make -V WRKSRC`/browser/app
setenv LD_LIBRARY_PATH $PWD || export LD_LIBRARY_PATH=$PWD
gdb ./firefox-bin
```

Newer than 1.9.x branch

```
setenv MOZ_DEBUG_SYMBOLS 1 || export MOZ_DEBUG_SYMBOLS=1
setenv CFLAGS "-gdwarf-2" || export CFLAGS="-gdwarf-2"
setenv CXXFLAGS "-gdwarf-2" || export CXXFLAGS="-gdwarf-2"
cd /usr/ports/www/firefox && make
cd `make -V WRKSRC`/browser/app
setenv LD_LIBRARY_PATH $PWD || export LD_LIBRARY_PATH=$PWD
gdb ./firefox-bin
```

*My question is:*
Why does it have to be so complicated?
Why WITH_DEBUG simply doesn't work (proof in #14)?

Anyway, reported the bug here:
http://www.freebsd.org/cgi/query-pr.cgi?pr=152043

My solution could be to add in Makefile:
1.9.x branch:

```
.if defined(WITH_DEBUG)
WITH_LOGGING= yes
CONFIGURE_ENV+= WITH_DEBUG=yes
CONFIGURE_ENV+= MOZ_DEBUG_SYMBOLS=1
CONFIGURE_ENV+= CFLAGS "-g -gfull"
CONFIGURE_ENV+= CXXFLAGS "-g -gfull"
.endif # defined(WITH_DEBUG)
```

Newer versions:

```
.if defined(WITH_DEBUG)
WITH_LOGGING= yes
CONFIGURE_ENV+= WITH_DEBUG=yes
CONFIGURE_ENV+= MOZ_DEBUG_SYMBOLS=1
CONFIGURE_ENV+= CFLAGS="-gdwarf-2"
CONFIGURE_ENV+= CXXFLAGS="-gdwarf-2"
.endif # defined(WITH_DEBUG)
```
But I haven't tested it.

Anyway after compiling with debug symbols, I've got another problem:

```
> ./firefox-bin
Error: Platform version '' is not compatible with
minVersion >= @GRE_MILESTONE@
maxVersion <= @GRE_MILESTONE@
```


----------



## luna (Nov 8, 2010)

kenorb said:
			
		

> Sure, but the problem is that Firefox is not compiled with debug symbols at all.


It is. See WITH_DEBUG ifdef in Mk/bsd.port.mk and in Mk/bsd.gecko.mk. DEBUG_FLAGS is also used in /usr/share/mk/bsd.own.mk to leave STRIP undefined/empty.





			
				kenorb said:
			
		

> Anyway after compiling with debug symbols, I've got another problem:
> 
> ```
> > ./firefox-bin
> ...


Try to *cd* to WRKSRC/dist/bin before running ./firefox-bin.


----------



## kenorb (Nov 8, 2010)

luna said:
			
		

> It is. See WITH_DEBUG ifdef in Mk/bsd.port.mk and in Mk/bsd.gecko.mk. DEBUG_FLAGS is also used in /usr/share/mk/bsd.own.mk to leave STRIP undefined/empty.



Yes, that's true.
There is a bug, new patch available here (against Mk/bsd.gecko.mk):
http://www.freebsd.org/cgi/query-pr.cgi?prp=152043-1-txt&n=/a.diff
http://www.freebsd.org/cgi/query-pr.cgi?pr=152043

Thank you for your help.


----------



## DutchDaemon (Nov 17, 2010)

This topic has been closed. Issues as technical or detailed as this should not be discussed in general user-oriented forums like The FreeBSD Forums. These forums are intended for end-user support with installing and/or running FreeBSD and/or applications from the ports tree, not for routinely resolving low-level problems with the operating system or add-on applications. Developers and port maintainers usually do not spend much time here, and we routinely refer technically detailed questions to them.

Consider opening this topic elsewhere, e.g.:

In the case of *the FreeBSD base system*:

1) by posting to one of the relevant mailing lists
2) by opening a bug report

In the case of *ported applications*:

1) by contacting the port maintainer (run make maintainer in the port directory)
2) by opening a bug report


----------

