I would not suggest a semi-auto for a trail gun.
If for some reason, you lose the magazine, you have a single shot. If that pistol has a magazine disconnect, you have a club.
A revolver is by far the better choice.
I'd suggest a double-action (easier to load, especially with HK speedloaders), adjustable sights and 4-inch barrel. Carry it in a shoulder holster with a thumb break, not a spring clamp, for greater security.
However, if you're carrying a small pack you'll have to carry it on your hip to avoid the pack straps. Or you can wear a small fanny pack on the front but this often gets aggravating as it wants to pull your pants down when used with a pack. Suspenders may help.
A revolver with function with all kinds of ammo: .22 BB, .22 CB, Shorts, Long, Long Rifles, Long Rifles with heavyweight bullets (Aguila makes `em) and so on.
Semi-auto .22 rimfires can be persnickety in their functioning. Know why John Browning invented the .25 Auto cartridge? Because he recognized that the .22 Rimfire with its comparatively large rim caused feeding problems. So, he created the .25 Auto and made it semi-rimless for better feeding. He wanted a round that would be very reliable, especially important in a last-ditch defensive gun.
Also, a revolver will tell you at a glance if it's loaded. With a semi-auto, you have to remove the magazine and pull back the slide to check.
Whichever type or brand you get, you should know that of all the cartridges out there, the .22 Rimfire is probably the most persnickety when it comes to preferences.
A brand that shoots well in one gun may be woefully inaccurate in another.
I have a Charter Arms Pathfinder .22 with 3 inch barrel and adjustable sights that proves this time and again. With CCI ammo groups are lousy. It improves a bit with Winchester. It clearly prefers Remington or Federal ammo.
After buying your .22 (rifle or pistol, by the way) you should buy a box of every kind of ammo you can find. Then fire at least 10 rounds at a REAL paper target (not a tin can or knot in a piece of scrap wood) from a benchrest at a measured distance.
I sight in my .22 pistols for 25 yards, my rifles at 50 yards, and always from a benchrest. When I find the best load, I stick to that.