diff options
author | Jim Ingham <jingham@apple.com> | 2011-03-29 21:45:47 +0000 |
---|---|---|
committer | Jim Ingham <jingham@apple.com> | 2011-03-29 21:45:47 +0000 |
commit | 7572fa75cff0a2567e1cc86e0c88931b58960f44 (patch) | |
tree | e372fd779301a5bc08619bb3a3799ff88c28110a /lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp | |
parent | 143f9aea2b73a4d7be47c51efd8d353231cc49c8 (diff) | |
download | bcm5719-llvm-7572fa75cff0a2567e1cc86e0c88931b58960f44.tar.gz bcm5719-llvm-7572fa75cff0a2567e1cc86e0c88931b58960f44.zip |
Can't just call "rand" to get a random port, 'cause then you'll get the same sequence in two lldb's. This makes running lldb on lldb not work very well.
llvm-svn: 128493
Diffstat (limited to 'lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp')
-rw-r--r-- | lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index 49f9aa6eb9f..b434853120e 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -54,9 +54,16 @@ using namespace lldb; using namespace lldb_private; +static bool rand_initialized = false; + static inline uint16_t get_random_port () { + if (!rand_initialized) + { + rand_initialized = true; + sranddev(); + } return (rand() % (UINT16_MAX - 1000u)) + 1000u; } |