コード例 #1
0
def _cmdline(obj: drgn.Object) -> str:
    try:
        s = " ".join(map(lambda s: s.decode("utf-8"), cmdline(obj)))

        #
        # The command line for a given thread can be obnoxiously long,
        # so (by default) we limit it to 50 characters here. This helps
        # preserve the readability of the command's output, but comes at
        # the cost of not always showing the full command line of a
        # thread.
        #
        return shorten(s, width=50)
    except drgn.FaultError:
        #
        # The command line information is contained in the user address
        # space of each thread, rather than in the kernel's address
        # space. Thus, often, it may not be possible to retreive the
        # thread's command line; e.g. when reading from a core dump.
        #
        return ""
コード例 #2
0
ファイル: test_mm.py プロジェクト: pzakha/drgn
 def test_cmdline(self):
     with open("/proc/self/cmdline", "rb") as f:
         proc_cmdline = f.read().split(b"\0")[:-1]
     task = find_task(self.prog, os.getpid())
     self.assertEqual(cmdline(task), proc_cmdline)