Skip to content

Instantly share code, notes, and snippets.

@klauer
Last active April 10, 2020 16:08
Show Gist options
  • Save klauer/b5ff0a892126501d38efa39a7872b52c to your computer and use it in GitHub Desktop.
Save klauer/b5ff0a892126501d38efa39a7872b52c to your computer and use it in GitHub Desktop.
strace: caget vs caproto-get
# strace -e trace=network -f -E EPICS_CA_ADDR_LIST="1.2.3.4 5.6.7.8" -E EPICS_CA_AUTO_ADDR_LIST=NO /root/epics/base/bin/linux-x86_64/caget test:A
strace: Process 540 attached
[pid 540] +++ exited with 0 +++
strace: Process 541 attached
strace: Process 542 attached
[pid 539] socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 3
[pid 539] connect(3, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
[pid 539] socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 3
[pid 539] connect(3, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
[pid 539] socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP) = 3
[pid 539] bind(3, {sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("0.0.0.0")}, 16) = 0
[pid 539] getsockname(3, {sa_family=AF_INET, sin_port=htons(51951), sin_addr=inet_addr("0.0.0.0")}, [16]) = 0
strace: Process 543 attached
[pid 539] socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP) = 4
[pid 539] setsockopt(4, SOL_IP, IP_MULTICAST_LOOP, [1], 4) = 0
[pid 539] setsockopt(4, SOL_IP, IP_MULTICAST_TTL, [1], 4) = 0
[pid 539] setsockopt(4, SOL_SOCKET, SO_BROADCAST, [1], 4) = 0
[pid 539] bind(4, {sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("0.0.0.0")}, 16) = 0
[pid 539] getsockname(4, {sa_family=AF_INET, sin_port=htons(48867), sin_addr=inet_addr("0.0.0.0")}, [16]) = 0
[pid 539] socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP) = 5
[pid 539] bind(5, {sa_family=AF_INET, sin_port=htons(5065), sin_addr=inet_addr("0.0.0.0")}, 16) = -1 EADDRINUSE (Address already in use)
[pid 539] setsockopt(5, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
[pid 543] recvfrom(4, <unfinished ...>
[pid 542] sendto(4, "\0\0\0\0\0\1\0\r\0\0\0\1\0\0\0\0\0\6\0\10\0\5\0\r\0\0\0\1\0\0\0\1"..., 40, 0, {sa_family=AF_INET, sin_port=htons(5064), sin_addr=inet_addr("1.2.3.4")}, 16) = 40
[pid 542] sendto(4, "\0\0\0\0\0\1\0\r\0\0\0\1\0\0\0\0\0\6\0\10\0\5\0\r\0\0\0\1\0\0\0\1"..., 40, 0, {sa_family=AF_INET, sin_port=htons(5064), sin_addr=inet_addr("5.6.7.8")}, 16) = 40
[pid 542] sendto(4, "\0\0\0\0\0\1\0\r\0\0\0\2\0\0\0\0\0\6\0\10\0\5\0\r\0\0\0\1\0\0\0\1"..., 40, 0, {sa_family=AF_INET, sin_port=htons(5064), sin_addr=inet_addr("1.2.3.4")}, 16) = 40
[pid 542] sendto(4, "\0\0\0\0\0\1\0\r\0\0\0\2\0\0\0\0\0\6\0\10\0\5\0\r\0\0\0\1\0\0\0\1"..., 40, 0, {sa_family=AF_INET, sin_port=htons(5064), sin_addr=inet_addr("5.6.7.8")}, 16) = 40
[pid 542] sendto(4, "\0\0\0\0\0\1\0\r\0\0\0\3\0\0\0\0\0\6\0\10\0\5\0\r\0\0\0\1\0\0\0\1"..., 40, 0, {sa_family=AF_INET, sin_port=htons(5064), sin_addr=inet_addr("1.2.3.4")}, 16) = 40
[pid 542] sendto(4, "\0\0\0\0\0\1\0\r\0\0\0\3\0\0\0\0\0\6\0\10\0\5\0\r\0\0\0\1\0\0\0\1"..., 40, 0, {sa_family=AF_INET, sin_port=htons(5064), sin_addr=inet_addr("5.6.7.8")}, 16) = 40
[pid 542] sendto(4, "\0\0\0\0\0\1\0\r\0\0\0\4\0\0\0\0\0\6\0\10\0\5\0\r\0\0\0\1\0\0\0\1"..., 40, 0, {sa_family=AF_INET, sin_port=htons(5064), sin_addr=inet_addr("1.2.3.4")}, 16) = 40
[pid 542] sendto(4, "\0\0\0\0\0\1\0\r\0\0\0\4\0\0\0\0\0\6\0\10\0\5\0\r\0\0\0\1\0\0\0\1"..., 40, 0, {sa_family=AF_INET, sin_port=htons(5064), sin_addr=inet_addr("5.6.7.8")}, 16) = 40
[pid 542] sendto(4, "\0\0\0\0\0\1\0\r\0\0\0\5\0\0\0\0\0\6\0\10\0\5\0\r\0\0\0\1\0\0\0\1"..., 40, 0, {sa_family=AF_INET, sin_port=htons(5064), sin_addr=inet_addr("1.2.3.4")}, 16) = 40
[pid 542] sendto(4, "\0\0\0\0\0\1\0\r\0\0\0\5\0\0\0\0\0\6\0\10\0\5\0\r\0\0\0\1\0\0\0\1"..., 40, 0, {sa_family=AF_INET, sin_port=htons(5064), sin_addr=inet_addr("5.6.7.8")}, 16) = 40
Channel connect timed out: 'test:A' not found.
[pid 539] sendto(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 16, 0, {sa_family=AF_INET, sin_port=htons(48867), sin_addr=inet_addr("127.0.0.1")}, 16) = 16
[pid 543] <... recvfrom resumed> "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 65551, 0, {sa_family=AF_INET, sin_port=htons(48867), sin_addr=inet_addr("127.0.0.1")}, [16]) = 16
[pid 543] +++ exited with 0 +++
[pid 542] +++ exited with 0 +++
strace: Process 544 attached
[pid 541] +++ exited with 1 +++
[pid 544] +++ exited with 1 +++
+++ exited with 1 +++
# strace -e trace=network -f -E EPICS_CA_ADDR_LIST="1.2.3.4 5.6.7.8" -E EPICS_CA_AUTO_ADDR_LIST=YES /root/epics/base/bin/linux-x86_64/caget test:A
strace: Process 520 attached
[pid 520] +++ exited with 0 +++
strace: Process 521 attached
strace: Process 522 attached
[pid 519] socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 3
[pid 519] connect(3, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
[pid 519] socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 3
[pid 519] connect(3, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
[pid 519] socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP) = 3
[pid 519] bind(3, {sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("0.0.0.0")}, 16) = 0
[pid 519] getsockname(3, {sa_family=AF_INET, sin_port=htons(51626), sin_addr=inet_addr("0.0.0.0")}, [16]) = 0
strace: Process 523 attached
[pid 519] socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP) = 4
[pid 519] setsockopt(4, SOL_IP, IP_MULTICAST_LOOP, [1], 4) = 0
[pid 519] setsockopt(4, SOL_IP, IP_MULTICAST_TTL, [1], 4) = 0
[pid 519] setsockopt(4, SOL_SOCKET, SO_BROADCAST, [1], 4) = 0
[pid 519] bind(4, {sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("0.0.0.0")}, 16) = 0
[pid 519] getsockname(4, {sa_family=AF_INET, sin_port=htons(46486), sin_addr=inet_addr("0.0.0.0")}, [16]) = 0
[pid 519] socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP) = 5
[pid 519] bind(5, {sa_family=AF_INET, sin_port=htons(5065), sin_addr=inet_addr("0.0.0.0")}, 16) = -1 EADDRINUSE (Address already in use)
[pid 519] setsockopt(5, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
[pid 523] recvfrom(4, <unfinished ...>
[pid 522] sendto(4, "\0\0\0\0\0\1\0\r\0\0\0\1\0\0\0\0\0\6\0\10\0\5\0\r\0\0\0\1\0\0\0\1"..., 40, 0, {sa_family=AF_INET, sin_port=htons(5064), sin_addr=inet_addr("172.17.255.255")}, 16) = 40
[pid 522] sendto(4, "\0\0\0\0\0\1\0\r\0\0\0\1\0\0\0\0\0\6\0\10\0\5\0\r\0\0\0\1\0\0\0\1"..., 40, 0, {sa_family=AF_INET, sin_port=htons(5064), sin_addr=inet_addr("1.2.3.4")}, 16 <unfinished ...>
[pid 523] <... recvfrom resumed> "\0\0\0\0\0\1\0\r\0\0\0\1\0\0\0\0\0\6\0\10\23\310\0\0\377\377\377\377\0\0\0\1"..., 65551, 0, {sa_family=AF_INET, sin_port=htons(5064), sin_addr=inet_addr("172.17.0.2")}, [16]) = 40
[pid 522] <... sendto resumed> ) = 40
[pid 522] sendto(4, "\0\0\0\0\0\1\0\r\0\0\0\1\0\0\0\0\0\6\0\10\0\5\0\r\0\0\0\1\0\0\0\1"..., 40, 0, {sa_family=AF_INET, sin_port=htons(5064), sin_addr=inet_addr("5.6.7.8")}, 16) = 40
strace: Process 524 attached
strace: Process 525 attached
[pid 523] socket(AF_INET, SOCK_STREAM, IPPROTO_TCP) = 5
[pid 523] setsockopt(5, SOL_TCP, TCP_NODELAY, [1], 4) = 0
[pid 523] setsockopt(5, SOL_SOCKET, SO_KEEPALIVE, [1], 4) = 0
[pid 521] socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 6
[pid 521] connect(6, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110 <unfinished ...>
[pid 523] getsockopt(5, SOL_SOCKET, SO_SNDBUF, [16384], [4]) = 0
[pid 521] <... connect resumed> ) = -1 ENOENT (No such file or directory)
[pid 523] recvfrom(4, <unfinished ...>
[pid 521] socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 6
[pid 521] connect(6, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110 <unfinished ...>
[pid 524] connect(5, {sa_family=AF_INET, sin_port=htons(5064), sin_addr=inet_addr("172.17.0.2")}, 16 <unfinished ...>
[pid 521] <... connect resumed> ) = -1 ENOENT (No such file or directory)
[pid 524] <... connect resumed> ) = 0
[pid 524] recvfrom(5, "\0\0\0\0\0\0\0\r\0\0\0\0\0\0\0\0", 16384, 0, NULL, NULL) = 16
[pid 524] recvfrom(5, <unfinished ...>
[pid 525] sendto(5, "\0\0\0\0\0\0\0\r\0\0\0\0\0\0\0\0\0\24\0\10\0\0\0\0\0\0\0\0\0\0\0\0"..., 96, 0, NULL, 0) = 96
[pid 524] <... recvfrom resumed> "\0\26\0\0\0\0\0\0\0\0\0\1\0\0\0\3\0\22\0\0\0\6\0\1\0\0\0\1\0\0\0\f", 16384, 0, NULL, NULL) = 32
[pid 525] sendto(5, "\0\17\0\0\0\24\0\1\0\0\0\f\0\0\0\1", 16, 0, NULL, 0) = 16
[pid 524] recvfrom(5, "\0\17\0\30\0\24\0\1\0\0\0\1\0\0\0\1\0\21\0\3\0\0\0\0\0\0\0\0\0\0\0\f"..., 16384, 0, NULL, NULL) = 40
[pid 524] recvfrom(5, test:A 0
<unfinished ...>
[pid 519] sendto(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 16, 0, {sa_family=AF_INET, sin_port=htons(46486), sin_addr=inet_addr("127.0.0.1")}, 16) = 16
[pid 523] <... recvfrom resumed> "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 65551, 0, {sa_family=AF_INET, sin_port=htons(46486), sin_addr=inet_addr("127.0.0.1")}, [16]) = 16
[pid 523] +++ exited with 0 +++
[pid 525] sendto(5, "\0\f\0\0\0\0\0\0\0\0\0\f\0\0\0\1", 16, 0, NULL, 0) = 16
[pid 524] <... recvfrom resumed> "\0\f\0\0\0\0\0\0\0\0\0\f\0\0\0\1", 16384, 0, NULL, NULL) = 16
[pid 525] shutdown(5, SHUT_WR) = 0
[pid 524] recvfrom(5, "", 16384, 0, NULL, NULL) = 0
[pid 524] +++ exited with 0 +++
[pid 525] +++ exited with 0 +++
[pid 522] +++ exited with 0 +++
strace: Process 528 attached
[pid 528] +++ exited with 0 +++
[pid 521] +++ exited with 0 +++
+++ exited with 0 +++
# strace -e trace=network -f -E EPICS_CA_ADDR_LIST="1.2.3.4 5.6.7.8" -E EPICS_CA_AUTO_ADDR_LIST=YES caproto-get test:A
/usr/local/lib/python3.6/dist-packages/caproto/_utils.py:246: UserWarning: EPICS_CA_ADDR_LIST is set but will be ignored because EPICS_CA_AUTO_ADDR_LIST is not set to 'no'. EPICS_CA_ADDR_LIST='1.2.3.4 5.6.7.8' EPICS_CA_AUTO_ADDR_LIST='YES'
result.get('EPICS_CA_AUTO_ADDR_LIST', ''))
socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC, IPPROTO_UDP) = 3
bind(3, {sa_family=AF_INET, sin_port=htons(5065), sin_addr=inet_addr("0.0.0.0")}, 16) = -1 EADDRINUSE (Address already in use)
getsockname(3, {sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("0.0.0.0")}, [16]) = 0
getpeername(3, 0x7ffe6da768b0, [16]) = -1 ENOTCONN (Transport endpoint is not connected)
socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC, IPPROTO_IP) = 3
setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
setsockopt(3, SOL_SOCKET, SO_BROADCAST, [1], 4) = 0
setsockopt(3, SOL_SOCKET, SO_REUSEPORT, [1], 4) = 0
getsockname(3, {sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("0.0.0.0")}, [16]) = 0
sendto(3, "\0\30\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 16, 0, {sa_family=AF_INET, sin_port=htons(5065), sin_addr=inet_addr("255.255.255.255")}, 16) = 16
sendto(3, "\0\0\0\0\0\0\0\r\0\0\0\0\0\0\0\0\0\6\0\10\0\5\0\r\0\0\0\0\0\0\0\0"..., 40, 0, {sa_family=AF_INET, sin_port=htons(5064), sin_addr=inet_addr("255.255.255.255")}, 16) = 40
recvfrom(3, "\0\21\0\0\0\0\0\0\0\0\0\0\254\21\0\2", 65519, 0, {sa_family=AF_INET, sin_port=htons(5065), sin_addr=inet_addr("172.17.0.2")}, [16]) = 16
recvfrom(3, "\0\0\0\0\0\1\0\r\0\0\0\0\0\0\0\0\0\6\0\10\23\310\0\0\377\377\377\377\0\0\0\0"..., 65519, 0, {sa_family=AF_INET, sin_port=htons(5064), sin_addr=inet_addr("172.17.0.2")}, [16]) = 40
socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, IPPROTO_TCP) = 4
connect(4, {sa_family=AF_INET, sin_port=htons(5064), sin_addr=inet_addr("172.17.0.2")}, 16) = -1 EINPROGRESS (Operation now in progress)
getsockopt(4, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
getsockname(4, {sa_family=AF_INET, sin_port=htons(39366), sin_addr=inet_addr("172.17.0.2")}, [16]) = 0
sendmsg(4, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\0\0\0\0\0\0\0\r\0\0\0\0\0\0\0\0", iov_len=16}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 16
sendmsg(4, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\0\25\0\20\0\0\0\0\0\0\0\0\0\0\0\0", iov_len=16}, {iov_base="", iov_len=0}, {iov_base="42394f05b01b\0\0\0\0", iov_len=16}], msg_iovlen=3, msg_controllen=0, msg_flags=0}, 0) = 32
socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 5
connect(5, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 5
connect(5, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
sendmsg(4, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\0\24\0\10\0\0\0\0\0\0\0\0\0\0\0\0", iov_len=16}, {iov_base="", iov_len=0}, {iov_base="root\0\0\0\0", iov_len=8}], msg_iovlen=3, msg_controllen=0, msg_flags=0}, 0) = 24
sendmsg(4, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\0\22\0\10\0\0\0\0\0\0\0\0\0\0\0\r", iov_len=16}, {iov_base="", iov_len=0}, {iov_base="test:A\0\0", iov_len=8}], msg_iovlen=3, msg_controllen=0, msg_flags=0}, 0) = 24
recvfrom(4, "\0\0\0\0\0\0\0\r\0\0\0\0\0\0\0\0\0\26\0\0\0\0\0\0\0\0\0\0\0\0\0\3"..., 4096, 0, NULL, NULL) = 48
sendmsg(4, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\0\17\0\0\0\6\0\0\0\0\0\r\0\0\0\0", iov_len=16}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 16
recvfrom(4, "\0\17\0\10\0\6\0\1\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0", 4096, 0, NULL, NULL) = 24
sendmsg(4, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\0\f\0\0\0\0\0\0\0\0\0\r\0\0\0\0", iov_len=16}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 16
test:A [0]
+++ exited with 0 +++
FROM hhslepicka/epics-devel
RUN apt-get update && apt-get install -y python3-pip strace tmux
RUN python3 -m pip install caproto
# docker run -it container /bin/bash
# tmux
# echo "record(ai, "test:A") {}" > test.db
# /root/epics/base/bin/linux-x86_64/softIoc -d test.db
# echo "Settings: $EPICS_CA_ADDR_LIST $EPICS_CA_AUTO_ADDR_LIST"; strace -f -e trace=network /root/epics/base/bin/linux-x86_64/caget test:A
@klauer
Copy link
Author

klauer commented Apr 9, 2020

Calls correctly including environment variables would look like (not as in the above):

strace -f -e trace=network -E EPICS_CA_ADDR_LIST=... -E EPICS_CA_AUTO_ADDR_LIST=... /root/epics/base/bin/linux-x86_64/caget test:A

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment