All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] scripts/gdb: clean up
@ 2015-05-14  5:22 Thiébaud Weksteen
  2015-05-14  5:22 ` [PATCH 1/3] scripts/gdb: Fix typo in exception name Thiébaud Weksteen
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Thiébaud Weksteen @ 2015-05-14  5:22 UTC (permalink / raw)
  To: linux-kernel; +Cc: Thiébaud Weksteen, jan.kiszka

Set of patches to clean up scripts/gdb

Thiébaud Weksteen (3):
  scripts/gdb: Fix typo in exception name
  scripts/gdb: Fix PEP8 compliance
  scripts/gdb: Remove useless global instruction

 scripts/gdb/linux/dmesg.py   | 1 -
 scripts/gdb/linux/symbols.py | 9 ++++-----
 scripts/gdb/linux/tasks.py   | 4 ++--
 scripts/gdb/linux/utils.py   | 4 ++--
 4 files changed, 8 insertions(+), 10 deletions(-)

-- 
2.1.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/3] scripts/gdb: Fix typo in exception name
  2015-05-14  5:22 [PATCH 0/3] scripts/gdb: clean up Thiébaud Weksteen
@ 2015-05-14  5:22 ` Thiébaud Weksteen
  2015-05-14  5:22 ` [PATCH 2/3] scripts/gdb: Fix PEP8 compliance Thiébaud Weksteen
  2015-05-14  5:22 ` [PATCH 3/3] scripts/gdb: Remove useless global instruction Thiébaud Weksteen
  2 siblings, 0 replies; 6+ messages in thread
From: Thiébaud Weksteen @ 2015-05-14  5:22 UTC (permalink / raw)
  To: linux-kernel; +Cc: Thiébaud Weksteen, jan.kiszka

Signed-off-by: Thiébaud Weksteen <thiebaud@weksteen.fr>
---
 scripts/gdb/linux/utils.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/gdb/linux/utils.py b/scripts/gdb/linux/utils.py
index 128c306..d7ff3a3 100644
--- a/scripts/gdb/linux/utils.py
+++ b/scripts/gdb/linux/utils.py
@@ -83,7 +83,7 @@ def get_target_endianness():
         elif "big endian" in endian:
             target_endianness = BIG_ENDIAN
         else:
-            raise gdb.GdgError("unknown endianness '{0}'".format(str(endian)))
+            raise gdb.GdbError("unknown endianness '{0}'".format(str(endian)))
     return target_endianness
 
 
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] scripts/gdb: Fix PEP8 compliance
  2015-05-14  5:22 [PATCH 0/3] scripts/gdb: clean up Thiébaud Weksteen
  2015-05-14  5:22 ` [PATCH 1/3] scripts/gdb: Fix typo in exception name Thiébaud Weksteen
@ 2015-05-14  5:22 ` Thiébaud Weksteen
  2015-05-15 11:32   ` Jan Kiszka
  2015-05-14  5:22 ` [PATCH 3/3] scripts/gdb: Remove useless global instruction Thiébaud Weksteen
  2 siblings, 1 reply; 6+ messages in thread
From: Thiébaud Weksteen @ 2015-05-14  5:22 UTC (permalink / raw)
  To: linux-kernel; +Cc: Thiébaud Weksteen, jan.kiszka

Signed-off-by: Thiébaud Weksteen <thiebaud@weksteen.fr>
---
 scripts/gdb/linux/dmesg.py   | 1 -
 scripts/gdb/linux/symbols.py | 9 ++++-----
 scripts/gdb/linux/tasks.py   | 2 ++
 scripts/gdb/linux/utils.py   | 2 +-
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/scripts/gdb/linux/dmesg.py b/scripts/gdb/linux/dmesg.py
index 3c947f0..927d0d2 100644
--- a/scripts/gdb/linux/dmesg.py
+++ b/scripts/gdb/linux/dmesg.py
@@ -12,7 +12,6 @@
 #
 
 import gdb
-import string
 
 from linux import utils
 
