Initial preparations for CURL and Discord integration.

This commit is contained in:
Sandu Liviu Catalin committed 2021-01-27 07:27:48 +02:00
1 parent 8257eb61d6
commit 95705e87c8
1751 files changed
+440547 -854

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
if !STANDALONE
EXAMPLES_CPP03 = examples/cpp03
endif
if HAVE_CXX11
EXAMPLES_CPP11 = examples/cpp11
endif
if HAVE_CXX14
EXAMPLES_CPP14 = examples/cpp14
endif
if HAVE_CXX17
EXAMPLES_CPP17 = examples/cpp17
endif
SUBDIRS = $(EXAMPLES_CPP03) $(EXAMPLES_CPP11) $(EXAMPLES_CPP14) $(EXAMPLES_CPP17) tests
DIST_SUBDIRS = examples/cpp03 examples/cpp11 examples/cpp14 examples/cpp17 tests
EXTRA_DIST = \
Makefile.mgw \
Makefile.msc \
tools/handlerlive.pl \
tools/handlertree.pl \
tools/handlerviz.pl
MAINTAINERCLEANFILES = \
$(srcdir)/Makefile.in
+300
View File
@@ -0,0 +1,300 @@
SHELL=cmd
ifndef BOOSTDIR
BOOSTDIR = ../../boost_1_73_0
endif
ifdef OPTIMISED
OPTIM_CXXFLAGS = -O2
OPTIM_LDFLAGS = -O2
else
OPTIM_CXXFLAGS = -fno-inline
OPTIM_LDFLAGS =
endif
ifndef STANDALONE
BOOST_CXXFLAGS = -I$(BOOSTDIR) -DASIO_ENABLE_BOOST
endif
ifdef SEPARATE_COMPILATION
SEPARATE_COMPILATION_LIB = libasio.a
SEPARATE_COMPILATION_CXXFLAGS = \
-DASIO_SEPARATE_COMPILATION \
-DASIO_ENABLE_CANCELIO
endif
CXXFLAGS = -g -Wall -Wextra -mthreads -I../include \
$(OPTIM_CXXFLAGS) \
$(BOOST_CXXFLAGS) \
$(SEPARATE_COMPILATION_CXXFLAGS)
LDFLAGS = -g -mthreads $(OPTIM_LDFLAGS)
LIBS = $(SEPARATE_COMPILATION_LIB) -lws2_32 -lmswsock
DEFINES = -D_WIN32_WINNT=0x0501
PERFORMANCE_TEST_EXES = \
tests/performance/client.exe \
tests/performance/server.exe
UNIT_TEST_EXES = \
tests/unit/associated_allocator.exe \
tests/unit/associated_executor.exe \
tests/unit/async_result.exe \
tests/unit/awaitable.exe \
tests/unit/basic_datagram_socket.exe \
tests/unit/basic_deadline_timer.exe \
tests/unit/basic_raw_socket.exe \
tests/unit/basic_seq_packet_socket.exe \
tests/unit/basic_serial_port.exe \
tests/unit/basic_signal_set.exe \
tests/unit/basic_socket.exe \
tests/unit/basic_socket_acceptor.exe \
tests/unit/basic_stream_socket.exe \
tests/unit/basic_streambuf.exe \
tests/unit/basic_waitable_timer.exe \
tests/unit/bind_executor.exe \
tests/unit/buffered_read_stream.exe \
tests/unit/buffered_stream.exe \
tests/unit/buffered_write_stream.exe \
tests/unit/buffer.exe \
tests/unit/buffers_iterator.exe \
tests/unit/co_spawn.exe \
tests/unit/completion_condition.exe \
tests/unit/compose.exe \
tests/unit/connect.exe \
tests/unit/coroutine.exe \
tests/unit/deadline_timer.exe \
tests/unit/defer.exe \
tests/unit/detached.exe \
tests/unit/dispatch.exe \
tests/unit/error.exe \
tests/unit/execution_context.exe \
tests/unit/execution/any_executor.exe \
tests/unit/execution/blocking.exe \
tests/unit/execution/blocking_adaptation.exe \
tests/unit/execution/bulk_execute.exe \
tests/unit/execution/bulk_guarantee.exe \
tests/unit/execution/connect.exe \
tests/unit/execution/context_as.exe \
tests/unit/execution/execute.exe \
tests/unit/execution/executor.exe \
tests/unit/execution/invocable_archetype.exe \
tests/unit/execution/mapping.exe \
tests/unit/execution/operation_state.exe \
tests/unit/execution/outstanding_work.exe \
tests/unit/execution/prefer_only.exe \
tests/unit/execution/receiver.exe \
tests/unit/execution/relationship.exe \
tests/unit/execution/schedule.exe \
tests/unit/execution/scheduler.exe \
tests/unit/execution/sender.exe \
tests/unit/execution/set_done.exe \
tests/unit/execution/set_error.exe \
tests/unit/execution/set_value.exe \
tests/unit/execution/start.exe \
tests/unit/execution/submit.exe \
tests/unit/executor.exe \
tests/unit/executor_work_guard.exe \
tests/unit/generic/basic_endpoint.exe \
tests/unit/generic/datagram_protocol.exe \
tests/unit/generic/raw_protocol.exe \
tests/unit/generic/seq_packet_protocol.exe \
tests/unit/generic/stream_protocol.exe \
tests/unit/high_resolution_timer.exe \
tests/unit/io_context.exe \
tests/unit/io_context_strand.exe \
tests/unit/ip/address.exe \
tests/unit/ip/address_v4.exe \
tests/unit/ip/address_v4_iterator.exe \
tests/unit/ip/address_v4_range.exe \
tests/unit/ip/address_v6.exe \
tests/unit/ip/address_v6_iterator.exe \
tests/unit/ip/address_v6_range.exe \
tests/unit/ip/basic_endpoint.exe \
tests/unit/ip/basic_resolver.exe \
tests/unit/ip/basic_resolver_entry.exe \
tests/unit/ip/basic_resolver_iterator.exe \
tests/unit/ip/basic_resolver_query.exe \
tests/unit/ip/host_name.exe \
tests/unit/ip/icmp.exe \
tests/unit/ip/multicast.exe \
tests/unit/ip/network_v4.exe \
tests/unit/ip/network_v6.exe \
tests/unit/ip/resolver_query_base.exe \
tests/unit/ip/tcp.exe \
tests/unit/ip/udp.exe \
tests/unit/ip/unicast.exe \
tests/unit/ip/v6_only.exe \
tests/unit/is_read_buffered.exe \
tests/unit/is_write_buffered.exe \
tests/unit/packaged_task.exe \
tests/unit/placeholders.exe \
tests/unit/post.exe \
tests/unit/read.exe \
tests/unit/read_at.exe \
tests/unit/read_until.exe \
tests/unit/redirect_error.exe \
tests/unit/serial_port.exe \
tests/unit/serial_port_base.exe \
tests/unit/signal_set.exe \
tests/unit/socket_base.exe \
tests/unit/static_thread_pool.exe \
tests/unit/steady_timer.exe \
tests/unit/strand.exe \
tests/unit/streambuf.exe \
tests/unit/system_context.exe \
tests/unit/system_executor.exe \
tests/unit/system_timer.exe \
tests/unit/this_coro.exe \
tests/unit/thread.exe \
tests/unit/thread_pool.exe \
tests/unit/time_traits.exe \
tests/unit/ts/buffer.exe \
tests/unit/ts/executor.exe \
tests/unit/ts/internet.exe \
tests/unit/ts/io_context.exe \
tests/unit/ts/net.exe \
tests/unit/ts/netfwd.exe \
tests/unit/ts/socket.exe \
tests/unit/ts/timer.exe \
tests/unit/use_awaitable.exe \
tests/unit/use_future.exe \
tests/unit/uses_executor.exe \
tests/unit/wait_traits.exe \
tests/unit/windows/basic_object_handle.exe \
tests/unit/windows/basic_overlapped_handle.exe \
tests/unit/windows/basic_random_access_handle.exe \
tests/unit/windows/basic_stream_handle.exe \
tests/unit/windows/object_handle.exe \
tests/unit/windows/overlapped_handle.exe \
tests/unit/windows/overlapped_ptr.exe \
tests/unit/windows/random_access_handle.exe \
tests/unit/windows/stream_handle.exe \
tests/unit/write.exe \
tests/unit/write_at.exe
CPP03_EXAMPLE_EXES = \
examples/cpp03/allocation/server.exe \
examples/cpp03/buffers/reference_counted.exe \
examples/cpp03/chat/chat_client.exe \
examples/cpp03/chat/chat_server.exe \
examples/cpp03/echo/async_tcp_echo_server.exe \
examples/cpp03/echo/async_udp_echo_server.exe \
examples/cpp03/echo/blocking_tcp_echo_client.exe \
examples/cpp03/echo/blocking_tcp_echo_server.exe \
examples/cpp03/echo/blocking_udp_echo_client.exe \
examples/cpp03/echo/blocking_udp_echo_server.exe \
examples/cpp03/http/client/async_client.exe \
examples/cpp03/http/client/sync_client.exe \
examples/cpp03/http/server/http_server.exe \
examples/cpp03/http/server2/http_server.exe \
examples/cpp03/http/server3/http_server.exe \
examples/cpp03/http/server4/http_server.exe \
examples/cpp03/icmp/ping.exe \
examples/cpp03/invocation/prioritised_handlers.exe \
examples/cpp03/iostreams/daytime_client.exe \
examples/cpp03/iostreams/daytime_server.exe \
examples/cpp03/iostreams/http_client.exe \
examples/cpp03/multicast/receiver.exe \
examples/cpp03/multicast/sender.exe \
examples/cpp03/nonblocking/third_party_lib.exe \
examples/cpp03/porthopper/client.exe \
examples/cpp03/porthopper/server.exe \
examples/cpp03/services/daytime_client.exe \
examples/cpp03/socks4/sync_client.exe \
examples/cpp03/timeouts/async_tcp_client.exe \
examples/cpp03/timeouts/blocking_tcp_client.exe \
examples/cpp03/timeouts/blocking_token_tcp_client.exe \
examples/cpp03/timeouts/blocking_udp_client.exe \
examples/cpp03/timeouts/server.exe \
examples/cpp03/timers/time_t_timer.exe \
examples/cpp03/tutorial/timer1/timer.exe \
examples/cpp03/tutorial/timer2/timer.exe \
examples/cpp03/tutorial/timer3/timer.exe \
examples/cpp03/tutorial/timer4/timer.exe \
examples/cpp03/tutorial/timer5/timer.exe \
examples/cpp03/tutorial/daytime1/client.exe \
examples/cpp03/tutorial/daytime2/server.exe \
examples/cpp03/tutorial/daytime3/server.exe \
examples/cpp03/tutorial/daytime4/client.exe \
examples/cpp03/tutorial/daytime5/server.exe \
examples/cpp03/tutorial/daytime6/server.exe \
examples/cpp03/tutorial/daytime7/server.exe \
examples/cpp03/windows/transmit_file.exe
ifdef STANDALONE
all: \
$(SEPARATE_COMPILATION_LIB) \
$(UNIT_TEST_EXES)
else
all: \
$(SEPARATE_COMPILATION_LIB) \
$(PERFORMANCE_TEST_EXES) \
$(UNIT_TEST_EXES) \
$(EXAMPLE_EXES) \
$(OTHER_EXAMPLE_EXES)
endif
ifdef SEPARATE_COMPILATION
libasio.a: asio.o
ar ru libasio.a asio.o
endif
check: $(UNIT_TEST_EXES) $(addprefix run.,$(UNIT_TEST_EXES))
$(addprefix run.,$(UNIT_TEST_EXES))::
@echo === Running $(@:run.%=%) ===
@$(@:run.%=%)
@echo.
clean:
-del libasio.a asio.o
-del /q /s tests\*.exe
-del /q /s tests\*.o
-del /q /s examples\*.exe
-del /q /s examples\*.o
$(UNIT_TEST_EXES): %.exe: %.o
g++ -o$@ $(LDFLAGS) $< $(LIBS)
$(PERFORMANCE_TEST_EXES) $(EXAMPLE_EXES): %.exe: %.o
g++ -o$@ $(LDFLAGS) $< $(LIBS)
examples/cpp03/http/server/http_server.exe: \
examples/cpp03/http/server/connection.o \
examples/cpp03/http/server/connection_manager.o \
examples/cpp03/http/server/main.o \
examples/cpp03/http/server/mime_types.o \
examples/cpp03/http/server/reply.o \
examples/cpp03/http/server/request_handler.o \
examples/cpp03/http/server/request_parser.o \
examples/cpp03/http/server/server.o
g++ -o$@ $(LDFLAGS) $^ $(LIBS)
examples/cpp03/http/server2/http_server.exe: \
examples/cpp03/http/server2/connection.o \
examples/cpp03/http/server2/io_context_pool.o \
examples/cpp03/http/server2/main.o \
examples/cpp03/http/server2/mime_types.o \
examples/cpp03/http/server2/reply.o \
examples/cpp03/http/server2/request_handler.o \
examples/cpp03/http/server2/request_parser.o \
examples/cpp03/http/server2/server.o
g++ -o$@ $(LDFLAGS) $^ $(LIBS)
examples/cpp03/http/server3/http_server.exe: \
examples/cpp03/http/server3/connection.o \
examples/cpp03/http/server3/main.o \
examples/cpp03/http/server3/mime_types.o \
examples/cpp03/http/server3/reply.o \
examples/cpp03/http/server3/request_handler.o \
examples/cpp03/http/server3/request_parser.o \
examples/cpp03/http/server3/server.o
g++ -o$@ $(LDFLAGS) $^ $(LIBS)
examples/cpp03/services/daytime_client.exe: \
examples/cpp03/services/daytime_client.o \
examples/cpp03/services/logger_service.o
g++ -o$@ $(LDFLAGS) $^ $(LIBS)
.cpp.o:
g++ -o$@ -c $(CXXFLAGS) $(DEFINES) $<
+533
View File
@@ -0,0 +1,533 @@
!ifndef BOOSTDIR
BOOSTDIR = ../../boost_1_34_1
!endif
COMMON_CXXFLAGS = -nologo -EHac -GR -I. -I../include
!ifdef CXXLATEST
STD_CXXFLAGS = -std:c++latest -permissive-
!endif
!ifdef WARNINGS
WARNINGS_CXXFLAGS = -W4 -wd4512 -wd4447
!endif
!ifdef STATICRTL
! ifdef DEBUG
DEBUG_CXXFLAGS = -Zi -MTd
! else
DEBUG_CXXFLAGS = -O2 -MT
! endif
!else
! ifdef DEBUG
DEBUG_CXXFLAGS = -Zi -MDd
! else
DEBUG_CXXFLAGS = -O2 -MD
! endif
!endif
!ifdef UNICODE
UNICODE_CXXFLAGS = -DUNICODE -D_UNICODE
!endif
!ifdef TRACKING
TRACKING_CXXFLAGS = -DASIO_ENABLE_HANDLER_TRACKING
!endif
!ifndef _WIN32_WINNT
! ifdef STORE
_WIN32_WINNT=0x0603
! else
_WIN32_WINNT=0x0601
! endif
!endif
!ifdef WIN9X
DEFINES = \
-DASIO_DISABLE_IOCP \
-D_WIN32_WINNT=$(_WIN32_WINNT) \
-DBOOST_ALL_NO_LIB \
-DBOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
!else
! ifdef STORE
DEFINES = \
-DWINAPI_FAMILY=WINAPI_FAMILY_PC_APP \
-DBOOST_ALL_NO_LIB -D_WIN32_WINNT=$(_WIN32_WINNT) \
-DUNICODE -D_UNICODE \
-DBOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
! else
! ifdef WINRT
DEFINES = \
-ZW -FI SDKDDKVer.h -FI winapifamily.h -DWINAPI_FAMILY=WINAPI_PARTITION_APP \
-DBOOST_ALL_NO_LIB \
-DBOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
! else
DEFINES = \
-D_WIN32_WINNT=$(_WIN32_WINNT) \
-DBOOST_ALL_NO_LIB \
-DBOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
! endif
! endif
!endif
!ifdef SEPARATE_COMPILATION
LIBS = asio.lib
SEPARATE_COMPILATION_CXXFLAGS = \
-DASIO_SEPARATE_COMPILATION \
-DASIO_ENABLE_CANCELIO
!endif
!ifdef STANDALONE
STANDALONE_CXXFLAGS = -DASIO_STANDALONE
!else
STANDALONE_CXXFLAGS = -I$(BOOSTDIR) -DASIO_ENABLE_BOOST
!endif
CXXFLAGS = \
$(COMMON_CXXFLAGS) \
$(STD_CXXFLAGS) \
$(WARNINGS_CXXFLAGS) \
$(DEBUG_CXXFLAGS) \
$(UNICODE_CXXFLAGS) \
$(TRACKING_CXXFLAGS) \
$(SEPARATE_COMPILATION_CXXFLAGS) \
$(STANDALONE_CXXFLAGS)
!ifndef SSLDIR
SSLDIR = ../../openssl-0.9.8g
!endif
SSL_CXXFLAGS = -I$(SSLDIR)/inc32
SSL_LIBS = \
$(SSLDIR)/out32/libeay32.lib \
$(SSLDIR)/out32/ssleay32.lib \
user32.lib advapi32.lib gdi32.lib
LATENCY_TEST_EXES = \
tests\latency\tcp_client.exe \
tests\latency\tcp_server.exe \
tests\latency\udp_client.exe \
tests\latency\udp_server.exe
PERFORMANCE_TEST_EXES = \
tests\performance\client.exe \
tests\performance\server.exe
UNIT_TEST_EXES = \
tests\unit\associated_allocator.exe \
tests\unit\associated_executor.exe \
tests\unit\async_result.exe \
tests\unit\awaitable.exe \
tests\unit\basic_datagram_socket.exe \
tests\unit\basic_deadline_timer.exe \
tests\unit\basic_raw_socket.exe \
tests\unit\basic_seq_packet_socket.exe \
tests\unit\basic_serial_port.exe \
tests\unit\basic_signal_set.exe \
tests\unit\basic_socket.exe \
tests\unit\basic_socket_acceptor.exe \
tests\unit\basic_stream_socket.exe \
tests\unit\basic_streambuf.exe \
tests\unit\basic_waitable_timer.exe \
tests\unit\bind_executor.exe \
tests\unit\buffered_read_stream.exe \
tests\unit\buffered_stream.exe \
tests\unit\buffered_write_stream.exe \
tests\unit\buffer.exe \
tests\unit\buffers_iterator.exe \
tests\unit\co_spawn.exe \
tests\unit\completion_condition.exe \
tests\unit\compose.exe \
tests\unit\connect.exe \
tests\unit\coroutine.exe \
tests\unit\deadline_timer.exe \
tests\unit\defer.exe \
tests\unit\detached.exe \
tests\unit\dispatch.exe \
tests\unit\error.exe \
tests\unit\execution_context.exe \
tests\unit\execution\any_executor.exe \
tests\unit\execution\blocking.exe \
tests\unit\execution\blocking_adaptation.exe \
tests\unit\execution\bulk_execute.exe \
tests\unit\execution\bulk_guarantee.exe \
tests\unit\execution\connect.exe \
tests\unit\execution\context_as.exe \
tests\unit\execution\execute.exe \
tests\unit\execution\executor.exe \
tests\unit\execution\invocable_archetype.exe \
tests\unit\execution\mapping.exe \
tests\unit\execution\operation_state.exe \
tests\unit\execution\outstanding_work.exe \
tests\unit\execution\prefer_only.exe \
tests\unit\execution\receiver.exe \
tests\unit\execution\relationship.exe \
tests\unit\execution\schedule.exe \
tests\unit\execution\scheduler.exe \
tests\unit\execution\sender.exe \
tests\unit\execution\set_done.exe \
tests\unit\execution\set_error.exe \
tests\unit\execution\set_value.exe \
tests\unit\execution\start.exe \
tests\unit\execution\submit.exe \
tests\unit\executor.exe \
tests\unit\executor_work_guard.exe \
tests\unit\generic\basic_endpoint.exe \
tests\unit\generic\datagram_protocol.exe \
tests\unit\generic\raw_protocol.exe \
tests\unit\generic\seq_packet_protocol.exe \
tests\unit\generic\stream_protocol.exe \
tests\unit\high_resolution_timer.exe \
tests\unit\io_context.exe \
tests\unit\io_context_strand.exe \
tests\unit\ip\address.exe \
tests\unit\ip\address_v4.exe \
tests\unit\ip\address_v4_iterator.exe \
tests\unit\ip\address_v4_range.exe \
tests\unit\ip\address_v6.exe \
tests\unit\ip\address_v6_iterator.exe \
tests\unit\ip\address_v6_range.exe \
tests\unit\ip\basic_endpoint.exe \
tests\unit\ip\basic_resolver.exe \
tests\unit\ip\basic_resolver_entry.exe \
tests\unit\ip\basic_resolver_iterator.exe \
tests\unit\ip\basic_resolver_query.exe \
tests\unit\ip\host_name.exe \
tests\unit\ip\icmp.exe \
tests\unit\ip\multicast.exe \
tests\unit\ip\network_v4.exe \
tests\unit\ip\network_v6.exe \
tests\unit\ip\resolver_query_base.exe \
tests\unit\ip\tcp.exe \
tests\unit\ip\udp.exe \
tests\unit\ip\unicast.exe \
tests\unit\ip\v6_only.exe \
tests\unit\local\basic_endpoint.exe \
tests\unit\local\connect_pair.exe \
tests\unit\local\datagram_protocol.exe \
tests\unit\local\stream_protocol.exe \
tests\unit\is_read_buffered.exe \
tests\unit\is_write_buffered.exe \
tests\unit\packaged_task.exe \
tests\unit\placeholders.exe \
tests\unit\post.exe \
tests\unit\read.exe \
tests\unit\read_at.exe \
tests\unit\read_until.exe \
tests\unit\redirect_error.exe \
tests\unit\serial_port.exe \
tests\unit\serial_port_base.exe \
tests\unit\signal_set.exe \
tests\unit\socket_base.exe \
tests\unit\static_thread_pool.exe \
tests\unit\steady_timer.exe \
tests\unit\strand.exe \
tests\unit\streambuf.exe \
tests\unit\system_context.exe \
tests\unit\system_executor.exe \
tests\unit\system_timer.exe \
tests\unit\this_coro.exe \
tests\unit\thread.exe \
tests\unit\thread_pool.exe \
tests\unit\time_traits.exe \
tests\unit\ts\buffer.exe \
tests\unit\ts\executor.exe \
tests\unit\ts\internet.exe \
tests\unit\ts\io_context.exe \
tests\unit\ts\net.exe \
tests\unit\ts\netfwd.exe \
tests\unit\ts\socket.exe \
tests\unit\ts\timer.exe \
tests\unit\use_awaitable.exe \
tests\unit\use_future.exe \
tests\unit\uses_executor.exe \
tests\unit\wait_traits.exe \
tests\unit\windows\basic_object_handle.exe \
tests\unit\windows\basic_overlapped_handle.exe \
tests\unit\windows\basic_random_access_handle.exe \
tests\unit\windows\basic_stream_handle.exe \
tests\unit\windows\object_handle.exe \
tests\unit\windows\overlapped_handle.exe \
tests\unit\windows\overlapped_ptr.exe \
tests\unit\windows\random_access_handle.exe \
tests\unit\windows\stream_handle.exe \
tests\unit\write.exe \
tests\unit\write_at.exe
CPP03_EXAMPLE_EXES = \
examples\cpp03\allocation\server.exe \
examples\cpp03\buffers\reference_counted.exe \
examples\cpp03\chat\chat_client.exe \
examples\cpp03\chat\chat_server.exe \
examples\cpp03\echo\async_tcp_echo_server.exe \
examples\cpp03\echo\async_udp_echo_server.exe \
examples\cpp03\echo\blocking_tcp_echo_client.exe \
examples\cpp03\echo\blocking_tcp_echo_server.exe \
examples\cpp03\echo\blocking_udp_echo_client.exe \
examples\cpp03\echo\blocking_udp_echo_server.exe \
examples\cpp03\http\client\async_client.exe \
examples\cpp03\http\client\sync_client.exe \
examples\cpp03\http\server\http_server.exe \
examples\cpp03\http\server2\http_server.exe \
examples\cpp03\http\server3\http_server.exe \
examples\cpp03\http\server4\http_server.exe \
examples\cpp03\icmp\ping.exe \
examples\cpp03\invocation\prioritised_handlers.exe \
examples\cpp03\iostreams\daytime_client.exe \
examples\cpp03\iostreams\daytime_server.exe \
examples\cpp03\iostreams\http_client.exe \
examples\cpp03\multicast\receiver.exe \
examples\cpp03\multicast\sender.exe \
examples\cpp03\nonblocking\third_party_lib.exe \
examples\cpp03\porthopper\client.exe \
examples\cpp03\porthopper\server.exe \
examples\cpp03\services\daytime_client.exe \
examples\cpp03\socks4\sync_client.exe \
examples\cpp03\timeouts\async_tcp_client.exe \
examples\cpp03\timeouts\blocking_tcp_client.exe \
examples\cpp03\timeouts\blocking_token_tcp_client.exe \
examples\cpp03\timeouts\blocking_udp_client.exe \
examples\cpp03\timeouts\server.exe \
examples\cpp03\timers\time_t_timer.exe \
examples\cpp03\tutorial\timer1\timer.exe \
examples\cpp03\tutorial\timer2\timer.exe \
examples\cpp03\tutorial\timer3\timer.exe \
examples\cpp03\tutorial\timer4\timer.exe \
examples\cpp03\tutorial\timer5\timer.exe \
examples\cpp03\tutorial\daytime1\client.exe \
examples\cpp03\tutorial\daytime2\server.exe \
examples\cpp03\tutorial\daytime3\server.exe \
examples\cpp03\tutorial\daytime4\client.exe \
examples\cpp03\tutorial\daytime5\server.exe \
examples\cpp03\tutorial\daytime6\server.exe \
examples\cpp03\tutorial\daytime7\server.exe \
examples\cpp03\windows\transmit_file.exe
SSL_UNIT_TEST_EXES = \
tests\unit\ssl\basic_context.exe \
tests\unit\ssl\context.exe \
tests\unit\ssl\context_base.exe \
tests\unit\ssl\context_service.exe \
tests\unit\ssl\rfc2818_verification.exe \
tests\unit\ssl\stream.exe \
tests\unit\ssl\stream_base.exe \
tests\unit\ssl\stream_service.exe
SSL_EXAMPLE_EXES = \
examples\cpp03\ssl\client.exe \
examples\cpp03\ssl\server.exe
!ifdef SEPARATE_COMPILATION
all: asio.lib
asio.lib: asio.cpp
cl -Fe$@ -Foasio.obj $(CXXFLAGS) $(DEFINES) -c asio.cpp
lib -name:asio.lib asio.obj
!endif
!ifdef STANDALONE
all: \
$(UNIT_TEST_EXES)
!else
all: \
$(LATENCY_TEST_EXES) \
$(PERFORMANCE_TEST_EXES) \
$(UNIT_TEST_EXES) \
$(CPP03_EXAMPLE_EXES)
!endif
ssl: \
$(SSL_UNIT_TEST_EXES) \
$(SSL_EXAMPLE_EXES)
check: $(UNIT_TEST_EXES)
!@echo === Running $** === && $** && echo.
{tests\latency}.cpp{tests\latency}.exe:
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< $(LIBS) -link -opt:ref
{tests\performance}.cpp{tests\performance}.exe:
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< $(LIBS) -link -opt:ref
tests\unit\unit_test.obj: tests\unit\unit_test.cpp
cl -Fe$@ -Fotests\unit\unit_test.obj $(CXXFLAGS) $(DEFINES) -c tests\unit\unit_test.cpp
{tests\unit}.cpp{tests\unit}.exe:
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< $(LIBS) -link -opt:ref
{tests\unit\execution}.cpp{tests\unit\execution}.exe:
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< $(LIBS) -link -opt:ref
{tests\unit\generic}.cpp{tests\unit\generic}.exe:
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< $(LIBS) -link -opt:ref
{tests\unit\ip}.cpp{tests\unit\ip}.exe:
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< $(LIBS) -link -opt:ref
{tests\unit\local}.cpp{tests\unit\local}.exe:
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< $(LIBS) -link -opt:ref
{tests\unit\ssl}.cpp{tests\unit\ssl}.exe:
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(SSL_CXXFLAGS) $(DEFINES) $< $(SSL_LIBS) $(LIBS) -link -opt:ref
{tests\unit\ts}.cpp{tests\unit\ts}.exe:
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< $(LIBS) -link -opt:ref
{tests\unit\windows}.cpp{tests\unit\windows}.exe:
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< $(LIBS) -link -opt:ref
{examples\cpp03\allocation}.cpp{examples\cpp03\allocation}.exe:
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< $(LIBS) -link -opt:ref
{examples\cpp03\buffers}.cpp{examples\cpp03\buffers}.exe:
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< $(LIBS) -link -opt:ref
{examples\cpp03\chat}.cpp{examples\cpp03\chat}.exe:
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< $(LIBS) -link -opt:ref
{examples\cpp03\echo}.cpp{examples\cpp03\echo}.exe:
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< $(LIBS) -link -opt:ref
{examples\cpp03\http\client}.cpp{examples\cpp03\http\client}.exe:
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< $(LIBS) -link -opt:ref
{examples\cpp03\icmp}.cpp{examples\cpp03\icmp}.exe:
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< $(LIBS) -link -opt:ref
{examples\cpp03\invocation}.cpp{examples\cpp03\invocation}.exe:
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< $(LIBS) -link -opt:ref
{examples\cpp03\iostreams}.cpp{examples\cpp03\iostreams}.exe:
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< $(LIBS) -link -opt:ref
{examples\cpp03\multicast}.cpp{examples\cpp03\multicast}.exe:
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< $(LIBS) -link -opt:ref
{examples\cpp03\nonblocking}.cpp{examples\cpp03\nonblocking}.exe:
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< $(LIBS) -link -opt:ref
{examples\cpp03\porthopper}.cpp{examples\cpp03\porthopper}.exe:
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< $(LIBS) -link -opt:ref
{examples\cpp03\socks4}.cpp{examples\cpp03\socks4}.exe:
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< $(LIBS) -link -opt:ref
{examples\cpp03\ssl}.cpp{examples\cpp03\ssl}.exe:
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(SSL_CXXFLAGS) $(DEFINES) $< $(SSL_LIBS) $(LIBS) -link -opt:ref
{examples\cpp03\timeouts}.cpp{examples\cpp03\timeouts}.exe:
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< $(LIBS) -link -opt:ref
{examples\cpp03\timers}.cpp{examples\cpp03\timers}.exe:
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< $(LIBS) -link -opt:ref
{examples\cpp03\tutorial\timer1}.cpp{examples\cpp03\tutorial\timer1}.exe:
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< $(LIBS) -link -opt:ref
{examples\cpp03\tutorial\timer2}.cpp{examples\cpp03\tutorial\timer2}.exe:
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< $(LIBS) -link -opt:ref
{examples\cpp03\tutorial\timer3}.cpp{examples\cpp03\tutorial\timer3}.exe:
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< $(LIBS) -link -opt:ref
{examples\cpp03\tutorial\timer4}.cpp{examples\cpp03\tutorial\timer4}.exe:
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< $(LIBS) -link -opt:ref
{examples\cpp03\tutorial\timer5}.cpp{examples\cpp03\tutorial\timer5}.exe:
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< $(LIBS) -link -opt:ref
{examples\cpp03\tutorial\daytime1}.cpp{examples\cpp03\tutorial\daytime1}.exe:
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< $(LIBS) -link -opt:ref
{examples\cpp03\tutorial\daytime2}.cpp{examples\cpp03\tutorial\daytime2}.exe:
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< $(LIBS) -link -opt:ref
{examples\cpp03\tutorial\daytime3}.cpp{examples\cpp03\tutorial\daytime3}.exe:
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< $(LIBS) -link -opt:ref
{examples\cpp03\tutorial\daytime4}.cpp{examples\cpp03\tutorial\daytime4}.exe:
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< $(LIBS) -link -opt:ref
{examples\cpp03\tutorial\daytime5}.cpp{examples\cpp03\tutorial\daytime5}.exe:
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< $(LIBS) -link -opt:ref
{examples\cpp03\tutorial\daytime6}.cpp{examples\cpp03\tutorial\daytime6}.exe:
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< $(LIBS) -link -opt:ref
{examples\cpp03\tutorial\daytime7}.cpp{examples\cpp03\tutorial\daytime7}.exe:
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< $(LIBS) -link -opt:ref
{examples\cpp03\windows}.cpp{examples\cpp03\windows}.exe:
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< $(LIBS) -link -opt:ref
{examples\cpp11\executors}.cpp{examples\cpp11\executors}.exe:
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< $(LIBS) -link -opt:ref
{examples\cpp11\operations}.cpp{examples\cpp11\operations}.exe:
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< $(LIBS) -link -opt:ref
{examples\cpp14\operations}.cpp{examples\cpp14\operations}.exe:
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< $(LIBS) -link -opt:ref
examples\cpp03\http\server\http_server.exe: \
examples\cpp03\http\server\connection.cpp \
examples\cpp03\http\server\connection_manager.cpp \
examples\cpp03\http\server\main.cpp \
examples\cpp03\http\server\mime_types.cpp \
examples\cpp03\http\server\reply.cpp \
examples\cpp03\http\server\request_handler.cpp \
examples\cpp03\http\server\request_parser.cpp \
examples\cpp03\http\server\server.cpp
cl -Fe$@ -Foexamples\cpp03\http\server\ $(CXXFLAGS) $(DEFINES) $** $(LIBS) -link -opt:ref
examples\cpp03\http\server2\http_server.exe: \
examples\cpp03\http\server2\connection.cpp \
examples\cpp03\http\server2\io_context_pool.cpp \
examples\cpp03\http\server2\main.cpp \
examples\cpp03\http\server2\mime_types.cpp \
examples\cpp03\http\server2\reply.cpp \
examples\cpp03\http\server2\request_handler.cpp \
examples\cpp03\http\server2\request_parser.cpp \
examples\cpp03\http\server2\server.cpp
cl -Fe$@ -Foexamples\cpp03\http\server2\ $(CXXFLAGS) $(DEFINES) $** $(LIBS) -link -opt:ref
examples\cpp03\http\server3\http_server.exe: \
examples\cpp03\http\server3\connection.cpp \
examples\cpp03\http\server3\main.cpp \
examples\cpp03\http\server3\mime_types.cpp \
examples\cpp03\http\server3\reply.cpp \
examples\cpp03\http\server3\request_handler.cpp \
examples\cpp03\http\server3\request_parser.cpp \
examples\cpp03\http\server3\server.cpp
cl -Fe$@ -Foexamples\cpp03\http\server3\ $(CXXFLAGS) $(DEFINES) $** $(LIBS) -link -opt:ref
examples\cpp03\http\server4\http_server.exe: \
examples\cpp03\http\server4\file_handler.cpp \
examples\cpp03\http\server4\main.cpp \
examples\cpp03\http\server4\mime_types.cpp \
examples\cpp03\http\server4\reply.cpp \
examples\cpp03\http\server4\request_parser.cpp \
examples\cpp03\http\server4\server.cpp
cl -Fe$@ -Foexamples\cpp03\http\server4\ $(CXXFLAGS) $(DEFINES) $** $(LIBS) -link -opt:ref
examples\cpp03\services\daytime_client.exe: \
examples\cpp03\services\daytime_client.cpp \
examples\cpp03\services\logger_service.cpp
cl -Fe$@ -Foexamples\cpp03\services\ $(CXXFLAGS) $(DEFINES) $** $(LIBS) -link -opt:ref
clean:
-del /q /s asio.lib
-del /q /s asio.obj
-del /q /s tests\*.exe
-del /q /s tests\*.exe.manifest
-del /q /s tests\*.exp
-del /q /s tests\*.ilk
-del /q /s tests\*.pdb
-del /q /s tests\*.obj
-del /q /s examples\*.exe
-del /q /s examples\*.exe.manifest
-del /q /s examples\*.exp
-del /q /s examples\*.ilk
-del /q /s examples\*.pdb
-del /q /s examples\*.obj
-del /q /s *.pdb
+11
View File
@@ -0,0 +1,11 @@
//
// asio.cpp
// ~~~~~~~~
//
// Copyright (c) 2003-2021 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#include "asio/impl/src.hpp"
+11
View File
@@ -0,0 +1,11 @@
//
// asio_ssl.cpp
// ~~~~~~~~~~~~
//
// Copyright (c) 2003-2021 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#include "asio/ssl/impl/src.hpp"
+89
View File
@@ -0,0 +1,89 @@
#!/usr/bin/perl -w
#
# handlerlive.pl
# ~~~~~~~~~~~~~~
#
# A tool for post-processing the debug output generated by Asio-based programs
# to print a list of "live" handlers. These are handlers that are associated
# with operations that have not yet completed, or running handlers that have
# not yet finished their execution. Programs write this output to the standard
# error stream when compiled with the define `ASIO_ENABLE_HANDLER_TRACKING'.
#
# Copyright (c) 2003-2021 Christopher M. Kohlhoff (chris at kohlhoff dot com)
#
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#
use strict;
my %pending_handlers = ();
my %running_handlers = ();
#-------------------------------------------------------------------------------
# Parse the debugging output and update the set of pending handlers.
sub parse_debug_output()
{
while (my $line = <>)
{
chomp($line);
if ($line =~ /\@asio\|([^|]*)\|([^|]*)\|(.*)$/)
{
my $action = $2;
# Handler creation.
if ($action =~ /^([0-9]+)\*([0-9]+)$/)
{
$pending_handlers{$2} = 1;
}
# Begin handler invocation.
elsif ($action =~ /^>([0-9]+)$/)
{
delete($pending_handlers{$1});
$running_handlers{$1} = 1;
}
# End handler invocation.
elsif ($action =~ /^<([0-9]+)$/)
{
delete($running_handlers{$1});
}
# Handler threw exception.
elsif ($action =~ /^!([0-9]+)$/)
{
delete($running_handlers{$1});
}
# Handler was destroyed without being invoked.
elsif ($action =~ /^~([0-9]+)$/)
{
delete($pending_handlers{$1});
}
}
}
}
#-------------------------------------------------------------------------------
# Print a list of incompleted handers, on a single line delimited by spaces.
sub print_handlers($)
{
my $handlers = shift;
my $prefix = "";
foreach my $handler (sort { $a <=> $b } keys %{$handlers})
{
print("$prefix$handler");
$prefix = " ";
}
print("\n") if ($prefix ne "");
}
#-------------------------------------------------------------------------------
parse_debug_output();
print_handlers(\%running_handlers);
print_handlers(\%pending_handlers);
+140
View File
@@ -0,0 +1,140 @@
#!/usr/bin/perl -w
#
# handlertree.pl
# ~~~~~~~~~~~~~~
# A tool for post-processing the debug output generated by Asio-based programs
# to print the tree of handlers that resulted in some specified handler ids.
# Programs write this output to the standard error stream when compiled with
# the define `ASIO_ENABLE_HANDLER_TRACKING'.
#
# Copyright (c) 2003-2021 Christopher M. Kohlhoff (chris at kohlhoff dot com)
#
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#
use strict;
my %target_handlers = ();
my @cached_output = ();
my %outstanding_handlers = ();
my %running_handlers = ();
#-------------------------------------------------------------------------------
# Build the initial list of target handlers from the command line arguments.
sub build_initial_target_handlers()
{
for my $handler (@ARGV)
{
$target_handlers{$handler} = 1;
}
}
#-------------------------------------------------------------------------------
# Parse the debugging output and cache the handler tracking lines.
sub parse_debug_output()
{
while (my $line = <STDIN>)
{
chomp($line);
if ($line =~ /\@asio\|([^|]*)\|([^|]*)\|(.*)$/)
{
push(@cached_output, $line);
}
}
}
#-------------------------------------------------------------------------------
# Iterate over the cached output in revese and build a hash of all target
# handlers' ancestors.
sub build_target_handler_tree()
{
my $i = scalar(@cached_output) - 1;
while ($i >= 0)
{
my $line = $cached_output[$i];
if ($line =~ /\@asio\|([^|]*)\|([^|]*)\|(.*)$/)
{
my $action = $2;
# Handler creation.
if ($action =~ /^([0-9]+)\*([0-9]+)$/)
{
if ($1 ne "0" and exists($target_handlers{$2}))
{
$target_handlers{$1} = 1;
}
}
}
--$i;
}
}
#-------------------------------------------------------------------------------
# Print out all handler tracking records associated with the target handlers.
sub print_target_handler_records()
{
for my $line (@cached_output)
{
if ($line =~ /\@asio\|([^|]*)\|([^|]*)\|(.*)$/)
{
my $action = $2;
# Handler location.
if ($action =~ /^([0-9]+)\^([0-9]+)$/)
{
print("$line\n") if ($1 eq "0" or exists($target_handlers{$1})) and exists($target_handlers{$2});
}
# Handler creation.
if ($action =~ /^([0-9]+)\*([0-9]+)$/)
{
print("$1, $2, $line\n") if ($1 eq "0" or exists($target_handlers{$1})) and exists($target_handlers{$2});
}
# Begin handler invocation.
elsif ($action =~ /^>([0-9]+)$/)
{
print("$line\n") if (exists($target_handlers{$1}));
}
# End handler invocation.
elsif ($action =~ /^<([0-9]+)$/)
{
print("$line\n") if (exists($target_handlers{$1}));
}
# Handler threw exception.
elsif ($action =~ /^!([0-9]+)$/)
{
print("$line\n") if (exists($target_handlers{$1}));
}
# Handler was destroyed without being invoked.
elsif ($action =~ /^~([0-9]+)$/)
{
print("$line\n") if (exists($target_handlers{$1}));
}
# Operation associated with a handler.
elsif ($action =~ /^\.([0-9]+)$/)
{
print("$line\n") if (exists($target_handlers{$1}));
}
}
}
}
#-------------------------------------------------------------------------------
build_initial_target_handlers();
parse_debug_output();
build_target_handler_tree();
print_target_handler_records();
+375
View File
@@ -0,0 +1,375 @@
#!/usr/bin/perl -w
#
# handlerviz.pl
# ~~~~~~~~~~~~~
#
# A visualisation tool for post-processing the debug output generated by
# Asio-based programs. Programs write this output to the standard error stream
# when compiled with the define `ASIO_ENABLE_HANDLER_TRACKING'.
#
# This tool generates output intended for use with the GraphViz tool `dot'. For
# example, to convert output to a PNG image, use:
#
# perl handlerviz.pl < output.txt | dot -Tpng > output.png
#
# To convert to a PDF file, use:
#
# perl handlerviz.pl < output.txt | dot -Tpdf > output.pdf
#
# Copyright (c) 2003-2021 Christopher M. Kohlhoff (chris at kohlhoff dot com)
#
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#
use strict;
my %nodes = ();
my @edges = ();
my %locations = ();
my %anon_nodes = ();
my $anon_id = 0;
my %all_nodes = ();
my %pending_nodes = ();
#-------------------------------------------------------------------------------
# Parse the debugging output and populate the nodes and edges.
sub parse_debug_output()
{
while (my $line = <>)
{
chomp($line);
if ($line =~ /\@asio\|([^|]*)\|([^|]*)\|(.*)$/)
{
my $timestamp = $1;
my $action = $2;
my $description = $3;
# Handler creation.
if ($action =~ /^([0-9]+)\*([0-9]+)$/)
{
my $begin = $1;
my $end = $2;
my $label = $description;
$label =~ s/\./\\n/g;
if ($begin eq "0")
{
$begin = "a" . $anon_id++;
$anon_nodes{$begin} = $timestamp;
$all_nodes{"$timestamp-$begin"} = $begin;
}
my %edge = ( begin=>$begin, end=>$end, label=>$label );
push(@edges, \%edge);
$pending_nodes{$end} = 1;
}
# Handler location.
elsif ($action =~ /^([0-9]+)\^([0-9]+)$/)
{
if ($1 ne "0")
{
if (not exists($locations{($1,$2)}))
{
$locations{($1,$2)} = ();
}
push(@{$locations{($1,$2)}}, $description);
}
}
# Begin handler invocation.
elsif ($action =~ /^>([0-9]+)$/)
{
my %new_node = ( label=>$description, entry=>$timestamp );
$new_node{content} = ();
$nodes{$1} = \%new_node;
$all_nodes{"$timestamp-$1"} = $1;
delete($pending_nodes{$1});
}
# End handler invocation.
elsif ($action =~ /^<([0-9]+)$/)
{
$nodes{$1}->{exit} = $timestamp;
}
# Handler threw exception.
elsif ($action =~ /^!([0-9]+)$/)
{
push(@{$nodes{$1}->{content}}, "exception");
}
# Handler was destroyed without being invoked.
elsif ($action =~ /^~([0-9]+)$/)
{
my %new_node = ( label=>"$timestamp destroyed" );
$new_node{content} = ();
$nodes{$1} = \%new_node;
$all_nodes{"$timestamp-$1"} = $1;
delete($pending_nodes{$1});
}
# Handler performed some operation.
elsif ($action =~ /^([0-9]+)$/)
{
if ($1 eq "0")
{
my $id = "a" . $anon_id++;
$anon_nodes{$id} = "$timestamp\\l$description";
$all_nodes{"$timestamp-$id"} = $id;
}
else
{
push(@{$nodes{$1}->{content}}, "$description");
}
}
}
}
}
#-------------------------------------------------------------------------------
# Helper function to convert a string to escaped HTML text.
sub escape($)
{
my $text = shift;
$text =~ s/&/\&amp\;/g;
$text =~ s/</\&lt\;/g;
$text =~ s/>/\&gt\;/g;
$text =~ s/\t/ /g;
return $text;
}
#-------------------------------------------------------------------------------
# Templates for dot output.
my $graph_header = <<"EOF";
/* Generated by handlerviz.pl */
digraph "handlerviz output"
{
graph [ nodesep="1" ];
node [ shape="box", fontsize="9" ];
edge [ arrowtail="dot", fontsize="9" ];
EOF
my $graph_footer = <<"EOF";
}
EOF
my $node_header = <<"EOF";
"%name%"
[
label=<<table border="0" cellspacing="0">
<tr><td align="left" bgcolor="gray" border="0">%label%</td></tr>
EOF
my $node_footer = <<"EOF";
</table>>
]
EOF
my $node_content = <<"EOF";
<tr><td align="left" bgcolor="white" border="0">
<font face="mono" point-size="9">%content%</font>
</td></tr>
EOF
my $anon_nodes_header = <<"EOF";
{
node [ shape="record" ];
EOF
my $anon_nodes_footer = <<"EOF";
}
EOF
my $anon_node = <<"EOF";
"%name%" [ label="%label%", color="gray" ];
EOF
my $pending_nodes_header = <<"EOF";
{
node [ shape="record", color="red" ];
rank = "max";
EOF
my $pending_nodes_footer = <<"EOF";
}
EOF
my $pending_node = <<"EOF";
"%name%";
EOF
my $edges_header = <<"EOF";
{
edge [ style="dashed", arrowhead="open" ];
EOF
my $edges_footer = <<"EOF";
}
EOF
my $edge = <<"EOF";
"%begin%" -> "%end%" [ label="%label%", labeltooltip="%tooltip%" ]
EOF
my $node_order_header = <<"EOF";
{
node [ style="invisible" ];
edge [ style="invis", weight="100" ];
EOF
my $node_order_footer = <<"EOF";
}
EOF
my $node_order = <<"EOF";
{
rank="same"
"%begin%";
"o%begin%";
}
"o%begin%" -> "o%end%";
EOF
#-------------------------------------------------------------------------------
# Generate dot output from the nodes and edges.
sub print_nodes()
{
foreach my $name (sort keys %nodes)
{
my $node = $nodes{$name};
my $entry = $node->{entry};
my $exit = $node->{exit};
my $label = escape($node->{label});
my $header = $node_header;
$header =~ s/%name%/$name/g;
$header =~ s/%label%/$label/g;
print($header);
if (defined($exit) and defined($entry))
{
my $line = $node_content;
my $content = $entry . " + " . sprintf("%.6f", $exit - $entry) . "s";
$line =~ s/%content%/$content/g;
print($line);
}
foreach my $content (@{$node->{content}})
{
$content = escape($content);
$content = " " if length($content) == 0;
my $line = $node_content;
$line =~ s/%content%/$content/g;
print($line);
}
print($node_footer);
}
}
sub print_anon_nodes()
{
print($anon_nodes_header);
foreach my $name (sort keys %anon_nodes)
{
my $label = $anon_nodes{$name};
my $line = $anon_node;
$line =~ s/%name%/$name/g;
$line =~ s/%label%/$label/g;
print($line);
}
print($anon_nodes_footer);
}
sub print_pending_nodes()
{
print($pending_nodes_header);
foreach my $name (sort keys %pending_nodes)
{
my $line = $pending_node;
$line =~ s/%name%/$name/g;
print($line);
}
print($pending_nodes_footer);
}
sub print_edges()
{
print($edges_header);
foreach my $e (@edges)
{
my $begin = $e->{begin};
my $end = $e->{end};
my $label = $e->{label};
my $tooltip = "";
if (exists($locations{($begin,$end)}))
{
for my $line (@{$locations{($begin,$end)}})
{
$tooltip = $tooltip . escape($line) . "\n";
}
}
my $line = $edge;
$line =~ s/%begin%/$begin/g;
$line =~ s/%end%/$end/g;
$line =~ s/%label%/$label/g;
$line =~ s/%tooltip%/$tooltip/g;
print($line);
}
print($edges_footer);
}
sub print_node_order()
{
my $prev = "";
print($node_order_header);
foreach my $name (sort keys %all_nodes)
{
if ($prev ne "")
{
my $begin = $prev;
my $end = $all_nodes{$name};
my $line = $node_order;
$line =~ s/%begin%/$begin/g;
$line =~ s/%end%/$end/g;
print($line);
}
$prev = $all_nodes{$name};
}
foreach my $name (sort keys %pending_nodes)
{
if ($prev ne "")
{
my $begin = $prev;
my $line = $node_order;
$line =~ s/%begin%/$begin/g;
$line =~ s/%end%/$name/g;
print($line);
}
last;
}
print($node_order_footer);
}
sub generate_dot()
{
print($graph_header);
print_nodes();
print_anon_nodes();
print_pending_nodes();
print_edges();
print_node_order();
print($graph_footer);
}
#-------------------------------------------------------------------------------
parse_debug_output();
generate_dot();