Fortunately, I have not been a witness at court yet, and these scenarios are theoretical, but if I were, say if I witnessed a murder, then...

1. How much would I be expected to reveal if not directly connected to the case? For example, if I was asked, "What were you doing in the alley at night?," would you be required to reveal the information if it is potentially humiliating (e.g. you were having an affair) or illegal (e.g. you were getting illegal drugs)? The latter case seems to violate the protection against self-incrimination. Or what happens if you just lie about something inconsequential?
2. Suppose you receive a death threat (either verbal or in writing) from the person charged with and who committed the crime. Something along the lines of: if you testify against me, then my friends will kill you after the trial. What legal options do you have?