[Gentoo] Enhancing a bash backtrace

Last night, ferringb mentioned to me that he wanted to pull a bash backtrace function from eselect into portage. So I took a look at it, and it seemed like a great idea. But it was missing one thing that could be really helpful: It didn’t show the arguments to functions.

Here’s a sample of the original output:

You’ll notice that not only does it lack arguments, but it says bleb() is in the wrong file, and it tries to attribute the original failure to main(). This doesn’t make a lot of sense, so we change both the sourcefile array, $(basename ${BASH_SOURCE[${n}]}), and the function name array, funcname=${FUNCNAME[${n} – 1]}, by 1. Here’s the enhanced output:

Here’s the chunk that does most of the heavy lifting:

This code is part of a loop printing the most recent function first. We initialize p to 0 at the beginning of looping through the call stack, then increment it by the size of the argc to that function on each pass through the loop: ${BASH_ARGC[$n – 1]. This is necessary because bash only has one-dimensional arrays. Thus, BASH_ARGC[] contains the argc values for every function in the call stack, but BASH_ARGV[] contains a concatenated list of every single argument without clear separators between functions.

If we wanted the most recent function last, we’d have to change things around a little:

In particular, note how j starts at 0 instead of the last argc, and how newarg is set in a very different way. We need to treat p differently when going in reverse order (it’s initialized to ${#BASH_ARGV[@]}, the size of the argv array), which necessitates the changed treatment of the rest.

We enclose the whole loop in a test for the existence of BASH_ARGV for backwards compatibility with bash-2: BASH_ARGV and BASH_ARGC weren’t incorporated into bash until 3.0. Another caveat is that neither of the arrays are set without the extdebug setting near the top of your code:

Thanks to ferringb for way too much discussion about how the output format should look and for making us put the effort into figuring out how to switch the ordering around for compatible output with Python tracebacks from portage.

For completeness, here’s the beginning of the loop in both cases, respectively:

The complete code is available for both versions.

Blog priorities

I use Liferea for blog reading. It’s a nice app, but it has some trouble detecting when I get the same post from multiple feeds. Really, Liferea, I don’t need to read it more than once; just mark it read and let me get on with it.

Anyway, I started using Liferea because it lets me create categories for my priorities of different feeds. I’ve got 3 priority levels of personal blogs, plus another one for newspapers and magazines. I rarely get to the third level, and never the newpapers/mags level. Every once in a while, I browse the third level, and if I find anything good, I exchange it for something in level 2 that I haven’t been getting much out of.

This week, I’ve moved Stephe Walli back up to #2, and Ted Leung dropped to #3. Ted has interesting things to say, but not really on topics I care about right now. Bye, Ted, see you in a couple months. Keep up the good work on Chandler.

A quick summary of my categories, for anyone who wants to see what I see:

Priority 1
Jay Cotton, Kazem Ardekanian, Pat Mochel, LWN.net, Gentoo Universe, Gentoo X team commits, Corvallis free Wi-Fi, Planet Freedesktop.org, and a Google search for Gentoo.

Priority 2
r0ml, Stephen O’Grady, a Google search for links to my blog, Paul Graham, Stephe Walli, Passionate Users, O’Reilly Radar, Planets: KDE, GNOME, OSLUG, another private one.

Priority 3
Bram Cohen, Ted Leung, Jon Udell, Joel on Software, Don Marti, Doc Searls, Planets: Ubuntu, Fedora, Debian, Novell/SuSE, Kernel, Cheap Stingy Bastard, Woot.

[Gentoo] Getting everything ported to modular X

I spent a significant chunk of time today on scripts to track down all the packages that still aren’t ported to modular X and identify their maintainers. Read more from the gentoo-dev list.

Over the next week, I plan to track the total number of unported packages in hopes of seeing a gradual decline. Once that decline gets low enough, I’ll unmask modular X so the testing (~arch) folks can get at it more easily. It’ll still require the migration guide, though.

If you want to join the effort to get the tree ported to modular X, take a look at my latest list of unported packages on the gentoo-dev thread linked earlier, read the porting guide and jump in!

Unported packages as of Jan 16, 2006 17:45:56 PST: 1058
Unported packages as of Jan 18, 2006 01:18:30 PST: 1037
Unported packages as of Jan 19, 2006 00:18:21 PST: 1012
Unported packages as of Jan 20, 2006 00:04:03 PST: 1003
Unported packages as of Jan 21, 2006 13:27:22 PST: 917
Unported packages as of Jan 22, 2006 22:05:42 PST: 871
Unported packages as of Jan 23, 2006 23:07:22 PST: 867
Unported packages as of Jan 24, 2006 23:02:28 PST: 783
Unported packages as of Jan 24, 2006 23:02:28 PST: 513 “true”
Unported packages as of Jan 25, 2006 21:32:30 PST: 498
Unported packages as of Jan 28, 2006 13:34:04 PST: 465
Unported packages as of Jan 29, 2006 23:23:02 PST: 401
Unported packages as of Jan 30, 2006 23:37:30 PST: 406
Unported packages as of Feb 02, 2006 12:33:49 PST: 343
Unported packages as of Feb 03, 2006 20:43:54 PST: 329
Unported packages as of Feb 12, 2006 11:18:44 PST: 260

What should I have majored in?

Too bad I didn’t come across this survey a few years ago … As it turns out, I majored in biochemistry and chemistry with a minor in journalism.

You scored as Engineering. You should be an Engineering major!

Mathematics

92%

Chemistry

92%

Engineering

92%

Linguistics

83%

Psychology

75%

Philosophy

75%

Biology

67%

English

58%

Sociology

42%

Theater

42%

Anthropology

42%

Journalism

33%

Art

25%

Dance

25%

What is your Perfect Major? (PLEASE RATE ME!!<3)
created with QuizFarm.com

Weird X-related backtrace

I just ported this app to gtk-2, and now I get a segfault when I close it while a file’s open. Check out this weird backtrace. Any ideas on how to resolve this are welcome.

(gdb) bt
#0 0x089921bb in ?? ()
#1 0xb6c0ebcd in XQueryExtension (dpy=0x8990df0, name=0xb72adb5d "GLX",
major_opcode=0x898d6d0, first_event=0x898d6d0, first_error=0x898d6d0)
at QuExt.c:46
#2 0xb6c01f2b in XInitExtension (dpy=0x8990df0, name=0xb72adb5d "GLX")
at InitExt.c:49
#3 0xb71c46d1 in XextAddDisplay (extinfo=0x82e7508, dpy=0x8990df0,
ext_name=0x898d6d0 " !\231\bI", hooks=0xb72b23a0, nevents=17,
data=0x898d6d0 " !\231\bI") at extutil.c:108
#4 0xb727bdb8 in __glXFindDisplay (dpy=0x8990df0) at glxext.c:329
#5 0xb727c535 in __glXInitialize (dpy=0x8990df0) at glxext.c:1104
#6 0xb727d73d in __glXSetupForCommand (dpy=0x8990df0) at glxext.c:1246
#7 0xb72787c6 in DestroyContext (dpy=0x8990df0, gc=0x82f4890) at glxcmds.c:458
#8 0xb7343dcc in gdk_gl_context_unref (context=0x82f4480) at gdkgl.c:192
#9 0xb734478c in gtk_gl_area_destroy (object=0x8762598) at gtkglarea.c:174
#10 0xb6aece1f in g_cclosure_marshal_VOID__VOID (closure=0x82a8700,
return_value=0x0, n_param_values=1, param_values=0x8990df0,
invocation_hint=0xbfa00ca8, marshal_data=0xb7344730) at gmarshal.c:77

