Heat the butter in a large pan and gently cook the onion and thyme until the onion is softened but not browned - about 20 minutes. Increase the heat slightly and cook for 15 minutes, until the onion becomes dark golden, sticky and caramalised, stirring now and again to stop it catching. Add the sherry and simmer for 2-3 minutes, then add the stock and bring to the boil. Season and simmer for 10 minutes. Meanwhile, toast the bread, rub each slice with garlic, then drizzle with a little olive oil. Sprinkle with the cheese and grill until golden and bubbling. Serve the soup with the cheese croutons on top.