diff --git a/scripts/gdb/linux/symbols.py b/scripts/gdb/linux/symbols.py
index cd5bea9..627750c 100644
--- a/scripts/gdb/linux/symbols.py
+++ b/scripts/gdb/linux/symbols.py
@@ -14,9 +14,8 @@
 import gdb
 import os
 import re
-import string
 
-from linux import modules, utils
+from linux import modules
 
 
 if hasattr(gdb, 'Breakpoint'):
@@ -97,7 +96,7 @@ lx-symbols command."""
             return ""
         attrs = sect_attrs['attrs']
         section_name_to_address = {
-            attrs[n]['name'].string() : attrs[n]['address']
+            attrs[n]['name'].string(): attrs[n]['address']
             for n in range(int(sect_attrs['nsections']))}
         args = []
         for section_name in [".data", ".data..read_mostly", ".rodata", ".bss"]:
@@ -124,7 +123,7 @@ lx-symbols command."""
                 addr=module_addr,
                 sections=self._section_arguments(module))
             gdb.execute(cmdline, to_string=True)
-            if not module_name in self.loaded_modules:
+            if module_name not in self.loaded_modules:
                 self.loaded_modules.append(module_name)
         else:
             gdb.write("no module object found for '{0}'\n".format(module_name))
@@ -164,7 +163,7 @@ lx-symbols command."""
         self.load_all_symbols()
 
         if hasattr(gdb, 'Breakpoint'):
-            if not self.breakpoint is None:
+            if self.breakpoint is not None:
                 self.breakpoint.delete()
                 self.breakpoint = None
             self.breakpoint = LoadModuleBreakpoint(
diff --git a/scripts/gdb/linux/tasks.py b/scripts/gdb/linux/tasks.py
index e2037d9..89d38e1 100644
--- a/scripts/gdb/linux/tasks.py
+++ b/scripts/gdb/linux/tasks.py
@@ -18,6 +18,7 @@ from linux import utils
 
 task_type = utils.CachedType("struct task_struct")
 
+
 def task_lists():
     global task_type
     task_ptr_type = task_type.get_type().pointer()
@@ -38,6 +39,7 @@ def task_lists():
         if t == init_task:
             return
 
+
 def get_task_by_pid(pid):
     for task in task_lists():
         if int(task['pid']) == pid:
diff --git a/scripts/gdb/linux/utils.py b/scripts/gdb/linux/utils.py
index d7ff3a3..0893b32 100644
--- a/scripts/gdb/linux/utils.py
+++ b/scripts/gdb/linux/utils.py
@@ -151,6 +151,6 @@ def get_gdbserver_type():
             gdbserver_type = GDBSERVER_QEMU
         elif probe_kgdb():
             gdbserver_type = GDBSERVER_KGDB
-        if not gdbserver_type is None and hasattr(gdb, 'events'):
+        if gdbserver_type is not None and hasattr(gdb, 'events'):
             gdb.events.exited.connect(exit_handler)
     return gdbserver_type
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] scripts/gdb: Remove useless global instruction
  2015-05-14  5:22 [PATCH 0/3] scripts/gdb: clean up Thiébaud Weksteen
  2015-05-14  5:22 ` [PATCH 1/3] scripts/gdb: Fix typo in exception name Thiébaud Weksteen
  2015-05-14  5:22 ` [PATCH 2/3] scripts/gdb: Fix PEP8 compliance Thiébaud Weksteen
@ 2015-05-14  5:22 ` Thiébaud Weksteen
  2015-05-15 11:32   ` Jan Kiszka
  2 siblings, 1 reply; 6+ messages in thread
From: Thiébaud Weksteen @ 2015-05-14  5:22 UTC (permalink / raw)
  To: linux-kernel; +Cc: Thiébaud Weksteen, jan.kiszka

Signed-off-by: Thiébaud Weksteen <thiebaud@weksteen.fr>
---
 scripts/gdb/linux/tasks.py | 2 --
 1 file changed, 2 deletions(-)

diff --git a/scripts/gdb/linux/tasks.py b/scripts/gdb/linux/tasks.py
index 89d38e1..0fa33b0 100644
--- a/scripts/gdb/linux/tasks.py
+++ b/scripts/gdb/linux/tasks.py
@@ -20,7 +20,6 @@ task_type = utils.CachedType("struct task_struct")
 
 
 def task_lists():
-    global task_type
     task_ptr_type = task_type.get_type().pointer()
     init_task = gdb.parse_and_eval("init_task").address
     t = g = init_task
@@ -73,7 +72,6 @@ ia64_task_size = None
 
 
 def get_thread_info(task):
-    global thread_info_type
     thread_info_ptr_type = thread_info_type.get_type().pointer()
     if utils.is_target_arch("ia64"):
         global ia64_task_size
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/3] scripts/gdb: Fix PEP8 compliance
  2015-05-14  5:22 ` [PATCH 2/3] scripts/gdb: Fix PEP8 compliance Thiébaud Weksteen
@ 2015-05-15 11:32   ` Jan Kiszka
  0 siblings, 0 replies; 6+ messages in thread
From: Jan Kiszka @ 2015-05-15 11:32 UTC (permalink / raw)
  To: Thiébaud Weksteen, linux-kernel

On 2015-05-14 07:22, Thiébaud Weksteen wrote:
> Signed-off-by: Thiébaud Weksteen <thiebaud@weksteen.fr>
> ---
>  scripts/gdb/linux/dmesg.py   | 1 -
>  scripts/gdb/linux/symbols.py | 9 ++++-----
>  scripts/gdb/linux/tasks.py   | 2 ++
>  scripts/gdb/linux/utils.py   | 2 +-
>  4 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/scripts/gdb/linux/dmesg.py b/scripts/gdb/linux/dmesg.py
> index 3c947f0..927d0d2 100644
> --- a/scripts/gdb/linux/dmesg.py
> +++ b/scripts/gdb/linux/dmesg.py
> @@ -12,7 +12,6 @@
>  #
>  
>  import gdb
> -import string
>  
>  from linux import utils
>  
> diff --git a/scripts/gdb/linux/symbols.py b/scripts/gdb/linux/symbols.py
> index cd5bea9..627750c 100644
> --- a/scripts/gdb/linux/symbols.py
> +++ b/scripts/gdb/linux/symbols.py
> @@ -14,9 +14,8 @@
>  import gdb
>  import os
>  import re
> -import string
>  
> -from linux import modules, utils
> +from linux import modules
>  
>  
>  if hasattr(gdb, 'Breakpoint'):
> @@ -97,7 +96,7 @@ lx-symbols command."""
>              return ""
>          attrs = sect_attrs['attrs']
>          section_name_to_address = {
> -            attrs[n]['name'].string() : attrs[n]['address']
> +            attrs[n]['name'].string(): attrs[n]['address']
>              for n in range(int(sect_attrs['nsections']))}
>          args = []
>          for section_name in [".data", ".data..read_mostly", ".rodata", ".bss"]:
> @@ -124,7 +123,7 @@ lx-symbols command."""
>                  addr=module_addr,
>                  sections=self._section_arguments(module))
>              gdb.execute(cmdline, to_string=True)
> -            if not module_name in self.loaded_modules:
> +            if module_name not in self.loaded_modules:
>                  self.loaded_modules.append(module_name)
>          else:
>              gdb.write("no module object found for '{0}'\n".format(module_name))
> @@ -164,7 +163,7 @@ lx-symbols command."""
>          self.load_all_symbols()
>  
>          if hasattr(gdb, 'Breakpoint'):
> -            if not self.breakpoint is None:
> +            if self.breakpoint is not None:
>                  self.breakpoint.delete()
>                  self.breakpoint = None
>              self.breakpoint = LoadModuleBreakpoint(
> diff --git a/scripts/gdb/linux/tasks.py b/scripts/gdb/linux/tasks.py
> index e2037d9..89d38e1 100644
> --- a/scripts/gdb/linux/tasks.py
> +++ b/scripts/gdb/linux/tasks.py
> @@ -18,6 +18,7 @@ from linux import utils
>  
>  task_type = utils.CachedType("struct task_struct")
>  
> +
>  def task_lists():
>      global task_type
>      task_ptr_type = task_type.get_type().pointer()
> @@ -38,6 +39,7 @@ def task_lists():
>          if t == init_task:
>              return
>  
> +
>  def get_task_by_pid(pid):
>      for task in task_lists():
>          if int(task['pid']) == pid:
> diff --git a/scripts/gdb/linux/utils.py b/scripts/gdb/linux/utils.py
> index d7ff3a3..0893b32 100644
> --- a/scripts/gdb/linux/utils.py
> +++ b/scripts/gdb/linux/utils.py
> @@ -151,6 +151,6 @@ def get_gdbserver_type():
>              gdbserver_type = GDBSERVER_QEMU
>          elif probe_kgdb():
>              gdbserver_type = GDBSERVER_KGDB
> -        if not gdbserver_type is None and hasattr(gdb, 'events'):
> +        if gdbserver_type is not None and hasattr(gdb, 'events'):
>              gdb.events.exited.connect(exit_handler)
>      return gdbserver_type
> 

Thanks, queued these first 2.

Which tool did you use for identifying the unused imports?

Jan

-- 
Siemens AG, Corporate Technology, CT RTC ITP SES-DE
Corporate Competence Center Embedded Linux

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 3/3] scripts/gdb: Remove useless global instruction
  2015-05-14  5:22 ` [PATCH 3/3] scripts/gdb: Remove useless global instruction Thiébaud Weksteen
@ 2015-05-15 11:32   ` Jan Kiszka
  0 siblings, 0 replies; 6+ messages in thread
