First, if you remember dreams, if us a sign that you hadn't had a sound sleep..
Learn and practice to have a sound sleep.
You don't require medicines for this
You only have to develop some good habits and discipline.
Next Steps
Consult a psychologist for a better clarity and understanding.