Commit Graph

23 Commits

Author SHA1 Message Date
Werner Koch
7d1159c1e9
core: Avoid printf format warnings due to gpgme_ssize_t.
* src/debug.h (_trace_sysres_ssize_t): Cast arg.
2023-04-17 15:05:22 +02:00
Ingo Klöcker
7cfc93193d core: Fix results returned by gpgme_data_* functions
src/debug.h (TRACE_SYSRES_OFF_T, _trace_sysres_off_t,
TRACE_SYSRES_SSIZE_T, _trace_sysres_ssize_t): New.
src/data.c (gpgme_data_read, gpgme_data_write, gpgme_data_seek): Use
appropriate new tracing macros instead of casting the results to int.
--

This change adds tracing macros for results of system functions of
type __off_t and __ssize_t.

GnuPG-bug-id: 5481
2021-08-03 12:13:27 +02:00
Werner Koch
0f68c9f16b
core: Prettify _gpgme_io_select debug output again and fix TRACE_SYSRES.
* src/debug.c (_gpgme_debug): Take better care of NULL userinfo.
(_gpgme_debug_end): Rework.
(_trace_sysres): Print ERRNO and not the supplied RES.
--

The TRACE_SYSRES patch fixes
Regression-due-to: 7a1e7006d0

Signed-off-by: Werner Koch <wk@gnupg.org>
2019-06-05 16:48:47 +02:00
Werner Koch
8f9f3224aa
core: Improve the debug messages even more.
* src/debug.c (_gpgme_debug): Add arg LINE.  Chnage all callers.
(_gpgme_debug_begin): Remove.
* src/debug.h (TRACE_SEQ): Use the LINE arg of _gpgme_debug.
--

This includes chnages to always print fds in decimal as weel as
tweaking the TARCE_SEQ function to make use of the new machinery.

The standard 'tag' can now always be NULL and no tag information will
be printed.

Signed-off-by: Werner Koch <wk@gnupg.org>
2019-06-05 15:54:55 +02:00
Werner Koch
7a1e7006d0
core: Protect the trace macros for fun and profit.
* src/debug.h: Protect macros using.
(_trace_err, _trace_sysres, _trace_syserr): New helper inline
functions.

Signed-off-by: Werner Koch <wk@gnupg.org>
2018-11-16 18:17:22 +01:00
Werner Koch
94d274a1a3
core: Remove old debug helper function
* src/debug.c (_gpgme_debug): Remove.
(_gpgme_debugf): Rename to _gpgme_debug.

Signed-off-by: Werner Koch <wk@gnupg.org>
2018-11-16 16:39:26 +01:00
Werner Koch
5857491a2a
core: Simplify the trace maros by using variadics.
* src/debug.h (TRACE_BEG, TRACE_LOG, TRACE_SUC): Use variadic macros
and remove the TRACE_BEG1 et al.  Change all users to always pass a
format string.
(TRACE): Ditto.
* src/debug.c (_gpgme_debugf): New.
* configure.ac <GCC>: Add -Wno-format-zero-length.
--

This makes it easier for use to enable format checks.  The zero-length
format is required to allow for an empty format due to the comman
problematic of __VA_ARGS__.

Signed-off-by: Werner Koch <wk@gnupg.org>
2018-11-16 16:25:49 +01:00
Werner Koch
5262ce0c81
w32: Fix a few compiler warnings.
* src/debug.h (TRACE_SYSERR_NR): New.
* src/w32-io.c: Fix compiler warnings.

Signed-off-by: Werner Koch <wk@gnupg.org>
2018-11-02 12:54:22 +01:00
Werner Koch
337c108255
core: Print a dump of the I/O data only at level 8.
* src/debug.h (TRACE_SUC3): New.
(TRACE_LOGBUFX): New.
* src/posix-io.c: Use TRACE_LOGBUFX instead of TRACE_LOGBUF.
* src/w32-glib-io.c: Ditto.
--

This will also be changed for w32-io as part of another commit.

