Convert int to bool in agent.c
authorChristian Biesinger <cbiesinger@google.com>
Wed, 30 Oct 2019 21:19:11 +0000 (16:19 -0500)
committerChristian Biesinger <cbiesinger@google.com>
Thu, 31 Oct 2019 18:28:14 +0000 (13:28 -0500)
Also moves an int declaration inside the for loop.

Code cleanup, no change in behavior intended.

gdb/ChangeLog:

2019-10-31  Christian Biesinger  <cbiesinger@google.com>

* gdbsupport/agent.c (debug_agent): Change type to bool.
(use_agent): Likewise.
(all_agent_symbols_look_up): Likewise.
(agent_loaded_p): Change return value to bool.
(agent_look_up_symbols): Update.
(agent_capability_check): Change return value to bool.
* gdbsupport/agent.h (agent_loaded_p): Likewise.
(debug_agent): Change type to bool.
(use_agent): Likewise.
(agent_capability_check): Change return value to bool.

gdb/gdbserver/ChangeLog:

2019-10-31  Christian Biesinger  <cbiesinger@google.com>

* ax.h (debug_agent): Remove duplicate declaration.

Change-Id: Icb28a65fcc8c7108bcd59287e6be66bf56f8ccb5

gdb/ChangeLog
gdb/gdbserver/ChangeLog
gdb/gdbserver/ax.h
gdb/gdbsupport/agent.c
gdb/gdbsupport/agent.h

index 0382082a92dfc050f4fc76e38e6effe118270634..ee48133aa7a74eb7977aa444a9d0ef5c55705326 100644 (file)
@@ -1,3 +1,16 @@
+2019-10-31  Christian Biesinger  <cbiesinger@google.com>
+
+       * gdbsupport/agent.c (debug_agent): Change type to bool.
+       (use_agent): Likewise.
+       (all_agent_symbols_look_up): Likewise.
+       (agent_loaded_p): Change return value to bool.
+       (agent_look_up_symbols): Update.
+       (agent_capability_check): Change return value to bool.
+       * gdbsupport/agent.h (agent_loaded_p): Likewise.
+       (debug_agent): Change type to bool.
+       (use_agent): Likewise.
+       (agent_capability_check): Change return value to bool.
+
 2019-10-30  Christian Biesinger  <cbiesinger@google.com>
 
        * minsyms.c (clear_minimal_symbol_hash_tables): New function.
index d016549e296ec4cc946481148c3cbedb6d39174e..9606596e3d82eb90818773e0b9aa3786148ca9a5 100644 (file)
@@ -1,3 +1,7 @@
+2019-10-31  Christian Biesinger  <cbiesinger@google.com>
+
+       * ax.h (debug_agent): Remove duplicate declaration.
+
 2019-10-26  Tom de Vries  <tdevries@suse.de>
 
        * linux-aarch64-low.c: Fix typos in comments.
index 3e9fd8f795c970405c47098a9ec027b914f3aa54..db8ecae076ef266af2f1b19508f3f778253cbef9 100644 (file)
@@ -22,7 +22,6 @@
 #include "regcache.h"
 
 #ifdef IN_PROCESS_AGENT
-extern int debug_agent;
 #define debug_threads debug_agent
 #endif
 
index 02cad4636994bffcb9057fd9e98d3d012fbbfc1e..6d55f586b8fc8b9e1acaa71f3499065249f72f6b 100644 (file)
@@ -26,7 +26,7 @@
 #define IPA_SYM_STRUCT_NAME ipa_sym_addresses_common
 #include "agent.h"
 
-int debug_agent = 0;
+bool debug_agent = false;
 
 /* A stdarg wrapper for debug_vprintf.  */
 
@@ -45,7 +45,7 @@ debug_agent_printf (const char *fmt, ...)
 #define DEBUG_AGENT debug_agent_printf
 
 /* Global flag to determine using agent or not.  */
-int use_agent = 0;
+bool use_agent = false;
 
 /* Addresses of in-process agent's symbols both GDB and GDBserver cares
    about.  */
@@ -73,9 +73,9 @@ static struct
 
 static struct ipa_sym_addresses_common ipa_sym_addrs;
 
-static int all_agent_symbols_looked_up = 0;
+static bool all_agent_symbols_looked_up = false;
 
-int
+bool
 agent_loaded_p (void)
 {
   return all_agent_symbols_looked_up;
@@ -87,11 +87,9 @@ agent_loaded_p (void)
 int
 agent_look_up_symbols (void *arg)
 {
-  int i;
-
-  all_agent_symbols_looked_up = 0;
+  all_agent_symbols_looked_up = false;
 
-  for (i = 0; i < sizeof (symbol_list) / sizeof (symbol_list[0]); i++)
+  for (int i = 0; i < sizeof (symbol_list) / sizeof (symbol_list[0]); i++)
     {
       CORE_ADDR *addrp =
        (CORE_ADDR *) ((char *) &ipa_sym_addrs + symbol_list[i].offset);
@@ -105,7 +103,7 @@ agent_look_up_symbols (void *arg)
        }
     }
 
-  all_agent_symbols_looked_up = 1;
+  all_agent_symbols_looked_up = true;
   return 0;
 }
 
@@ -260,7 +258,7 @@ static uint32_t agent_capability = 0;
 
 /* Return true if agent has capability AGENT_CAP, otherwise return false.  */
 
-int
+bool
 agent_capability_check (enum agent_capa agent_capa)
 {
   if (agent_capability == 0)
@@ -269,7 +267,7 @@ agent_capability_check (enum agent_capa agent_capa)
                              &agent_capability))
        warning (_("Error reading capability of agent"));
     }
-  return agent_capability & agent_capa;
+  return (agent_capability & agent_capa) != 0;
 }
 
 /* Invalidate the cache of agent capability, so we'll read it from inferior
index 4f054987dd0dfb6c74c69614a892d4c3a70fc207..27f515dc9c30a18c3ab5f2018042ea4e29ba21ed 100644 (file)
@@ -42,11 +42,11 @@ int agent_look_up_symbols (void *);
    thread.  */
 #define IPA_CMD_BUF_SIZE 1024
 
-int agent_loaded_p (void);
+bool agent_loaded_p (void);
 
-extern int debug_agent;
+extern bool debug_agent;
 
-extern int use_agent;
+extern bool use_agent;
 
 /* Capability of agent.  Different agents may have different capabilities,
    such as installing fast tracepoint or evaluating breakpoint conditions.
@@ -61,7 +61,7 @@ enum agent_capa
   AGENT_CAPA_STATIC_TRACE = (0x1 << 1),
 };
 
-int agent_capability_check (enum agent_capa);
+bool agent_capability_check (enum agent_capa);
 
 void agent_capability_invalidate (void);
 
This page took 0.039228 seconds and 4 git commands to generate.