Tizen Native API  6.0
Diagnostics

The Diagnostics API provides functions to receive crash reports and request logs from other apps.

Required Header

#include <diagnostics.h>

Overview

This Diagnostics API allows applications to receive notification about newly created crash report, as well as request other apps to dump their logs in real time. Moreover, functions for reading crash and log contents are provided.

Realted Features

This API is related with the following feature:

  • http://tizen.org/feature/diagnostics

It is recommended to design feature related codes in your application for reliability.

You can check if a device supports the related features for this API by using System Information,thereby controlling the procedure of your application.

To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.

More details on featuring your application can be found from Feature Element.

Functions

int diagnostics_set_notification_cb (diagnostics_notification_cb callback, void *user_data)
 Sets the callback for bug report notification.
int diagnostics_unset_notification_cb (void)
 Unsets the callback for bug report notification.
int diagnostics_request_client_data (const char *client_id, const char **params, int params_size, diagnostics_data_h *data)
 Requests client to dump data.
int diagnostics_data_read (diagnostics_data_h data, void *buf, size_t count, int timeout_ms, size_t *bytes_read)
 Reads diagnostics data.
int diagnostics_data_destroy (diagnostics_data_h data)
 Frees diagnostics data.
int diagnostics_get_client_id (diagnostics_ctx_h ctx, char **client_id)
 Gets diagnostics context provider's id.
int diagnostics_get_data (diagnostics_ctx_h ctx, const char **params, int params_size, diagnostics_data_h *data)
 Gets report data.
int diagnostics_destroy (diagnostics_ctx_h ctx)
 Frees diagnostics context.

Typedefs

typedef void * diagnostics_ctx_h
 Diagnostics context.
typedef void * diagnostics_data_h
 Diagnostics data.
typedef void(* diagnostics_notification_cb )(diagnostics_ctx_h ctx, void *user_data)
 Notification callback fired when new bug report arrives.

Typedef Documentation

typedef void* diagnostics_ctx_h

Diagnostics context.

Since :
6.0
typedef void* diagnostics_data_h

Diagnostics data.

Since :
6.0
typedef void(* diagnostics_notification_cb)(diagnostics_ctx_h ctx, void *user_data)

Notification callback fired when new bug report arrives.

Since :
6.0
Remarks:
ctx should be released with diagnostics_destroy()
Parameters:
[in]ctxDiagnostics context handle
[in]user_dataThe user data passed from the callback registration function

Enumeration Type Documentation

Enumeration for error codes of Diagnostics.

Since :
6.0
Enumerator:
DIAGNOSTICS_ERROR_NONE 

Successful

DIAGNOSTICS_ERROR_INVALID_PARAMETER 

Invalid parameter

DIAGNOSTICS_ERROR_IO_ERROR 

I/O error

DIAGNOSTICS_ERROR_OUT_OF_MEMORY 

Out of memory

DIAGNOSTICS_ERROR_RESOURCE_BUSY 

Device or resource busy

DIAGNOSTICS_ERROR_TIMED_OUT 

Time out

DIAGNOSTICS_ERROR_NOT_SUPPORTED 

Not supported

DIAGNOSTICS_ERROR_TRY_AGAIN 

Try again

DIAGNOSTICS_ERROR_PERMISSION_DENIED 

Permission denied


Function Documentation

Frees diagnostics data.

Since :
6.0
Parameters:
[in]dataDiagnostics data handle
Returns:
0 on success, otherwise a negative error value
Return values:
DIAGNOSTICS_ERROR_NONESuccess
DIAGNOSTICS_ERROR_NOT_SUPPORTEDNot supported
DIAGNOSTICS_ERROR_INVALID_PARAMETERProvided parameter is invalid
int diagnostics_data_read ( diagnostics_data_h  data,
void *  buf,
size_t  count,
int  timeout_ms,
size_t *  bytes_read 
)

Reads diagnostics data.

Since :
6.0
Remarks:
data should be released with diagnostics_data_destroy(). This function is intended for use in loop until EOF is reached. EOF is when bytes_read == 0 and function returns DIAGNOSTICS_ERROR_NONE.
Parameters:
[in]dataDiagnostics data handle
[in,out]bufBuffer to store read data
Provided buffer must be large enough to contain count number of bytes
[in]countNumber of bytes to read
[in]timeout_msTimeout [ms] for reading requested number of bytes (timeout_ms <= 0 means to wait forever)
[out]bytes_readReal number of read bytes
Returns:
0 on success, otherwise a negative error value
Return values:
DIAGNOSTICS_ERROR_NONESuccess
DIAGNOSTICS_ERROR_NOT_SUPPORTEDNot supported
DIAGNOSTICS_ERROR_INVALID_PARAMETERProvided parameter is invalid
DIAGNOSTICS_ERROR_TIMED_OUTTimeout occured
DIAGNOSTICS_ERROR_TRY_AGAINTry again
DIAGNOSTICS_ERROR_IO_ERRORInternal error occured while trying to read data, result is unspecified and *bytes_read is not updated

