Movies like the Jurassic Park series often fail to understand the psychology of dinosaurs, as well as that of even modern animals.
Solitary predators, no matter how powerful, are cowardly by necessity: if they were to receive an injury, they might starve to death before they could recover. When threatened by potential prey that is mounting a potentially effective defense, prudence leads them to seek their meal elsewhere. Consider present-day tigers: they are known to attack humans, but prefer to do so from behind. Wearing a face mask on the back of the head confuses them sufficiently that they don't attack. Which way is that human facing? I'd better not risk it...
On the other hand, predators that operate in cooperative groups can afford to be injured on occasion, as their pack mates can look after them until they can recover. Dangerous prey is no longer automatically avoided unless weaker prey is at hand.
Herbivores can in some ways have more aggressive psychologies than predatory species, particularly if they are herd animals. Herbivores with defensive weaponry are at an advantage if they confidently attack solitary predators, even if it is a bluff, since solitary predators cannot afford to be injured, and both parties know it.
It is a different matter when herbivores are attacked by a pack of predators. The herbivores can no longer defend themselves individually, and so defense becomes a herd task. If an individual is injured, both predator and herbivores know that the injured individual is likely to be singled out as prey.
So, the response of dinosaurs, as well as modern animals, to firearms depends upon a number of factors.
A solitary predator may well run from a gunshot even if not hit the first time it hears one... it might be dangerous. After hearing several shots without being hit or observing another animal being hit, it may conclude that the noise is a bluff. However, if hit, it is likely to flee even if the hit is not crippling or fatal, as it can't afford to take the chance that the next hit won't be worse.
A pack predator can afford to take chances, and is less likely to run from the sound of a shot, or even a poorly-placed hit if the shooter looks like a good meal. They won't likely break off an attack unless the shots coincide with pack members being crippled or killed outright more often than not.
Herbivores - especially if bigger - are likely to attack if they feel threatened or crowded by a single or small group of unfamiliar animal(s) such as humans with guns. They may ignore poorly placed hits in order to eliminate the threat, equating the human with a predator.
This means that a human with a handgun should be able to successfully defend themselves against even a large solitary predatory dinosaur. If Tyrannosaurs are solitary, the mere sound of a gunshot should give one pause, and any hit should drive it off. Being hit by a handgun shot would hurt a lot, even if not particularly effectively placed, and prudence would likely cause the dinosaur to retreat. However, even a handgun shot would penetrate most predatory dinosaurs' hide, and might break a rib or cause a fatal thoracic injury. A long-arm shot would be even more effective.
Pack predator dinosaur species would be more dangerous. A poor hit against one member of the pack probably wouldn't discourage the others, and the human may easily find themselves attacked from multiple directions. It would likely take multiple immediately effective shots to convince the uninjured pack members that this prey is too dangerous to tackle. However, pack hunters tend to be smaller, and would likely be almost as susceptible to handgun shots as humans.
Large herbivores might be more troublesome. Their larger bones mean that lighter, slower pistol rounds could be ineffective, and would merely goad them into pressing their attack. A long-barreled firearm would be advisable to be effective. In particular, armoured dinosaurs such as Ankylosaurus might require a .50" round to penetrate their armour, but most others would be susceptible to regular rifle fire.
Of course, even predatory dinosaurs may change their behavior if they are defending their offspring. In such a case, they may become less cautious in order to eliminate the threat.
Knowledge of firearms by observation can change the behavior of even pack hunters. In Africa, where humans hunt lions, the sight of a solitary human can send an entire pride into a slinking retreat.
Just because dinosaurs had smaller brains doesn't mean that they wouldn't be able to learn from experience. Even for a large, solitary predator, once shot, they would become very wary of future encounters with humans. Pack hunting dinosaurs, being social, would be smarter and even quicker to understand that humans mean trouble if they saw humans shooting other dinosaurs.
Then we need to consider the scale of the meal that a human would provide. To a Tyrannosaur, a human would be a single bite... hardly worth the effort it might take to run it down, unless it was really hungry and the human was really close. Even a Utahraptor pack would get a meager meal from a human... though one human might satisfy a single Utahraptor. Deinonychus packs would probably be tempted by a human, since one would make a half-decent meal for the pack... but if the human pulled out a pistol and started blowing the pack members away, the survivors would soon think better of it. A pack of turkey-sized Velociraptors would get a good meal out of a human, but again, a human with a gun could easily make them find easier prey, even if the pack would have a good chance against an unarmed human.
Huge predatory dinosaurs wading through gunfire - even pistol fire - to eat the humans? I think not!