Posts tagged ‘GNU’

I’ve been working on enum again recently and got completely stuck in getopt_long() return values. I don’t want to bore you with details, so let me cut to the chase: I needed a way to look into what getopt_long() is actually doing.

Now, there are a few ways to figure out the doings of a function. If it’s your own code, you could just go ahead and add a few printf()s to see if your variables fill up as intended. Then you could use gdb to walk through your running code. But what if you want to do so in functions outside the scope of your own code? In my case: getopt, i.e. libc?

Obviously, you can download the library, add your printf() stuff, compile and install it, and see it all happening. But libc isn’t exactly small, fast-compiling, and you really don’t want to mess it up and have it installed on your system. So how about just taking what you actually care for and push it in? This is nothing experimental or particularly “hacky”. I just don’t want to forget about it and maybe someone can make use of it. So here we go…

Download your libc sources to a new directory and copy the files you need. Try something like

mkdir -p /tmp/getopt/mygetopt
cd /tmp/getopt
apt-get source eglibc
cp eglibc-*/posix/getopt* mygetopt/
cd mygetopt

Now write up a primitive Makefile:

all: libmygetopt.so

libmygetopt.so: getopt.c getopt1.c getopt_int.h getopt.h
	gcc -shared -Wl,-soname,libmygetopt.so.1 -fPIC -o libmygetopt.so.1.0.0 getopt1.c getopt.c
	ln -s libmygetopt.so.1.0.0 libmygetopt.so.1
	ln -s libmygetopt.so.1 libmygetopt.so

clean:
	$(RM) libmygetopt*

In order for this to actually work, I fiddled around with a few #ifdef’s in getopt.c. But that’s something you’ll probably find out yourselves. You should at least be able to compile it (‘make’ it). Now put a printf statement somewhere in the function you want to inspect. Recompile the lib and then go back to your actual program.

Running the program ist easy.

src/enum -p1 1 3
1.0
2.0
3.0

Surprisingly, running it using your own getopt version is just as easy. Just push your library in:

LD_PRELOAD=libmygetopt.so LD_LIBRARY_PATH=/tmp/getopt/mygetopt:$LD_LIBRARY_PATH src/enum -p1 1 3
Yo, Ulrich, my getopt version is waaaay cooler than yours!
Yo, Ulrich, my getopt version is waaaay cooler than yours!
1.0
2.0
3.0

If you’re disappointed now, that’s your own fault. I said it in the beginning, this is nothing special. It’s not my idea. It’s something that developers all use all the time … or something like that. In case you didn’t know about it, good for you. Otherwise, sorry for reading my memory dump.

It’s the time of the year again. LinuxTag is right up and, of course, Debian is part of it. But, it wouldn’t be us if we didn’t have any problems at all. Well, the situation isn’t real bad™ but could deserve some improvement. Improvement about what, you ask? Isn’t that obvious? It’s man power that we need (women shall feel included :)).

Now, LinuxTag 2011 is going to happen, with or without you, on May 11th to 14th. Needless to say that you’ll be missing quite a lot if you don’t attend. I mean, even Zack will be there. And so will I (most probably at least). And even more… Who’s willing to miss that, really? So, pack your stuff, get a train ticket or your car or your friend’s car or the car of a friend of your friend who knows a friend who doesn’t know you but still wants to give you his car which you don’t even need since you already have the car of that friend of your friend and now you have two cars and can even bring another bunch of fellas who probably own cars themselves and now you’re thinking about the environment because of all the cars that will come to Berlin and because of that you suddenly buy a train ticket and leave all three cars at home… and in the end only one thing counts: you’ll be there. Oh, and before you drive off to your local train station, please put your name into our neat little list so we can count on you as booth staff — that’s because we need man power in case you missed that section or somehow forgot it while thinking about that guy who is the friend of your friend that owns a car but rather comes by train as it saves the environment.

Dear lazyweb,

I’m using Gnome for quite some time now and I’m always satisfied with the interfaces I have to whatever I need. There is one thing, though, that I miss: a calendar. I don’t like evolution, I don’t need another mail client. What I want is a simple, yet sophisticated application that I can put appointments in and which reminds me of them (recurring issues should be possible, too). It may but doesn’t have to be somehow attached to the Gnome clock or whatever. Though I expect it to look “Gnome-like” and be accessible from the panel. Do you know such? And is there even a Debian package for it?