Signed-off-by: Werner Koch <wk@gnupg.org>
2018-11-02 09:03:43 +01:00
Werner Koch
3c04dea3ec
w32: Remove all support for WindowsCE
* configure.ac: Remove WindwosCE support.
* contrib/: Remove all; it was only used for WindowsCE.
* src/w32-ce.c, src/w32-ce.h: Remove files.
* src/Makefile.am (system_components): Remove these files.
* src/ath.c, src/ath.h: Remove W32CE support.
* src/data-compat.c (gpgme_data_new_from_filepart): Ditto.
(gpgme_data_new_from_file): Ditto.
* src/debug.c (debug_init, _gpgme_debug): Ditto.
* src/gpgme-tool.c (gpgme_server): Ditto.
(main): Ditto.
* src/priv-io.h: Do not include w32-ce.h.
* src/util.h: Remove WindowsCE support.
* src/w32-io.c: Ditto.
* src/w32-util.c: Ditto.
* src/debug.h (TRACE_SUC4): New.
--

There is no more hardware to test our code, the support for Windows CE
terminated along time ago.  Note that our code worked only with the
old WindowsCE with that overall system limit of 31 processes.

Signed-off-by: Werner Koch <wk@gnupg.org>
2018-10-31 12:35:14 +01:00
Werner Koch
8b9f84828c
Fix compiler warnings about unused value in TRACE macros.
* src/debug.h: Change macros to not have a literal 0 as last
expression of the comma operator.
* src/debug.c (_gpgme_debug_frame_end): Return 0.
(_gpgme_debug): Return 0.
--

Instead of using
   foo(), 0
for the trace macros we let foo() return 0 instead.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-06-08 11:08:08 +02:00
Werner Koch
8031341283 Improve the debug output a bit.
* src/debug.h (TRACE_ERR): Include the line number in the output.
2014-11-06 15:59:06 +01:00
Werner Koch
bd24feaa86 Trace the use of GPG_ERR_INV_ENGINE.
* src/debug.h: Include "gpgme.h"
(_gpgme_trace_gpgme_error): New.
(trace_gpg_error): New macro.  Use it in all files where we return
GPG_ERR_INV_ENGINE; also "include debug.h" as needed.
--

This is a pretty common error code but often it is hard to figure out
the actual cause.  With debug level 4 we now print the file name and
line number where this error code is generated by gpgme.  Along with
the git revision printed in the first log lines, this should give us
an easier way to track down the problems related to this error code.
2012-10-19 11:23:39 +02:00
Werner Koch
c62b79a1d6 Add gpgme_set_global_flag to help debugging
* src/gpgme.c (gpgme_set_global_flag): New.
* src/gpgme.h.in (gpgme_set_global_flag): New.
* src/gpgme.def, src/libgpgme.vers: Add new public function.
* src/debug.c (envvar_override): New.:
(_gpgme_debug_set_debug_envvar): New.
(debug_init): Take ENVVAR_OVERRIDE in account.
--

On Android envvars can't be used, thus we need another way to enable
GPGME debugging.  The new function allows this and may be used in the
future to implement similar things.
2012-09-25 15:38:26 +02:00
Werner Koch
139e798c87 Remove all trailing whitespace from source files
--
Command used:  sed -i 's,[ \t]*$,,' FILE
2012-09-25 15:29:49 +02:00
Marcus Brinkmann
dbb1112da1 2010-06-10 Marcus Brinkmann <marcus@g10code.de>
* debug.h (TRACE_SUC6): New macro.
	* w32-io.c (MAX_SLAFD): New macro.
	(fd_table): New static variable.
	(new_fd, release_fd): New functions.
	(fd_to_handle, handle_to_fd, handle_to_socket): Remove macros.
	(MAX_READERS, MAX_WRITERS): Increase to 64.
	(notify_table): Increase to MAX_SLAFD.
	(struct reader_context_s, struct writer_context_s): Add member
	file_sock.
	(reader, writer): Use file_hd vs file_sock to decide if socket
	operations to use.  Remove auto-detect mode.
	(create_reader, create_writer): Set file_sock.  Unblock pending
	thread only if this is a pipe fd.
	(_gpgme_io_pipe): Allocate fds from table and return slot indices
	instead of windows handles.  This allows to properly handle RVIDs.
	(_gpgme_io_close): Handle dup'ed file descriptors.
	(build_commandline) [HAVE_W32_SYSTEM]: Use RVID from fd table now.
	(_gpgme_io_spawn): Use fd table now.
	(_gpgme_io_fd2str): Use RVID from fd table now.
	(_gpgme_io_dup): Implement using fd table.
	(_gpgme_io_socket): Allocate fds from table.
	(_gpgme_io_connect): Use fd from table.
