Skip to content
Snippets Groups Projects
  1. May 20, 2024
  2. May 19, 2024
  3. May 15, 2024
  4. May 14, 2024
  5. May 11, 2024
  6. May 09, 2024
  7. May 08, 2024
    • Florian Rommel's avatar
      scripts/gdb: fix detection of current CPU in KGDB · 40eea5ab
      Florian Rommel authored
      Directly read the current CPU number from the kgdb_active variable.
      
      Before, the active CPU was obtained through the current task, which
      required searching the task list for the pid of GDB's selected thread. 
      Obtaining the pid was buggy: GDB may use selected_thread().ptid[1] (LWPID)
      instead of .ptid[2] (TID) to store the threads pid; see
      https://sourceware.org/gdb/current/onlinedocs/gdb.html/Threads-In-Python.html
      As a result, the detection could return the wrong CPU number, leading to
      incorrect results for $lx_per_cpu and $lx_current.
      
      As a side effect, the patch significantly speeds up $lx_per_cpu and
      $lx_current in KGDB by avoiding the task-list iteration.
      
      Link: https://lkml.kernel.org/r/20240425153501.749966-5-mail@florommel.de
      
      
      Signed-off-by: default avatarFlorian Rommel <mail@florommel.de>
      Cc: Andrew Jones <ajones@ventanamicro.com>
      Cc: Deepak Gupta <debug@rivosinc.com>
      Cc: Jan Kiszka <jan.kiszka@siemens.com>
      Cc: Kieran Bingham <kbingham@kernel.org>
      Cc: Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com>
      Cc: Palmer Dabbelt <palmer@rivosinc.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      40eea5ab
    • Florian Rommel's avatar
      scripts/gdb: make get_thread_info accept pointers · 7566b063
      Florian Rommel authored
      get_thread_info ($lx_thread_info) only accepted a dereferenced task
      parameter.  Passing a pointer to a task_struct (like $lx_per_cpu does with
      KGDB) threw an exception.
      
      With this patch, both (dereferenced values and pointers) are accepted.
      
      Before (on x86, KGDB):
      >>> p $lx_per_cpu(cpu_info)
      Traceback (most recent call last):
        File "./scripts/gdb/linux/cpus.py", line 158, in invoke
          return per_cpu(var_ptr, cpu)
                 ^^^^^^^^^^^^^^^^^^^^^
        File "./scripts/gdb/linux/cpus.py", line 42, in per_cpu
          cpu = get_current_cpu()
                ^^^^^^^^^^^^^^^^^
        File "./scripts/gdb/linux/cpus.py", line 33, in get_current_cpu
          return tasks.get_thread_info(tasks.get_task_by_pid(tid))['cpu']
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "./scripts/gdb/linux/tasks.py", line 88, in get_thread_info
          if task.type.fields()[0].type == thread_info_type.get_type():
             ~~~~~~~~~~~~~~~~~~^^^
      IndexError: list index out of range
      
      Link: https://lkml.kernel.org/r/20240425153501.749966-4-mail@florommel.de
      
      
      Signed-off-by: default avatarFlorian Rommel <mail@florommel.de>
      Cc: Andrew Jones <ajones@ventanamicro.com>
      Cc: Deepak Gupta <debug@rivosinc.com>
      Cc: Jan Kiszka <jan.kiszka@siemens.com>
      Cc: Kieran Bingham <kbingham@kernel.org>
      Cc: Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com>
      Cc: Palmer Dabbelt <palmer@rivosinc.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      7566b063
    • Florian Rommel's avatar
      scripts/gdb: fix parameter handling in $lx_per_cpu · db08c53f
      Florian Rommel authored
      Before, the script tried to get the address by constructing a pointer to
      the parameter (by name).  However, since GDB now passes the parameter as a
      GdbValue, we cannot get its name.  Instead, we retrieve the address
      through GdbValue's address attribute.
      
      Before:
      >>> p $lx_per_cpu(cpu_info)
      Traceback (most recent call last):
        File "./scripts/gdb/linux/cpus.py", line 152, in invoke
          var_ptr = gdb.parse_and_eval("&" + var_name.string())
                                             ^^^^^^^^^^^^^^^^^
      gdb.error: Trying to read string with inappropriate type `struct cpuinfo_x86'.
      
      Link: https://lkml.kernel.org/r/20240425153501.749966-3-mail@florommel.de
      
      
      Signed-off-by: default avatarFlorian Rommel <mail@florommel.de>
      Cc: Andrew Jones <ajones@ventanamicro.com>
      Cc: Deepak Gupta <debug@rivosinc.com>
      Cc: Jan Kiszka <jan.kiszka@siemens.com>
      Cc: Kieran Bingham <kbingham@kernel.org>
      Cc: Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com>
      Cc: Palmer Dabbelt <palmer@rivosinc.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      db08c53f
Loading