From: Jan Kiszka @ 2015-05-15 11:32 UTC (permalink / raw)
  To: Thiébaud Weksteen, linux-kernel

On 2015-05-14 07:22, Thiébaud Weksteen wrote:
> Signed-off-by: Thiébaud Weksteen <thiebaud@weksteen.fr>
> ---
>  scripts/gdb/linux/tasks.py | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/scripts/gdb/linux/tasks.py b/scripts/gdb/linux/tasks.py
> index 89d38e1..0fa33b0 100644
> --- a/scripts/gdb/linux/tasks.py
> +++ b/scripts/gdb/linux/tasks.py
> @@ -20,7 +20,6 @@ task_type = utils.CachedType("struct task_struct")
>  
>  
>  def task_lists():
> -    global task_type
>      task_ptr_type = task_type.get_type().pointer()
>      init_task = gdb.parse_and_eval("init_task").address
>      t = g = init_task
> @@ -73,7 +72,6 @@ ia64_task_size = None
>  
>  
>  def get_thread_info(task):
> -    global thread_info_type
>      thread_info_ptr_type = thread_info_type.get_type().pointer()
>      if utils.is_target_arch("ia64"):
>          global ia64_task_size

These are from my early Python days...

Did you check all the other global statements as well? I bet there are
more, e.g. the one in the last line above.

Jan

-- 
Siemens AG, Corporate Technology, CT RTC ITP SES-DE
Corporate Competence Center Embedded Linux

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-05-15 11:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-14  5:22 [PATCH 0/3] scripts/gdb: clean up Thiébaud Weksteen
2015-05-14  5:22 ` [PATCH 1/3] scripts/gdb: Fix typo in exception name Thiébaud Weksteen
2015-05-14  5:22 ` [PATCH 2/3] scripts/gdb: Fix PEP8 compliance Thiébaud Weksteen
2015-05-15 11:32   ` Jan Kiszka
2015-05-14  5:22 ` [PATCH 3/3] scripts/gdb: Remove useless global instruction Thiébaud Weksteen
2015-05-15 11:32   ` Jan Kiszka

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.