Dynamics of a cavitation bubble near a solid surface and the induced damage