2 Samuel 16:5 As King David approached Bahurim, a man from the same clan as Saul’s family came out from there. His name was Shimei son of Gera, and he cursed as he came out. 6 He pelted David and all the king’s officials with stones, though all the troops and the special guard were on David’s right and left. 7 As he cursed, Shimei said, “Get out, get out, you murderer, you scoundrel! 8 The Lord has repaid you for all the blood you shed in the household of Saul, in whose place you have reigned. The Lord has given the kingdom into the hands of your son Absalom. You have come to ruin because you are a murderer!”

9 Then Abishai son of Zeruiah said to the king, “Why should this dead dog curse my lord the king? Let me go over and cut off his head.”

10 But the king said, “What does this have to do with you, you sons of Zeruiah? If he is cursing because the Lord said to him, ‘Curse David,’ who can ask, ‘Why do you do this?’”

11 David then said to Abishai and all his officials, “My son, my own flesh and blood, is trying to kill me. How much more, then, this Benjamite! Leave him alone; let him curse, for the Lord has told him to. 12 It may be that the Lord will look upon my misery and restore to me his covenant blessing instead of his curse today.”

13 So David and his men continued along the road while Shimei was going along the hillside opposite him, cursing as he went and throwing stones at him and showering him with dirt. 14 The king and all the people with him arrived at their destination exhausted. And there he refreshed himself.

This reminds me of "casting the first stone". I can easily imagine this guy running along the hillside throwing rocks and cussing. If that were to happen today... he'd be locked up. It looks like Abishai wanted to lock him up... but David told him to hold off. So David knew it just more of the calamity he brought on himself.

This is from Bibletrack.org.

Then there's this guy, Shimei; his mention in the scripture comes because he's a relative of Saul who obviously feels strongly that David is an illegitimate King of Israel. Shimei walks alongside David as he is fleeing Jerusalem throwing rocks at David and cursing him, and he does so for quite a distance. He's very cruel and daring when he says to David, "Come out, come out, thou bloody man, and thou man of Belial." Incidentally, while the KJV frequently transliterates the Hebrew word "belial" as a proper name, in fact it is a general Hebrew word meaning worthless or wicked. Seeing it capitalized, one might get the impression that it was the name of a pagan god, but not so. Shimei is a gutsy guy; David's nephew, Abishai, offers to take him out, but David forbids it and allows the man to go on mocking and cursing him - even suggests in verse 10 that Shimei is prompted by Jehovah himself to cry out these insults. David concludes that God will sort it all out. Later on, Shimei would come back to David and apologize, and David would forgive him (II Samuel 19, see notes). That's not really the end of it, though; his end would be unpleasant under the reign of David's son and successor, Solomon (I Kings 2:46,).

This is from Bible.org.

As I read this account, I am amazed at how stupid this man appears. Here is but one man, verbally attacking David and physically abusing him (although I would suspect that David's bodyguards did not let Shimei get close enough to David to do him any physical harm). Does this man not know that any one of David's bodyguards could cut off his head in a moment, should David give permission to do so? I think I have seen similar actions in the news when protesters, armed only with sticks and rocks, have challenged those they consider their enemies, in riot gear, and armed with tanks and automatic weapons. In spite of the power of their adversary, they will not be silenced or stopped, if not by death.

If there is something light in this story, it's the laughable ignorance. This cursing critic is apparently accusing David of Saul's death. That's not true. David could have killed Saul a couple times and didn't. Remember, David could have killed him in the cave while he was going to the bathroom or in the field while he was surrounded by thousands of well armed and trained soldiers. David didn't take advantage of those opportunities because David believes that Saul was God's anointed king. So in today's dialect.... the cursing critic was spreading fake news and attempting to assault the king and his soldiers but David let him proceed without consequence.

Do you see the irony here.... first David had Uriah, Bathsheba's husband, killed to keep him quiet and now there's this guy screaming about David at the top of his lungs... from a distance, so everyone can hear, creating a big scene so everyone will notice. Do you see the irony here?