Can I tell what part of a program is in swap?

Is there a way to tell what part of a program is swapped out? for example, mysqld presently has about 300 mb swapped out, Xorg has 450 mb swapped out, and so on, and I’m curious to know what actually was put into swap.

There are one-liners you can find since this information is exposed under /proc

One program that reports this data is smem, install with zypper and run:

$ sudo zypper in smem
$ smem

Well, that is a nice program but what i want to know is what parts of mysqld get swapped out. e.g how much code seg how much data seg etc.

Code and data are never swapped, only anonymous memory.

I guess it is not quite correct. To allow writing to static data it has to be copied into memory allocated when program is loaded and this memory also becomes anonymous. So static data may be swapped.

What else can be swapped? Can you give me a primer on this? I really have no idea what can or cant be swapped, except active code and data (I guess)

Memory allocate by malloc() as example. You can see how much of each virtual memory segment is currently in swap in /proc/$PID/smaps.