[Gentoo] My day job

Since I just finished up an ebuild for the next-generation application of what I do all day, I thought you might like to see what it looks like. What you’re seeing is a zoomed-in picture of part of a protein. The electron density is in blue, and green and red indicate where there’s too little or too much actual atom present for the density. The big cross things are waters.

The atom bonds in the pic look a little jagged because I haven’t gotten its antialiasing working yet (works fine on OS X, FWIW).

Keep in mind this is pretty much state of the art in my field — it’s using gtk-1 and glut rather than tcltk, or home-rolled widgets.

(Click for bigger version)
coot -- an X-ray crystallography modeler

The program is called coot. Unfortunately, it won’t enter the tree until I fix rpath issues with ccp4, a huge bundle of apps that this depends on.

[Gentoo] Do we have a vision?

Lance today brought up the lack of a global vision for Gentoo. He suggests that the council come up with one; another promoted idea would re-create a “visionary” position similar to what Daniel Robbins used to do. Both ideas sound alright, but the question is: Does Gentoo need a created, artificial vision? Or is it more of a living organism that just flows in directions based on what its parts do?

I’m of the latter opinion, as you may guess. Accordingly, I think Gentoo doesn’t need to create a vision but already has one. We just don’t realize what it is, because we haven’t put the pieces of the puzzle together. We need to construct a collection of microscopic goals and ideas, then let them coalesce through discussion into a global Gentoo vision.

Over the past couple of days, I’ve been reading a speech by Richard Hamming of Bell Labs called “You and Your Research.” Hamming tells his audience how to do truly great work; Nobel-quality work. The answer sounds simple: Only work on important problems, and don’t let the small stuff distract you.

Hamming said this about how the size of your vision relates to how high you need to advance in the project:

I went to my boss, Bode, one day and said, “Why did you ever become department head? Why didn’t you just be a good scientist?” He said, “Hamming, I had a vision of what mathematics should be in Bell Laboratories. And I saw if that vision was going to be realized, I had to make it happen; I had to be department head.”

When your vision of what you want to do is what you can do single-handedly, then you should pursue it. The day your vision, what you think needs to be done, is bigger than what you can do single-handedly, then you have to move toward management. And the bigger the vision is, the farther in management you have to go. If you have a vision of what the whole laboratory should be, or the whole Bell System, you have to get there to make it happen.

The same idea applies to Gentoo. Perhaps people with a global vision should get together and talk about their ideas for a Gentoo direction. Who’s got one?

[Gentoo] Ripping MP3’s with Sound-Juicer

Came across a couple of posts on Google about how to do this, so I can actually get songs onto my iPod. It seems like it’s purposely made impossible to figure out by yourself.

1. Make sure you’ve got gst-plugins-lame installed.
2. Read this and set up a new sound profile. Make sure you check the “Active” box.

Alternately, some random J5 guy recently posted about MP3 for free from Fluendo.