DbgShell icon indicating copy to clipboard operation
DbgShell copied to clipboard

Enhancement: dps but with recursive safe pointer following

Open Zhentar opened this issue 7 years ago • 2 comments

Regular dps:

> dps 26ee7c30
26ee7c30  2368c010
26ee7c34  13234900
26ee7c38  5f080100 d2d1!CSRGBToLinearTranslator::s_shaders+400f0
26ee7c3c  26db1aa8
26ee7c40  26ee74a8
26ee7c44  26e80020

Awesome recursive dps:

26ee7c30  2368c010  -> 50afffa8 jscript9!Js::JavascriptLibrary::`vftable'
26ee7c34  13234900  -> 50b35650 jscript9!Js::GlobalObject::`vftable'
26ee7c38  5f080100 d2d1!CSRGBToLinearTranslator::s_shaders+400f0
26ee7c3c  26db1aa8  -> 50afa570 jscript9!ScriptEngine::`vftable'
26ee7c40  26ee74a8  -> 21dd7da0  -> 50afffa8 jscript9!Js::JavascriptLibrary::`vftable'
26ee7c44  26e80020  -> 26a0cda0  -> 50afffa8 jscript9!Js::JavascriptLibrary::`vftable'

Ah! It is so much more clear what I am looking at now! And with colorization it's even better!

Zhentar avatar Oct 15 '18 20:10 Zhentar

Hey, that's a cool idea. Did you actually try implementing it, or is that just a mockup?

jazzdelightsme avatar Oct 16 '18 04:10 jazzdelightsme

I did indeed, although just as a quick hack that replaces the standard dps:

		private static ColorString _DefaultSymLookup(DbgEngDebugger debugger, ulong addr)
		{
			var tempCs = ColorString.Empty;
			int depth = 0;
			do
			{
				if (tempCs.Length > 0) { tempCs = tempCs + "-> " + DbgProvider.FormatAddress(addr, is32bit: true, useTick: true, numericNull: true) + " "; }
				if (debugger.TryGetNameByOffset(addr, out string symName, out ulong disp))
				{
					ColorString cs = tempCs + DbgProvider.ColorizeSymbol(symName);
					if (disp != 0)
						cs.AppendPushPopFg(ConsoleColor.Gray, "+" + disp.ToString("x"));

					return cs;
				}

				tempCs += " ";
				depth++;
			} while (addr > 4096 && depth < 5 && debugger.TryReadMemAs_pointer(addr, out addr));

			return tempCs;
		} // end _DefaultSymLookup()

Zhentar avatar Oct 16 '18 18:10 Zhentar