2010-06-10 13:49:19 +00:00
Marcus Brinkmann
49693e8e45 2009-11-04 Marcus Brinkmann <marcus@g10code.de>
* ath.h (ath_self): New prototype.  Include <stdint.h>
	* ath.c, ath-pth.c, ath-pthread.c (ath_self): New function.
	* debug.h: Rewrite most macros to beautify debug output.
	(_gpgme_debug_buffer): Remove tagname and tag argument.
	(_gpgme_debug_frame_begin, _gpgme_debug_frame_end): New prototypes.
	* debug.c: Include <time.h>.  Don't include assuan.h.
	(frame_nr, FRAME_NR): New thread-specific variable and macro.
	(debug_init): Do not initialize assuan.  Call _gpgme_debug after
	initialization instead using printf directly.
	(_gpgme_debug): Do not call debug_init (we now ensure proper
	initialization by user).  Add timestamp and thread/process ID.
	(_gpgme_debug_buffer): Do not take tagname and tag argument.
	(_gpgme_debug_frame_begin, _gpgme_debug_frame_end): New functions.
	* version.c (gpgme_check_version_internal, gpgme_check_version):
	Fix debug string.  Do not initialize assuan.
	* posix-io.c (get_max_fds): Use 0 not NULL (nicer debug output).
2009-11-04 18:13:44 +00:00
Marcus Brinkmann
490661821a 2009-11-02 Marcus Brinkmann <marcus@g10code.de>
* debug.h (_gpgme_debug_buffer): Make TAG argument const const.
	* debug.c (_gpgme_debug_buffer): Likewise.
	* gpgme-tool.c (input_notify, output_notify): Adjust type to new
	assuan interface.
	* decrypt.c (gpgme_op_decrypt_result): Remove unused variable.
	* opassuan.c (gpgme_op_assuan_transact): Fix return value.
2009-11-02 17:18:48 +00:00
Marcus Brinkmann
9d3fdd8c96 2009-10-30 Marcus Brinkmann <marcus@g10code.de>
* configure.ac: Check for argp.h and error_t.

src/
2009-10-30  Marcus Brinkmann  <marcus@g10code.de>

	* Makefile.am (noinst_PROGRAMS): New target gpgme-tool.
	(gpgme_tool_LDADD): New variable.
	* gpgme-tool.c: New file.
	* ops.h (_gpgme_sig_notation_clearm _gpgme_signers_clear): New
	prototypes.
	* gpgme.c (gpgme_set_protocol): Allow GPGME_PROTOCOL_GPGCONF (when
	had that gone missing?).
	(_gpgme_sig_notation_clear): New function without debug output.
	(gpgme_release): Call it and _gpgme_signers_clear.
	* signers.c (_gpgme_signers_clear): New function without debug output.
	* g13.c (gpgme_op_vfs_mount): Add debug output.
	* assuan-support.c (my_spawn): Allow fd_child_list to be NULL.
	* conversion.c (_gpgme_encode_percent_string): Fix infinite loop.
	* debug.h: Put tag in front of debug lines, should make for nicer
	output.
	* engine-assuan.c (llass_new): Use our new system hooks for libassuan.
	* engine-g13.c (g13_new): Remove redundant assuan context allocation.
	* version.c (gpgme_check_version_internal): Delay debug output
	until after gpgme_check_version was called.
2009-10-30 14:21:08 +00:00
Marcus Brinkmann
36e2c1a9d1 2009-10-27 Marcus Brinkmann <marcus@g10code.de>
* edit.c (gpgme_op_edit_start, gpgme_op_edit)
	(gpgme_op_card_edit_start, gpgme_op_card_edit): Add debug output.
	* encrypt-sign.c (gpgme_op_encrypt_sign_start)
	(gpgme_op_encrypt_sign): Likewise.
	* encrypt.c (gpgme_op_encrypt_start, gpgme_op_encrypt)
	(gpgme_op_encrypt_result): Likewise.
	* export.c (gpgme_op_export_start, gpgme_op_export)
	(gpgme_op_export_ext_start, gpgme_op_export_ext)
	(gpgme_op_export_keys_start, gpgme_op_export_keys): Likewise.
	* genkey.c (gpgme_op_genkey_start, gpgme_op_genkey)
	(gpgme_op_genkey_result): Likewise.
	* getauditlog.c (gpgme_op_getauditlog_start)
	(gpgme_op_getauditlog): Likewise.
	* import.c (gpgme_op_import_result, gpgme_op_import_start)
	(gpgme_op_import): Likewise.
	* keylist.c (gpgme_op_keylist_result, keylist_colon_handler)
	(gpgme_op_keylist_start, gpgme_op_keylist_ext_start)
	(gpgme_op_keylist_next, gpgme_op_keylist_end, gpgme_get_key): Likewise.
	* opassuan.c (gpgme_op_assuan_transact_start)
	(gpgme_op_assuan_transact_ext, gpgme_op_assuan_result)
	(gpgme_op_assuan_transact): Likewise.
	* signers.c (gpgme_signers_add, gpgme_signers_clear): Likewise.
	* trustlist.c (gpgme_op_trustlist_start)
	(gpgme_op_trustlist_next, gpgme_op_trustlist_end): Likewise.
	* verify.c (gpgme_op_verify_start, gpgme_op_verify)
	(gpgme_op_verify_result): Likewise.
