Find an advisor that you feel you can work with and that has a good perspective of a field you are interested in. A faculty member knowledgeable in their field should be able to provide you with a few topics that are appropriate for a Ph.D. Also, start doing research early since it may take you a while to find the niche in which to do your research. It can be easier to make a thesis out of a bunch of papers you've had published. Start reading the literature in an area you are interested in. A good way to start is through literature searches.
Survey articles can give a good glimpse of a field with less investment in time.
You should read many articles. Sometimes ideas from other areas can be applied in a new way to your topic. Anticipate what will be hot in the future. New solutions to hot problems are good. Delving in open areas of research can be good.