Usually it's somewhere in between. I probably average around 5-6 hours of productive coding per day on any given project, not counting break times, but with very wide variance.
Also, although different projects aren't completely independent, I do find that after taking a significant break (read: probably multiple hours) I can work productively on something else for a while. For example, if I've got some main feature I'm developing but also need to investigate and fix some bugs, I might spend a few hours on the main work, but I might still be quite comfortable tracking down and fixing a few bugs later in the day. So quite often, I will actually split my working time into 2 or even 3 main sessions during a day, doing other things in between, though I have the advantage here of not being someone else's employee with standard office hours.
Not sure if it's like that for anyone else, though. Right now, I'm writing on HN because I'm taking a bit of a break after solving a production issue that was baffling me for the last hour.
This aspect (required rest schedule) was not very well researched. The only data I've got was collected by the IT and engineering companies, and they could only measure working-day-long spans.
And of course there's meetings, lunch, etc breaking up the day as well.
2 hours of debugging a tricky issue, while having your tools fail you multiple times in the process, can drain me out for the remainder of the day. On the other hand, doing an interesting research/notes-taking or other non-infuriating work, and I might spend 6 hours without even feeling too tired.
On average, 4-5 hours of _actual_ programming (thinking, writing, refactoring, testing, documenting) is all I can squeeze out for a day.
Is this normal or am I not pushing myself enough? I'm not sure.