2009-10-27 19:23:56 +00:00
Marcus Brinkmann
ca67902311 2009-10-26 Marcus Brinkmann <marcus@g10code.de>
* debug.h (DEBUG_GLOBAL): New debug level.
	* conversion.c (gnupg_errors, _gpgme_map_gnupg_error): Removed.
	* data-user.c (gpgme_data_new_from_cbs): Add debug output.
	* data-fd.c (gpgme_data_new_from_fd): Likewise.
	* data-stream.c (gpgme_data_new_from_stream): Likewise.
	* decrypt.c (gpgme_op_decrypt_result, gpgme_op_decrypt_start)
	(gpgme_op_decrypt): Likewise.
	* delete.c (gpgme_op_delete_start, gpgme_op_delete): Likewise.
	* decrypt-verify.c (gpgme_op_decrypt_verify_start)
	(gpgme_op_decrypt_verify): Likewise.
	* sign.c (gpgme_op_sign_result): Fix debug message.
	* data-mem.c (gpgme_data_new): Improve debug output.
	* verify.c (parse_trust): Use atoi instead of
	_gpgme_map_gnupg_error.
	* decrypt.c (_gpgme_decrypt_status_handler): Likewise.
2009-10-26 17:38:39 +00:00
Marcus Brinkmann
1c454aee81 2009-06-22 Marcus Brinkmann <marcus@g10code.de>
* configure.ac: Add AC_TYPE_UINTPTR_T.

	* assuan/assuan.h [_ASSUAN_IN_GPGME_BUILD_ASSUAN]: Declare
	_gpgme_io_connect.

src/
2009-06-22  Marcus Brinkmann  <marcus@g10code.de>

	* debug.h: Everywhere, use %p instead of 0x%x to print pointer.
	[HAVE_STDINT_H]: Include <stdint.h>.
	(_TRACE, TRACE, TRACE0, TRACE1, TRACE2, TRACE3, TRACE6): Cast tag
	to (uintptr_t) before casting it to (void*) to silence GCC
	warning.

	* gpgme.h.in (_GPGME_DEPRECATED_OUTSIDE_GPGME): New macro.
	* sign.c (_GPGME_IN_GPGME): Define it.
	* keylist.c (_GPGME_IN_GPGME): Define it.

	* debug.c (_gpgme_debug_begin, _gpgme_debug_add): Handle error in
	vasprintf and asprintf.

	* priv-io.h: Include <sys/socket.h>.  Declare _gpgme_io_connect.

tests/
2009-06-22  Marcus Brinkmann  <marcus@g10code.de>

	* gpg/t-support.h (passphrase_cb): Implement write() according to
	the book to silence compiler warning.
	* gpgsm/t-support.h (passphrase_cb): Likewise.
2009-06-22 14:50:17 +00:00
Marcus Brinkmann
66d0fa1973 008-11-03 Marcus Brinkmann <marcus@g10code.com>
* configure.ac: Replace gpgme paths with src.
        * gpgme: Move to ...
        * src: ... this new directory.

assuan/
2008-11-03  Marcus Brinkmann  <marcus@g10code.com>

	* Makefile.am (INCLUDES): Replace gpgme path with src.

tests/
2008-11-03  Marcus Brinkmann  <marcus@g10code.com>

        * gpgsm/Makefile.am (INCLUDES, LDADD): Replace gpgme path with src.
        * gpg/Makefile.am (INCLUDES, LDADD, t_thread1_LDADD): Likewise.
	* Makefile.am (LDADD): Likewise.
2008-11-03 17:24:09 +00:00