Here again is a subject that, slowly but surely, will be added to the fossil record. Indeed, such a record would not be complete without knowing what each of those dinosaurs did eat, while they were alive during prehistoric times. The fossil record, as it is, indicates that there were a whole lot of yummy things that were either growing or crawling or walking or swimming around in the prehistoric environment that existed millions of years ago.
There is a natural order of living things within any particular region or such an environment. Living things have to consume some form of nourishment in order to remain healthy and alive. In that regard, dinosaurs are no different than any other life form. So, you better believe that all kinds of creatures, in total, were part of the food chain. Yes, it is truly a dog eat dog environment, so to speak, no matter what time or what place that a food chain prevailed. Yes, and what will you be eating for dinner tonight or maybe for breakfast the following day?
Naturalists and paleontologists agree that a predator and foe relationship exists now and as it did those millions of years ago. They also agree that the meat eaters were at the top of the food chain, while the less violent creatures were content by eating the available plant life that the environment provided. Yes, and that is how that all living creatures survive, for as long as they are healthy and alive. It was also discovered that some dinosaurs ate meat and vegetation. Those creatures did happen to have both kinds of teeth for eating both kinds of food.
As such, in is a simple matter for a paleontologist to determine what a particular type of dinosaur ate during its lifetime. Its teeth truly reveal what that creature did or did not eat. Sharp and/or pointed teeth indicate that the animal in question ate the meat of some other animal. Relatively flat teeth that are used for grinding the food that it ate does reveal the fact that the animal probably ate some kinds of plant life.
There is another way to determine what a particular creature consumed. Fossilized excrement of the animal in question most certainly provides evidence of what the creature ate, and that evidence might even be within the fossilized remains of some of those long dead prehistoric creatures.
So now you know how it is possible to determine what some kinds of dinosaurs did eat when they either walked upon or swam in the seas during prehistoric times within an environment and a particular food chain that vanished many millions of years ago.