Frees diagnostics context.

Since :
6.0
Parameters:
[in]ctxDiagnostics context handle
Returns:
0 on success, otherwise a negative error value
Return values:
DIAGNOSTICS_ERROR_NONESuccess
DIAGNOSTICS_ERROR_NOT_SUPPORTEDNot supported
DIAGNOSTICS_ERROR_INVALID_PARAMETERProvided parameter is invalid
int diagnostics_get_client_id ( diagnostics_ctx_h  ctx,
char **  client_id 
)

Gets diagnostics context provider's id.

Since :
6.0
Remarks:
client_id should be released with free().
Parameters:
[in]ctxDiagnostics context handle
[out]client_idAn id of the context provider
Returns:
0 on success, otherwise a negative error value
Return values:
DIAGNOSTICS_ERROR_NONESuccess
DIAGNOSTICS_ERROR_NOT_SUPPORTEDNot supported
DIAGNOSTICS_ERROR_INVALID_PARAMETERProvided parameter is invalid
int diagnostics_get_data ( diagnostics_ctx_h  ctx,
const char **  params,
int  params_size,
diagnostics_data_h data 
)

Gets report data.

Warning:
This is not for use by third-party applications.
Since :
6.0
Privilege Level:
platform
Privilege:
Remarks:
data should be released with diagnostics_data_destroy(). This function is permitted only to an app signed by platform level certificates.
Parameters:
[in]ctxDiagnostics context handle
[in]paramsArray of parameters
Refer to context provider's documentation for available parameters
[in]params_sizeNumber of parameters
[out]dataDiagnostics data handle
Returns:
0 on success, otherwise a negative error value
Return values:
DIAGNOSTICS_ERROR_NONESuccess
DIAGNOSTICS_ERROR_NOT_SUPPORTEDNot supported
DIAGNOSTICS_ERROR_PERMISSION_DENIEDPermission denied
DIAGNOSTICS_ERROR_INVALID_PARAMETERProvided parameter is invalid
DIAGNOSTICS_ERROR_IO_ERRORInternal error occured
DIAGNOSTICS_ERROR_OUT_OF_MEMORYNot enough memory to create data handle
int diagnostics_request_client_data ( const char *  client_id,
const char **  params,
int  params_size,
diagnostics_data_h data 
)

Requests client to dump data.

Warning:
This is not for use by third-party applications.
Since :
6.0
Privilege Level:
platform
Privilege:
Remarks:
data should be released with diagnostics_data_destroy(). This function is permitted only to an app signed by platform level certificates.
Parameters:
[in]client_idAn id of app or service to request
[in]paramsArray of parameters
[in]params_sizeNumber of parameters
[out]dataDumpsys data handle
Returns:
0 on success, otherwise a negative error value
Return values:
DIAGNOSTICS_ERROR_NONESuccess
DIAGNOSTICS_ERROR_NOT_SUPPORTEDNot supported
DIAGNOSTICS_ERROR_PERMISSION_DENIEDPermission denied
DIAGNOSTICS_ERROR_INVALID_PARAMETERProvided parameter is invalid
DIAGNOSTICS_ERROR_IO_ERRORInternal error occured
DIAGNOSTICS_ERROR_OUT_OF_MEMORYNot enough memory to create data handle
int diagnostics_set_notification_cb ( diagnostics_notification_cb  callback,
void *  user_data 
)

Sets the callback for bug report notification.

Since :
6.0
Parameters:
[in]callbackA callback function to set
[in]user_dataThe user data to be passed to the callback function
Returns:
0 on success, otherwise a negative error value
Return values:
DIAGNOSTICS_ERROR_NONESuccess
DIAGNOSTICS_ERROR_NOT_SUPPORTEDNot supported
DIAGNOSTICS_ERROR_INVALID_PARAMETERProvided parameter is invalid
DIAGNOSTICS_ERROR_RESOURCE_BUSYCallback already registered
DIAGNOSTICS_ERROR_IO_ERRORInternal error occured

Unsets the callback for bug report notification.

Since :
6.0
Returns:
0 on success, otherwise a negative error value
Return values:
DIAGNOSTICS_ERROR_NONESuccess
DIAGNOSTICS_ERROR_NOT_SUPPORTEDNot supported
DIAGNOSTICS_ERROR_IO_ERRORInternal error occured