You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@trafficserver.apache.org by GitBox <gi...@apache.org> on 2022/11/17 19:38:02 UTC

[GitHub] [trafficserver] bneradt commented on a diff in pull request #9201: update gdb-helpers

bneradt commented on code in PR #9201:
URL: https://github.com/apache/trafficserver/pull/9201#discussion_r1025620447


##########
tools/gdb-helpers.py:
##########
@@ -222,10 +233,14 @@ def sm_command(val):
 def hdrs_command(val):
     HTTPHdr(val).pr()
 
+def url_command(val):
+    print("{}".format(URL(val)))

Review Comment:
   Doesn't look like this needs to be a formatted string:
   
   ```
       print(URL(val))
   ```



##########
tools/gdb-helpers.py:
##########
@@ -37,19 +37,30 @@
 
 
 def ats_str(addr, addr_len):
+    if addr_len == 0:
+        return ''
     #print("addr {} len {}".format(addr, addr_len))
     inferior = gdb.selected_inferior()
-    buff = inferior.read_memory(addr, addr_len)
-    if buff[0] == '\x00':
-        return 'null'
-    else:
-        return buff
+    try:
+        buff = inferior.read_memory(addr, addr_len)
+        if buff[0] == '\x00':
+            return 'null'
+        else:
+            return buff
+    except:
+        return 'unreadable({:x})'.format(int(addr))

Review Comment:
   Preferable to use a format string literal:
   
   ```
           return f'unreadable({int(addr):x}'



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org