Thanks.

Since thousands of people seem to like RSA keys these days and my key is “old” anyways, I thought: how about running where the other lemmings run… So, here it is, my transition to a new gpg key. A properly written transition document is to be found here, obviously signed by both the old and the new key. I’d appreciate signatures if your signing policy allows (and you’re not insanely signing anything that looks like it could be signed).

Been playing with that thought for a while now, finally got to rebuilding it for lenny, now I’m using it… tmux is the new screen. To have fun already I read a few short introductions and got myself a few suggestions for a proper .tmux.conf. So, for root I have this one now:

# Copy mode
unbind [
bind Escape copy-mode

# Use Vi mode
setw -g mode-keys vi

# Make mouse useful in copy mode
setw -g mode-mouse on

# More straight forward key bindings for splitting
unbind %
bind | split-window -h
bind h split-window -h
unbind '"'
bind - split-window -v
bind v split-window -v

# History
set -g history-limit 4000

# Terminal emulator window title
set -g set-titles on
set -g set-titles-string '#S:#I.#P #W'

# Status Bar
set -g status-bg black
set -g status-fg white
set -g status-interval 1
set -g status-left '#[fg=green]#H#[default]'
# no line break here, it's just to long for my blog layout!
set -g status-right '#[fg=yellow]#(cut -d " " -f 1-4 /proc/loadavg)#[default] #[fg=cyan,bold]%Y-%m-%d %H:%M:%S#[default]'

# Notifying if other windows has activities
setw -g monitor-activity on
set -g visual-activity on

# Highlighting the active window in status bar
setw -g window-status-current-bg red

# Clock
setw -g clock-mode-colour green
setw -g clock-mode-style 24

# Create a default session
new -n htop -d htop
setw -t htop monitor-activity off
neww -n aptitude -d aptitude
neww -d

Then I added a new alias to my user’s zsh config:

alias root='su -c "tmux attach"'

Why ‘tmux attach’? Because tmux would start a new session which I don’t want it to. The config already starts a session which we can immediately attach to. Also, when such session was started I can attach to it as a user with the very same command over and over again. That makes it pretty handy as I always have htop, aptitude and a free shell available in a nice tmux session. Great. How did I live until now? ;-)

When I first started using Free Software — yes, that’s quite some time ago — I found it the right thing to do. It felt like I was first time ever really controlling what my computer does. Took just a bit of time to notice I really never knew anything about it. Well, almost at least. Then when I started contributing to Free Software this obviously changed. One of the freedoms is to learn from the code you’re running. And I did it… by reading, contributing, doing nonsense with it, reimplementing it… you know the deal.

Starting to work on Debian was something that just evolved out of it. Doing so gave me the opportunity to give back. I never achieved that actually, though. At least I don’t consider my contributions even remotely sufficient to make up for the great deal of software that I use — sometimes without noticing it. Still there’s lots of stuff that I don’t have a clue of and I rely on other developers to do their (volunteer) job. Otherwise my knowledge wouldn’t help much. I could never continue kernel development if those kernel hackers all stepped back for instance. I guess, it’s getting more and more difficult the closer the piece of code is to hardware.

Another thought I had was about Free Software in general. It’s more than just the code (although it might be the most important part), it’s also a concept that needs to be communicated. Firefox on Windows shows how Free Software can have a big market share in an otherwise closed source environment. Yet I’m not sure all users know about it being open source and what that means (hear them talk about Freeware instead). And who is dealing with this conceptual stuff?

I decided to do something about all that. Now I don’t really have money but a bit I thought I could share. And I could set yet another sign by publicly talking about it, or casually mentioning that I consider Free Software and Linux a good thing. So you will see a mail signature now below all my mails. I always wondered what one might gain with such and now I found a reason to include one. It reads:

Debian Developer                                 www.debian.org
Member of the Linux Foundation                    www.linux.com
Fellow of the Free Software Foundation Europe      www.fsfe.org